Tpm2Lib.Tpm2.HashSequenceStart C# (CSharp) Method

HashSequenceStart() private method

private HashSequenceStart ( byte auth, TpmAlgId hashAlg ) : TpmHandle
auth byte
hashAlg TpmAlgId
return TpmHandle
        public TpmHandle HashSequenceStart(
            byte[] auth,
            TpmAlgId hashAlg
        )
        {
            Tpm2HashSequenceStartRequest inS = new Tpm2HashSequenceStartRequest();
            inS.auth = auth;
            inS.hashAlg = hashAlg;
            TpmStructureBase outSBase;
            DispatchMethod(TpmCc.HashSequenceStart, (TpmStructureBase) inS, typeof(Tpm2HashSequenceStartResponse), out outSBase, 0, 1);
            Tpm2HashSequenceStartResponse outS = (Tpm2HashSequenceStartResponse) outSBase;
            outS.sequenceHandle.Name = new byte[0];
            return outS.sequenceHandle;
        }
        /// <summary>

Usage Example

Esempio n. 1
0
        /// <summary>
        /// This sample shows the use of HMAC sessions to authorize TPM actions.
        /// HMAC sessions may be bound/unbound and seeded/unseeded.  This sample
        /// illustrates an unseeded and unbound session.
        /// </summary>
        /// <param name="tpm">Reference to the TPM object.</param>
        static void HmacUnboundUnseeded(Tpm2 tpm)
        {
            //
            // Create a hash-sequence with a random authorization value
            // 
            AuthValue authVal = AuthValue.FromRandom(8);
            TpmHandle hashHandle = tpm.HashSequenceStart(authVal, TpmAlgId.Sha256);

            //
            // Commands with the Ex modifier are library-provided wrappers
            // around TPM functions to make programming easier.  This version
            // of StartAuthSessionEx calls StartAuthSession configured to 
            // create an unbound and unseeded auth session with the auth-value 
            // provided here.
            // 
            AuthSession s0 = tpm.StartAuthSessionEx(TpmSe.Hmac, TpmAlgId.Sha256);

            //
            // The following calls show the use of the HMAC session in authorization.
            // The session to use is communicated as a parameter in the [] overloaded 
            // function and the auth-value is that set during HMAC session creation.
            // 
            TkHashcheck validate;
            tpm[s0].SequenceUpdate(hashHandle, new byte[] { 0, 2, 1 });
            byte[] hashedData = tpm[s0].SequenceComplete(hashHandle,
                                                         new byte[] { 2, 3, 4 },
                                                         TpmHandle.RhOwner,
                                                         out validate);

            Console.WriteLine("Hashed data (HMAC authorized sequence): " + BitConverter.ToString(hashedData));
            tpm.FlushContext(s0.Handle);
        }
All Usage Examples Of Tpm2Lib.Tpm2::HashSequenceStart
Tpm2