Tpm2Lib.TpmPublic.GetName C# (CSharp) Method

GetName() public method

Calculate and return the name of the entity. The name is an alg-prepended hash in a byte[]
public GetName ( ) : byte[]
return byte[]
        public byte[] GetName()
        {
            byte[] rawData = GetTpmRepresentation();
            TpmHash pubDigest = TpmHash.FromData(nameAlg, rawData);
            return Marshaller.GetTpmRepresentation(pubDigest);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Name processing for Load-style operations
        /// </summary>
        /// <param name="h"></param>
        /// <param name="tpmAssignedName"></param>
        /// <param name="publicPart"></param>
        internal void ProcessName(TpmHandle h, byte[] tpmAssignedName, TpmPublic publicPart)
        {
            // Has been configured to *not* throw an exception if the TPM returns an error.
            if (tpmAssignedName.Length == 0)
                return;

            // If the load-command fails then the name returned is NULL.
            if (!NamesEqual(publicPart.GetName(), tpmAssignedName))
                throw new Exception("TPM assigned name differs from that expected");
            h.Name = tpmAssignedName;
        }