Ejemplo n.º 1
0
        public void ShortResults()
        {
            byte[] decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short017));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "017");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short063));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "063");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short136));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "136");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short264));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "264");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short482));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "482");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short631));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "631");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short634));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "634");

            decdata = PKCS1.Decrypt_v15(rsa, Convert.FromBase64String(short890));
            Assert.AreEqual("<password>", Encoding.UTF8.GetString(decdata), "890");
        }
        public override byte[] DecryptKeyExchange(byte[] rgbIn)
        {
            if (rsa == null)
            {
                throw new CryptographicUnexpectedOperationException(
                          Locale.GetText("No key pair available."));
            }

            byte[] result = PKCS1.Decrypt_v15(rsa, rgbIn);
            if (result != null)
            {
                return(result);
            }

            throw new CryptographicException(Locale.GetText("PKCS1 decoding error."));
        }