Exemple #1
0
        /// <summary>
        /// Verify the given data and signature using RSA.
        /// </summary>
        public static bool VerifySignedHashUsingRSA(byte[] dataToVerify, byte[] signedData,
                                                    string keyContainerName, HashAlgorithmTypeEnum hashType)
        {
            RSACryptoServiceProvider rsa = AsymmetricOperation.GetRSACryptoServiceProvider(keyContainerName);

            return(rsa.VerifyData(dataToVerify, HashOperation.CreateHashAlgorithmProvider(hashType), signedData));
        }
Exemple #2
0
        /// <summary>
        /// Hash the given data and sign it using DSA.
        /// </summary>
        public static byte[] HashAndSignUsingDSA(byte[] dataToSign, string keyContainerName, HashAlgorithmTypeEnum hashType)
        {
            DSACryptoServiceProvider dsa = AsymmetricOperation.GetDSACryptoServiceProvider(keyContainerName);

            byte[] hashedData = HashOperation.CreateHashAlgorithmProvider(hashType).ComputeHash(dataToSign);
            return(dsa.CreateSignature(hashedData));
        }
Exemple #3
0
        /// <summary>
        /// Hash the given data and sign it using RSA.
        /// </summary>
        public static byte[] HashAndSignUsingRSA(byte[] dataToSign, string keyContainerName,
                                                 HashAlgorithmTypeEnum hashType)
        {
            RSACryptoServiceProvider rsa = AsymmetricOperation.GetRSACryptoServiceProvider(keyContainerName);

            return(rsa.SignData(dataToSign, HashOperation.CreateHashAlgorithmProvider(hashType)));
        }
Exemple #4
0
        /// <summary>
        /// Verify the given data and signature using RSA.
        /// </summary>
        public static bool VerifySignedHashUsingDSA(byte[] dataToVerify, byte[] signedData,
                                                    string keyContainerName, HashAlgorithmTypeEnum hashType)
        {
            DSACryptoServiceProvider dsa = AsymmetricOperation.GetDSACryptoServiceProvider(keyContainerName);

            byte[] hashedData = HashOperation.CreateHashAlgorithmProvider(hashType).ComputeHash(dataToVerify);
            return(dsa.VerifySignature(hashedData, signedData));
        }