예제 #1
0
        public byte[] DecryptOaep(byte[] cipherText, byte[] label)
        {
            var rr = new RawRsa(Key);

            byte[] plainText = rr.OaepDecrypt(cipherText, OaepHash, label);
            return(plainText);
        }
예제 #2
0
        public byte[] DecryptOaep(byte[] cipherText, byte[] label)
        {
#if TSS_USE_BCRYPT
            var    paddingInfo = new BCryptOaepPaddingInfo(OaepHash, label);
            byte[] plainText   = Key.Decrypt(cipherText, paddingInfo);
#elif false
            var    rr        = new RawRsa(RsaProvider.ExportParameters(true), RsaProvider.KeySize);
            byte[] plainText = rr.OaepDecrypt(cipherText, OaepHash, label);
#else
            RSAParameters parms       = RsaProvider.ExportParameters(true);
            var           alg         = new BCryptAlgorithm(Native.BCRYPT_RSA_ALGORITHM);
            var           key         = alg.LoadRSAKey(parms.Exponent, parms.Modulus, parms.P, parms.Q);
            var           paddingInfo = new BCryptOaepPaddingInfo(OaepHash, label);
            byte[]        plainText   = key.Decrypt(cipherText, paddingInfo);
            key.Destroy();
            alg.Close();
#endif
            return(plainText);
        }