public override void PerformTest() { IsaacEngine engine = new IsaacEngine(); doTest(engine, Hex.Decode("00000000"), outBase); doTest(engine, Hex.Decode("ffffffff"), outFFFFFFFF); byte[] k = new byte[256 * 4]; for (int i = 0; i != k.Length; i++) { k[i] = (byte)((i % 4 == 0 || i % 4 == 1) ? 0xff : 0x00); } doTest(engine, k, outFFFF0000); k = new byte[256 * 4]; for (int i = 0; i != k.Length; i++) { k[i] = (byte)((i % 4 == 2 || i % 4 == 3) ? 0xff : 0x00); } doTest(engine, k, out0000FFFF); }
private void doTest( IsaacEngine engine, byte[] key, byte[] output) { byte[] input = new byte[output.Length]; byte[] enc = new byte[output.Length]; engine.Init(true, new KeyParameter(key)); engine.ProcessBytes(input, 0, input.Length, enc, 0); if (!AreEqual(enc, output)) { Fail("ciphertext mismatch"); } engine.Init(false, new KeyParameter(key)); engine.ProcessBytes(enc, 0, enc.Length, enc, 0); if (!AreEqual(enc, input)) { Fail("plaintext mismatch"); } }
private BufferedStreamCipher CreateSstreamEngine() { IStreamCipher engine; switch (_MSec.Algorithm) { case ESec.SSTREAM_HC128: engine = new HC128Engine(); _MSec.KeySize = 16;//128 _MSec.IVSize = 16; break; case ESec.SSTREAM_HC256: engine = new HC256Engine(); _MSec.KeySize = 32; _MSec.IVSize = 16; break; case ESec.SSTREAM_ISAAC: engine = new IsaacEngine(); _MSec.KeySize = 10; _MSec.IVSize = 0; break; case ESec.SSTREAM_RC4: engine = new RC4Engine(); _MSec.KeySize = 10; _MSec.IVSize = 0; break; case ESec.SSTREAM_SALSA20: engine = new Salsa20Engine(); _MSec.KeySize = 16; _MSec.IVSize = 8; break; case ESec.SSTREAM_VMPC: engine = new VmpcEngine(); _MSec.KeySize = 10; _MSec.IVSize = 16; break; case ESec.SSTREAM_VMPCKSA3: engine = new VmpcKsa3Engine(); _MSec.KeySize = 10; _MSec.IVSize = 16; break; default: engine = null; _MSec.KeySize = 0; _MSec.IVSize = 0; break; } return new BufferedStreamCipher(engine); }