static void PerformTest(encFn Encrypt, string name, int blockCounts, int keySize, int iterCount) { int dataSize = blockCounts * 8; byte[] input; byte[] key; input = getRandomArray(dataSize); key = getRandomArray(keySize); double totalBytes = dataSize * iterCount; sWatch.Reset(); sWatch.Start(); for (int i = 0; i < iterCount; i++) { input = Encrypt(input, key); } sWatch.Stop(); double throughPut = totalBytes / sWatch.Elapsed.TotalSeconds; throughPut /= 1024; Console.WriteLine(name + " Throughput: " + throughPut.ToString("f2") + " kb/s"); }
static void TestVectors128(encFn Encrypt, string name) { byte[] plaintext = new byte[] { 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }; byte[] key = new byte[] { 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }; byte[] ciphertext; ciphertext = Encrypt(plaintext, key); ciphertext = byte2nibble(ciphertext, 0); Console.Write(name + " TestVector: "); printArray(ciphertext, ciphertext.Length); }
static void TestVectors64Decryption(encFn Decrypt, string name) { byte[] plaintext = new byte[] { 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }; byte[] key = new byte[] { 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }; byte[] ciphertext; ciphertext = LED_64_4.Encrypt(plaintext, key); byte[] _PT = Decrypt(ciphertext, key); plaintext = byte2nibble(plaintext, 0); ciphertext = byte2nibble(ciphertext, 0); _PT = byte2nibble(_PT, 0); Console.WriteLine(name + " TestVector: "); printArray(plaintext, plaintext.Length); printArray(ciphertext, ciphertext.Length); printArray(_PT, _PT.Length); }