コード例 #1
0
        /// <summary>
        ///     Verifies that alleged signature of a hash is, in fact, a valid signature of that hash.
        /// </summary>
        public override bool VerifyHash(byte[] hash, byte[] signature)
        {
            if (hash == null)
            {
                throw new ArgumentNullException("hash");
            }
            if (signature == null)
            {
                throw new ArgumentNullException("signature");
            }

            unsafe
            {
                bool verified = CngAsymmetricAlgorithmCore.VerifyHash(Key, hash, signature, AsymmetricPaddingMode.None, null);
                return(verified);
            }
        }
コード例 #2
0
        /// <summary>
        ///     Verifies that alleged signature of a hash is, in fact, a valid signature of that hash.
        /// </summary>
        public override bool VerifyHash(byte[] hash, byte[] signature, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding)
        {
            if (hash == null)
            {
                throw new ArgumentNullException("hash");
            }
            if (signature == null)
            {
                throw new ArgumentNullException("signature");
            }

            unsafe
            {
                bool verified = false;
                SignOrVerify(padding, hashAlgorithm, hash,
                             delegate(AsymmetricPaddingMode paddingMode, void *pPaddingInfo)
                {
                    verified = CngAsymmetricAlgorithmCore.VerifyHash(Key, hash, signature, paddingMode, pPaddingInfo);
                }
                             );
                return(verified);
            }
        }