Tpm2Lib.TpmPublic.VerifyCertify C# (CSharp) Method

VerifyCertify() public method

Verify that quotedInfo is properly signed by an associated private key holder, and that the quotedInfo.type, .extraData and .magic are correct. Also check that the certified name is what the caller expects. The caller must check other fields (for instance the qualified name)
public VerifyCertify ( TpmHash name, byte nonce, Attest quotedInfo, byte expectedName, ISignatureUnion signature ) : bool
name TpmHash
nonce byte
quotedInfo Attest
expectedName byte
signature ISignatureUnion
return bool
        public bool VerifyCertify(TpmHash name, byte[] nonce, Attest quotedInfo, byte[] expectedName, ISignatureUnion signature)
        {
            // Check generic signature stuff
            if (quotedInfo.type != TpmSt.AttestCertify)
            {
                return false;
            }

            if (!Globs.ArraysAreEqual(quotedInfo.extraData, nonce))
            {
                return false;
            }

            if (quotedInfo.magic != Generated.Value)
            {
                return false;
            }

            // Check specific certify-signature stuff
            var certInfo = (CertifyInfo)quotedInfo.attested;
            if (!Globs.ArraysAreEqual(expectedName, certInfo.name))
            {
                return false;
            }
            // Check the actual signature
            TpmHash sigHash = TpmHash.FromData(TpmAlgId.Sha1, quotedInfo.GetTpmRepresentation());
            bool certifyOk = VerifySignatureOverHash(sigHash, signature);
            return certifyOk;
        }