Esempio n. 1
0
 def test__AES192_Encrypt_OnlineTest__Valid(self):
     """
     Test from https://tools.ietf.org/html/rfc3686#page-2
     """
     aes = AES(bytes.fromhex('7c5cb2401b3dc33c19e7340819e0f69c678c3db8e6f6a91a'),
               [0x00, 0x96, 0xB0 , 0x3B, 0x02, 0x0C, 0x6E, 0xAD, 0xC2, 0xCB, 0x50, 0x0D, 0x00, 0x00, 0x00, 0x01])
     enc_msg = aes.encrypt(bytes.fromhex('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), mode='CTR')
     self.assertEqual(enc_msg, bytes.fromhex('453243fc609b23327edfaafa7131cd9f8490701c5ad4a79cfc1fe0ff42f4fb00'))
Esempio n. 2
0
 def test__AES128_Encrypt_OnlineTest__Valid(self):
     """
     Test from https://tools.ietf.org/html/rfc3686#page-2
     """
     aes = AES(bytes.fromhex('7691be035e5020a8ac6e618529f9a0dc'),
               [0x00, 0xE0, 0x01, 0x7B, 0x27, 0x77, 0x7F, 0x3F, 0x4A, 0x17, 0x86, 0xF0, 0x00, 0x00, 0x00, 0x01])
     enc_msg = aes.encrypt(bytes.fromhex('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), mode='CTR')
     self.assertEqual(enc_msg, bytes.fromhex('c1cf48a89f2ffdd9cf4652e9efdb72d74540a42bde6d7836d59a5ceaaef31053'))
Esempio n. 3
0
 def test__AES256_Encrypt_OnlineTest__Valid(self):
     """
     Test from https://tools.ietf.org/html/rfc3686#page-2
     """
     aes = AES(bytes.fromhex('f6d66d6bd52d59bb0796365879eff886c66dd51a5b6a99744b50590c87a23884'),
               [0x00, 0xFA, 0xAC, 0x24, 0xC1, 0x58, 0x5E, 0xF1, 0x5A, 0x43, 0xD8, 0x75, 0x00, 0x00, 0x00, 0x01])
     enc_msg = aes.encrypt(bytes.fromhex('000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f'), mode='CTR')
     self.assertEqual(enc_msg, bytes.fromhex('f05e231b3894612c49ee000b804eb2a9b8306b508f839d6a5530831d9344af1c'))
Esempio n. 4
0
 def test__AES128_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x2e, 0x5e, 0x3b, 0x51, 0xb3, 0x1e, 0xb1, 0x48, 0x33, 0x15, 0xba, 0xeb, 0x48, 0x36, 0xdc, 0x22])
     enc_msg = aes.encrypt(bytes('abababababababababababababababab', encoding='ascii'), mode='CTR')
     self.assertEqual(enc_msg, bytes.fromhex('3d594de7781a8131333d640c35cae716d74fd95d07b9c3075ed2380e41e504b8'))
Esempio n. 5
0
 def test__AES192_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbc', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('3a3d2cca3e7e7a2eb07826e2498f711c'))
Esempio n. 6
0
 def test__AES192_Encrypt_PeriodicA__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('b60700284ecba59fa24962d00cf9c299'))
Esempio n. 7
0
 def test__AES128_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbc', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('a15c57e515d484873825d0e08e27b8a0'))
Esempio n. 8
0
 def test__AES128_Encrypt_PeriodicA__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('5188c6474b228cbdd242e9125ebe1d53'))
Esempio n. 9
0
 def test__AES256_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbc', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('2499f49e95c204b4ca782ed4c8c592ca'))
Esempio n. 10
0
 def test__AES256_Encrypt_PeriodicA__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('2ccd45896fc3525e03c7cb97b66895ff'))
Esempio n. 11
0
 def test__AES256_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x68, 0xf8, 0x4a, 0x59, 0xa3, 0xca, 0x2d, 0x0e, 0x5c, 0xb1, 0x64, 0x6f, 0xbb, 0x16, 0x4d, 0xa4])
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('e3be46f516d867556907171f3b28be221e3b267b0f575778f148630a5e285e58'))
Esempio n. 12
0
 def test__AES256_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x68, 0xf8, 0x4a, 0x59, 0xa3, 0xca, 0x2d, 0x0e, 0x5c, 0xb1, 0x64, 0x6f, 0xbb, 0x16, 0x4d, 0xa4])
     enc_msg = aes.encrypt(bytes('abababababababababababababababab', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('301d248423445c4569d59c40bfe7c0cddc0a2c97024c082826097bb537e4f6fd'))
Esempio n. 13
0
 def test__AES256_Encrypt_PeriodicA__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x68, 0xf8, 0x4a, 0x59, 0xa3, 0xca, 0x2d, 0x0e, 0x5c, 0xb1, 0x64, 0x6f, 0xbb, 0x16, 0x4d, 0xa4])
     enc_msg = aes.encrypt(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('f3d5d8a0097fa114f798293cd837dd080b2b675d14d1e8cb52c3b57ff128c2f2'))
Esempio n. 14
0
 def test__AES128_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0xa3, 0xa7, 0xe0, 0xad, 0xe7, 0x52, 0x67, 0x66, 0x41, 0x14, 0x83, 0xe9, 0x42, 0x85, 0x82, 0x11])
     enc_msg = aes.encrypt(bytes('abcdefghijklmnopabcdefghijklmnop', encoding='ascii'), mode='CTR')
     self.assertEqual(enc_msg, bytes.fromhex('2a24626a7305e14f61cb195f678cb9b9daf2676d7915786912458b0a198ebd94'))
Esempio n. 15
0
 def test__AES128_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0xeb, 0xa9, 0x3f, 0x32, 0x70, 0xe9, 0xe0, 0x64, 0x34, 0x83, 0x8e, 0x47, 0x5b, 0x22, 0xcc, 0x3e])
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc', encoding='ascii'), mode='CTR')
     self.assertEqual(enc_msg, bytes.fromhex('f085abba1b8ae6b78664a84768707ab9fd5683984f67be9cc6bf7828af28ca6e'))
Esempio n. 16
0
 def test__AES192_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0xb1, 0xc7, 0x6a, 0xec, 0x76, 0x74, 0x86, 0x5d, 0x53, 0x46, 0xb3, 0xb0, 0xd1, 0xcb, 0x2c, 0x22])
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('5c1256fe11bc1fa3e684803eae32ae030b5ba3b574451fc15541d92369d9848c'))
Esempio n. 17
0
 def test__AAES192_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0xb1, 0xc7, 0x6a, 0xec, 0x76, 0x74, 0x86, 0x5d, 0x53, 0x46, 0xb3, 0xb0, 0xd1, 0xcb, 0x2c, 0x22])
     enc_msg = aes.encrypt(bytes('abcdefghijklmnopabcdefghijklmnop', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('3d3d7d6cdd47263cb591cac9ffe5bd96c0e27c4ceb53a581fc2ad24b18499b51'))
Esempio n. 18
0
 def test__AES256_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x68, 0xf8, 0x4a, 0x59, 0xa3, 0xca, 0x2d, 0x0e, 0x5c, 0xb1, 0x64, 0x6f, 0xbb, 0x16, 0x4d, 0xa4])
     enc_msg = aes.encrypt(bytes('abcdefghijklmnopabcdefghijklmnop', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('452f2f1d6357ae9e64df11f895141305778ccab1e7f7a698f350d13b6460f346'))
Esempio n. 19
0
 def test__AES256_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('abababababababab', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('19fa9a9ce608af93221470a62707d29d'))
Esempio n. 20
0
 def test__AES128_Encrypt_PeriodicA__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x34, 0x99, 0xc6, 0x0e, 0xea, 0x22, 0x74, 0x53, 0xc7, 0x79, 0xde, 0x50, 0xfc, 0x84, 0xe2, 0x17])
     enc_msg = aes.encrypt(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('f0130bd72e27c31bb1b53a209863fa4e47530c2112ec5b1b203a71d3a4a126e8'))
Esempio n. 21
0
 def test__AES256_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('abcdefghijklmnop', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('ab168814674b512b604c739a63059e86'))
Esempio n. 22
0
 def test__AES128_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x34, 0x99, 0xc6, 0x0e, 0xea, 0x22, 0x74, 0x53, 0xc7, 0x79, 0xde, 0x50, 0xfc, 0x84, 0xe2, 0x17])
     enc_msg = aes.encrypt(bytes('abababababababababababababababab', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('c27f75c3a7e4266f1375853000ea8a0ee11d6c3da0b1a6eaf88f1c8bae08ffb6'))
Esempio n. 23
0
 def test__AES128_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('abababababababab', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('1806e8c195c426ce33a6f53495c75e7c'))
Esempio n. 24
0
 def test__AES128_Encrypt_PeriodicBC__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x34, 0x99, 0xc6, 0x0e, 0xea, 0x22, 0x74, 0x53, 0xc7, 0x79, 0xde, 0x50, 0xfc, 0x84, 0xe2, 0x17])
     enc_msg = aes.encrypt(bytes('bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('0fbe03e305d80bdd081074f287d103825eb0920b8ca3d56e33cdf1fbaf7944ba'))
Esempio n. 25
0
 def test__AES128_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('abcdefghijklmnop', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('b72be667bfb231e45800e956b97c2fae'))
Esempio n. 26
0
 def test__AES128_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaa', encoding='ascii'),
               [0x34, 0x99, 0xc6, 0x0e, 0xea, 0x22, 0x74, 0x53, 0xc7, 0x79, 0xde, 0x50, 0xfc, 0x84, 0xe2, 0x17])
     enc_msg = aes.encrypt(bytes('abcdefghijklmnopabcdefghijklmnop', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('911a7b25e138adfe7507192d7c96aa4a544b6cab9f4fccff141107430f9de955'))
Esempio n. 27
0
 def test__AES192_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('abababababababab', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('690e0ecc29930889a0d47a944f17b658'))
Esempio n. 28
0
 def test__AES192_Encrypt_PeriodicA__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0xb1, 0xc7, 0x6a, 0xec, 0x76, 0x74, 0x86, 0x5d, 0x53, 0x46, 0xb3, 0xb0, 0xd1, 0xcb, 0x2c, 0x22])
     enc_msg = aes.encrypt(bytes('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('4b30726a54367b5623d172f7656625fb7d7570c68ff6713aa4a67c0c782dcab7'))
Esempio n. 29
0
 def test__AES192_Encrypt_PeriodicEnglishAlphabet__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'))
     enc_msg = aes.encrypt(bytes('abcdefghijklmnop', encoding='ascii'))
     self.assertEqual(enc_msg,
                      bytes.fromhex('cb03edd12fb7ea19c8a4a95d6fb6df8e'))
Esempio n. 30
0
 def test__AES192_Encrypt_PeriodicAB__Valid(self):
     aes = AES(bytes('aaaaaaaaaaaaaaaaaaaaaaaa', encoding='ascii'),
               [0xb1, 0xc7, 0x6a, 0xec, 0x76, 0x74, 0x86, 0x5d, 0x53, 0x46, 0xb3, 0xb0, 0xd1, 0xcb, 0x2c, 0x22])
     enc_msg = aes.encrypt(bytes('abababababababababababababababab', encoding='ascii'), mode='CBC')
     self.assertEqual(enc_msg, bytes.fromhex('5eaeab24c89ba1b6be04a2a08073d4d7665812b4eeadea2a983a3d5505d39416'))