public Open ( byte input, byte ekey, byte iv, OpenSSL.Crypto.CryptoKey pkey ) : byte[] | ||
input | byte | |
ekey | byte | |
iv | byte | |
pkey | OpenSSL.Crypto.CryptoKey | |
return | byte[] |
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); } } }
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(); } } }