예제 #1
0
        /// <summary>
        /// Check the type of signature and use the publicKeyDer to verify the
        /// signedBlob using the appropriate signature algorithm.
        /// </summary>
        ///
        /// <param name="signature"></param>
        /// <param name="signedBlob">the SignedBlob with the signed portion to verify.</param>
        /// <param name="publicKeyDer"></param>
        /// <returns>True if the signature is verified, false if failed.</returns>
        /// <exception cref="System.Security.SecurityException">if the signature type is not recognized or ifpublicKeyDer can't be decoded.</exception>
        protected internal static bool verifySignature(
				net.named_data.jndn.Signature signature, SignedBlob signedBlob,
				Blob publicKeyDer)
        {
            if (signature  is  Sha256WithRsaSignature) {
                if (publicKeyDer.isNull())
                    return false;
                return verifySha256WithRsaSignature(signature.getSignature(),
                        signedBlob, publicKeyDer);
            } else if (signature  is  Sha256WithEcdsaSignature) {
                if (publicKeyDer.isNull())
                    return false;
                return verifySha256WithEcdsaSignature(signature.getSignature(),
                        signedBlob, publicKeyDer);
            } else if (signature  is  DigestSha256Signature)
                return verifyDigestSha256Signature(signature.getSignature(),
                        signedBlob);
            else
                // We don't expect this to happen.
                throw new SecurityException(
                        "PolicyManager.verify: Signature type is unknown");
        }