Extend() public method

Replace the hash value with the hash of the concatenation of the current value and the TPM representation of objectToExtend
public Extend ( Object objectToExtend ) : TpmHash
objectToExtend Object
return TpmHash
コード例 #1
0
        internal override TpmHash GetPolicyDigest(TpmAlgId hashAlg)
        {
            TpmCc commandCode = 0;

            if (TicketType == TpmSt.AuthSecret)
            {
                commandCode = TpmCc.PolicySecret;
            }
            else if (TicketType == TpmSt.AuthSigned)
            {
                commandCode = TpmCc.PolicySigned;
            }
            else
            {
                Globs.Throw <ArgumentException>("Ticket type is not recognized");
                return(new TpmHash(hashAlg));
            }

            if (ObjectName == null)
            {
                ObjectName = AuthorizingKey.GetName();
            }
            var m = new Marshaller();

            m.Put(commandCode, "ordinal");
            m.Put(ObjectName, "name");

            // ReSharper disable once UnusedVariable
            TpmHash atStart      = GetNextAcePolicyDigest(hashAlg);
            TpmHash firstExtend  = GetNextAcePolicyDigest(hashAlg).Extend(m.GetBytes());
            TpmHash secondExtend = firstExtend.Extend(PolicyRef);

            return(secondExtend);
        }
コード例 #2
0
        /// <summary>
        /// Implements the first step of the policy digest update (see the PolicyUpdate()
        /// method), and also used by PolicyAuthorizeNV.
        /// </summary>
        internal TpmHash PolicyUpdate1(TpmHash currentHash, TpmCc commandCode, byte[] name)
        {
            var m = new Marshaller();

            m.Put(commandCode, "commandCode");
            m.Put(name, "name");

            return(currentHash.Extend(m.GetBytes()));
        }
コード例 #3
0
        internal override TpmHash GetPolicyDigest(TpmAlgId hashAlg)
        {
            var m = new Marshaller();

            m.Put(TpmCc.PolicyNvWritten, "ordinal");
            byte writtenName = IsNvIndexRequiredToHaveBeenWritten ? (byte)1 : (byte)0;

            m.Put(writtenName, "writtenSet");
            TpmHash previous = GetNextAcePolicyDigest(hashAlg);

            return(previous.Extend(m.GetBytes()));
        }
コード例 #4
0
        internal override TpmHash GetPolicyDigest(TpmAlgId hashAlg)
        {
            var m = new Marshaller();

            m.Put(TpmCc.PolicyDuplicationSelect, "ordinal");
            if (IncludeObjectNameInPolicyHash)
            {
                m.Put(NameOfObject, "objectName");
            }
            m.Put(NameOfNewParent, "newParent");
            byte includeName = IncludeObjectNameInPolicyHash ? (byte)1 : (byte)0;

            m.Put(includeName, "includeObject");
            TpmHash previous = GetNextAcePolicyDigest(hashAlg);

            return(previous.Extend(m.GetBytes()));
        }
コード例 #5
0
        internal override TpmHash GetPolicyDigest(TpmAlgId hashAlg)
        {
            var m = new Marshaller();

            m.Put(OperandB, "operandB");
            m.Put(Offset, "offset");
            m.Put(Operation, "operation");
            byte[] toHash = m.GetBytes();
            byte[] args   = CryptoLib.HashData(hashAlg, toHash);

            m = new Marshaller();
            m.Put(TpmCc.PolicyCounterTimer, "cc");
            m.Put(args, "args");

            TpmHash tailHash = GetNextAcePolicyDigest(hashAlg);
            TpmHash hashNow  = tailHash.Extend(m.GetBytes());

            return(hashNow);
        }
コード例 #6
0
ファイル: PolicyAces.cs プロジェクト: Microsoft/TSS.MSR
        /// <summary>
        /// Implements the first step of the policy digest update (see the PolicyUpdate()
        /// method), and also used by PolicyAuthorizeNV.
        /// </summary>
        internal TpmHash PolicyUpdate1(TpmHash currentHash, TpmCc commandCode, byte[] name)
        {
            var m = new Marshaller();
            m.Put(commandCode, "commandCode");
            m.Put(name, "name");

            return currentHash.Extend(m.GetBytes());
        }
コード例 #7
0
ファイル: PolicyAces.cs プロジェクト: vishalishere/TSS.MSR
 /// <summary>
 /// Return an updated policy hash according to the TPM specification.
 /// </summary>
 /// <param name="?"></param>
 /// <param name="currentHash"></param>
 /// <param name="commandCode"></param>
 /// <param name="name"></param>
 /// <param name="refData"></param>
 /// <returns></returns>
 internal TpmHash PolicyUpdate(TpmHash currentHash, TpmCc commandCode, byte[] name, byte[] refData)
 {
     var m = new Marshaller();
     m.Put(commandCode, "commandCode");
     m.Put(name, "name");
     TpmHash h1 = currentHash.Extend(m.GetBytes());
     TpmHash h2 = h1.Extend(refData);
     return h2;
 }