Open() публичный Метод

Calls EVP_OpenInit() and EVP_OpenFinal()
public Open ( byte input, byte ekey, byte iv, OpenSSL.Crypto.CryptoKey pkey ) : byte[]
input byte
ekey byte
iv byte
pkey OpenSSL.Crypto.CryptoKey
Результат byte[]
Пример #1
0
		public void TestSealOpen(Cipher cipher)
		{
			if (cipher == Cipher.Null)
				Assert.Ignore();

			var inputMsg = "This is a message";
			var input = Encoding.ASCII.GetBytes(inputMsg);

			using (var cc = new CipherContext(cipher))
			{
				var env = cc.Seal(Keys, input);
				Assert.AreNotEqual(input, env.Data);

				for (int i = 0; i < Keys.Length; i++)
				{
					var result = cc.Open(env.Data, env.Keys[i], env.IV, Keys[i]);
					Assert.AreEqual(input, result);
				}
			}
		}
Пример #2
0
        public void TestSealOpen()
        {
            string inputMsg = "This is a message";
            byte[] input = Encoding.ASCII.GetBytes(inputMsg);
            const int numKeys = 10;
            var rsas = new RSA[numKeys];
            var pkeys = new CryptoKey[numKeys];
            for (int i = 0; i < numKeys; i++) {
                rsas[i] = new RSA();
                rsas[i].GenerateKeys(1024, BigNumber.One, null, null);
                pkeys[i] = new CryptoKey(rsas[i]);
            }

            try {
                foreach (var cipher in Ciphers(true)) {
                    using (var cc = new CipherContext(cipher)) {
                        var env = cc.Seal(pkeys, input);
                        Assert.AreNotEqual(input, env.Data);

                        for (int i = 0; i < numKeys; i++) {
                            var result = cc.Open(env.Data, env.Keys[i], env.IV, pkeys[i]);
                            Assert.AreEqual(input, result);
                        }
                    }
                }
            }
            finally {
                for (int i = 0; i < numKeys; i++) {
                    pkeys[i].Dispose();
                    rsas[i].Dispose();
                }
            }
        }