Beispiel #1
0
        public override byte[] Decrypt(byte[] data, RSAEncryptionPadding padding)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data");
            }

            if (padding == null)
            {
                throw new ArgumentNullException("padding");
            }

            SafeNCryptKeyHandle keyHandle = KeyHandle;

            if (padding == RSAEncryptionPadding.Pkcs1)
            {
                return(NCryptNative.DecryptDataPkcs1(keyHandle, data));
            }
            else if (padding.Mode == RSAEncryptionPaddingMode.Oaep)
            {
                return(NCryptNative.DecryptDataOaep(keyHandle, data, padding.OaepHashAlgorithm.Name));
            }
            else
            {
                // no other padding possibilities at present, but we might version independently from more being added.
                throw new CryptographicException(SR.GetString(SR.Cryptography_UnsupportedPaddingMode));
            }
        }