예제 #1
0
        public void Window_Loaded()
        {
            if (t_Gel.ID == 0)
            {
                IsNew            = true;
                base.DisplayName = "新建";
            }
            else
            {
                base.DisplayName = "修改";
            }

            unknown = new UnknownResult(t_Gel.UnknownResult);

            Tbs.Clear();
            Tbs.Add(new TubeName(1, t_Gel.Name1));
            Tbs.Add(new TubeName(2, t_Gel.Name2));
            Tbs.Add(new TubeName(3, t_Gel.Name3));
            Tbs.Add(new TubeName(4, t_Gel.Name4));
            Tbs.Add(new TubeName(5, t_Gel.Name5));
            Tbs.Add(new TubeName(6, t_Gel.Name6));
            Tbs.Add(new TubeName(7, t_Gel.Name7));
            Tbs.Add(new TubeName(8, t_Gel.Name8));

            var count = t_Gel.GelSteps.Count;

            GelSteps.AddRange(t_Gel.GelSteps);
            for (int i = 0; i < 20 - count; i++)
            {
                GelSteps.Add(new T_GelStep()
                {
                    StepIndex = count + i
                });
            }
        }
예제 #2
0
        public X509Certificate SignWith(X509PrivateKey authorityPrivateKey)
        {
            var tbsData = Tbs.ToAsn1().GetBytes();
            var data    = authorityPrivateKey.SignData(tbsData);

            SignatureValue     = new Asn1BitString(data);
            SignatureAlgorithm = Tbs.SignatureAlgorithm;
            return(this);
        }
예제 #3
0
 public Asn1Node ToAsn1()
 {
     return(new Asn1Sequence {
         Nodes =
         {
             Tbs.ToAsn1(),
             SignatureAlgorithm.ToAsn1(),
             SignatureValue
         }
     });
 }
예제 #4
0
        /// <summary>
        /// This sample illustrates the use of the resource manager built into
        /// Tpm2Lib.  Using the resource manager relieves the programmer of the
        /// (sometimes burdensome) chore of juggling a small number of TPM slots
        /// </summary>
        /// <param name="tpm">Reference to the TPM object.</param>
        static void ResourceManager(Tpm2 tpm)
        {
            //
            // The Tbs device class has a built-in resource manager. We create an
            // instance of the Tbs device class, but hook it up to the TCP device
            // created above. We also tell the Tbs device class to clean the TPM
            // before we start using it.
            // This sample won't work on top of the default Windows resource manager
            // (TBS).
            //
            var tbs    = new Tbs(tpm._GetUnderlyingDevice(), false);
            var tbsTpm = new Tpm2(tbs.CreateTbsContext());

            //
            // Make more sessions than the TPM has room for
            //
            const int count    = 32;
            var       sessions = new AuthSession[count];

            for (int j = 0; j < count; j++)
            {
                sessions[j] = tbsTpm.StartAuthSessionEx(TpmSe.Policy, TpmAlgId.Sha1);
            }

            Console.WriteLine("Created {0} sessions.", count);

            //
            // And now use them. The resource manager will use ContextLoad and
            // ContextSave to bring them into the TPM
            //
            for (int j = 0; j < count; j++)
            {
                tbsTpm.PolicyAuthValue(sessions[j].Handle);
            }

            Console.WriteLine("Used {0} sessions.", count);

            //
            // And now clean up
            //
            for (int j = 0; j < count; j++)
            {
                tbsTpm.FlushContext(sessions[j].Handle);
            }

            Console.WriteLine("Cleaned up.");

            //
            // Dispose of the Tbs device object.
            //
            tbsTpm.Dispose();
        }
예제 #5
0
 public Asn1Node ToAsn1()
 {
     if (SignatureValue == null)
     {
         throw new Exception("Certificate is not signed");
     }
     return(new Asn1Sequence {
         Nodes =
         {
             Tbs.ToAsn1(),
             SignatureAlgorithm.ToAsn1(),
             SignatureValue
         }
     });
 }