コード例 #1
0
        public byte[] Decrypt(byte[] rgb, bool fOAEP)
        {
            if (rgb == null)
            {
                throw new ArgumentNullException("rgb");
            }

            // size check -- must be at most the modulus size
            if (rgb.Length > (KeySize / 8))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_Padding_DecDataTooBig", KeySize / 8));
            }

            if (m_disposed)
            {
                throw new ObjectDisposedException("rsa");
            }
            // choose between OAEP or PKCS#1 v.1.5 padding
            AsymmetricKeyExchangeDeformatter def = null;

            if (fOAEP)
            {
                def = new RSAOAEPKeyExchangeDeformatter(rsa);
            }
            else
            {
                def = new RSAPKCS1KeyExchangeDeformatter(rsa);
            }

            return(def.DecryptKeyExchange(rgb));
        }
コード例 #2
0
        public byte[] Decrypt(byte[] rgb, bool fOAEP)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException("rsa");
            }
            // choose between OAEP or PKCS#1 v.1.5 padding
            AsymmetricKeyExchangeDeformatter def = null;

            if (fOAEP)
            {
                def = new RSAOAEPKeyExchangeDeformatter(rsa);
            }
            else
            {
                def = new RSAPKCS1KeyExchangeDeformatter(rsa);
            }

            return(def.DecryptKeyExchange(rgb));
        }