public void DecryptIntermediate256BitKeys() { //rfc byte[] P = new byte[16] { 0xf9, 0x2b, 0xd7, 0xc7, 0x9f, 0xb7, 0x2e, 0x2f, 0x2b, 0x8f, 0x80, 0xc1, 0x97, 0x2d, 0x24, 0xfc }; byte[] K = new byte[32] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; byte[] result = ARIA.DecryptBlock(P, K); Assert.IsTrue(compareArrays(result, new byte[16] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, out int FirstDiff), "RFC Decrypt 256 Test Failed"); //pdf K = ts.Bank256.Key; foreach (Test t in ts.Bank256.Data) { result = ARIA.DecryptBlock(t.C, K); Assert.IsTrue(compareArrays(result, t.P, out FirstDiff), "PDF Decrypt 256 Test Source Failed: " + t.C[0].ToString("x2")); } }
public void EncryptIntermediate192BitKeys() { //rfc byte[] P = new byte[16] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; byte[] K = new byte[24] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; byte[] result = ARIA.EncryptBlock(P, K); Assert.IsTrue(compareArrays(result, new byte[16] { 0x26, 0x44, 0x9c, 0x18, 0x05, 0xdb, 0xe7, 0xaa, 0x25, 0xa4, 0x68, 0xce, 0x26, 0x3a, 0x9e, 0x79 }, out int FirstDiff), "RFC Encrypt 192 Test Failed"); //pdf K = ts.Bank192.Key; foreach (Test t in ts.Bank192.Data) { result = ARIA.EncryptBlock(t.P, K); Assert.IsTrue(compareArrays(result, t.C, out FirstDiff), "PDF Encrypt 192 Test Source Failed: " + t.C[0].ToString("x2")); } }
static void Main(string[] args) { if (ARIA.RunSelfTests()) { Console.WriteLine("SelfTest OK!"); } else { Console.WriteLine("*** SelfTest FAILED!!! ***"); } #if DEBUG //Excercise Debug routines // Common plaintext byte[] P = new byte[16] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; Debug.Print("PT:" + BitConverter.ToString(P).Replace("-", "").ToLower()); //128-bit key Debug.Print("==128-BIT KEY============================================="); byte[] K = new byte[16] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; byte[] result = ARIA.EncryptBlock(P, K); Debug.Print("CT:" + BitConverter.ToString(result).Replace("-", "").ToLower()); result = ARIA.DecryptBlock(result, K); Debug.Print("PT:" + BitConverter.ToString(result).Replace("-", "").ToLower()); //192-bit key Debug.Print("==192-BIT KEY============================================="); K = new byte[24] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 }; result = ARIA.EncryptBlock(P, K); Debug.Print("CT:" + BitConverter.ToString(result).Replace("-", "").ToLower()); result = ARIA.DecryptBlock(result, K); Debug.Print("PT:" + BitConverter.ToString(result).Replace("-", "").ToLower()); //256-bit key Debug.Print("==256-BIT KEY============================================="); K = new byte[32] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; result = ARIA.EncryptBlock(P, K); Debug.Print("CT:" + BitConverter.ToString(result).Replace("-", "").ToLower()); result = ARIA.DecryptBlock(result, K); Debug.Print("PT:" + BitConverter.ToString(result).Replace("-", "").ToLower()); #endif Console.WriteLine("Press ENTER to quit..."); Console.ReadLine(); }
public void DecryptIntermediate128BitKeys() { //rfc byte[] P = new byte[16] { 0xd7, 0x18, 0xfb, 0xd6, 0xab, 0x64, 0x4c, 0x73, 0x9d, 0xa9, 0x5f, 0x3b, 0xe6, 0x45, 0x17, 0x78 }; byte[] K = new byte[16] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; byte[] result = ARIA.DecryptBlock(P, K); Assert.IsTrue(compareArrays(result, new byte[16] { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, out int FirstDiff), "RFC Decrypt 128 Test Failed"); //pdf K = ts.Bank128.Key; foreach (Test t in ts.Bank128.Data) { result = ARIA.DecryptBlock(t.C, K); Assert.IsTrue(compareArrays(result, t.P, out FirstDiff), "PDF Decrypt 128 Test Source Failed: " + t.C[0].ToString("x2")); } }
public void Decrypt_Exception_InvalidKeyLength() { ARIA.DecryptBlock(new byte[16], new byte[1]); Assert.Fail("Did not throw exception"); }
public void Decrypt_Exception_NullKey() { ARIA.DecryptBlock(new byte[16], null); Assert.Fail("Did not throw exception"); }
public void Decrypt_Exception_NullData() { ARIA.DecryptBlock(null, new byte[16]); Assert.Fail("Did not throw exception"); }
public void Encrypt_Exception_InvalidDataLength() { ARIA.EncryptBlock(new byte[3], new byte[16]); Assert.Fail("Did not throw exception"); }