def test_init_key_schedule_0(self): ntk='2b7e151628aed2a6abf7158809cf4f3c' q = aes.init_key_schedule(aes.key_bv(ntk)) self.assertEqual(len(q),44,"there should be 44 elements in the key schedule") self.assertEqual(aes.bv_hex_str(q[0]),'2b7e1516',"random testing elements\ of key schedule according to FIPS-197 appendix 2") self.assertEqual(aes.bv_hex_str(q[20]),'d4d1c6f8',"random testing elements\ of key schedule according to FIPS-197 appendix 2") self.assertEqual(aes.bv_hex_str(q[43]),'b6630ca6',"random testing elements\ of key schedule according to FIPS-197 appendix 2") self.assertEqual(aes.bv_hex_str(q[33]),'b58dbad2',"random testing elements\ of key schedule according to FIPS-197 appendix 2")
def test_init_key_schedule_0(self): ntk = '2b7e151628aed2a6abf7158809cf4f3c' q = aes.init_key_schedule(aes.key_bv(ntk)) self.assertEqual(len(q), 44, "there should be 44 elements in the key schedule") self.assertEqual( aes.bv_hex_str(q[0]), '2b7e1516', "random testing elements\ of key schedule according to FIPS-197 appendix 2") self.assertEqual( aes.bv_hex_str(q[20]), 'd4d1c6f8', "random testing elements\ of key schedule according to FIPS-197 appendix 2") self.assertEqual( aes.bv_hex_str(q[43]), 'b6630ca6', "random testing elements\ of key schedule according to FIPS-197 appendix 2") self.assertEqual( aes.bv_hex_str(q[33]), 'b58dbad2', "random testing elements\ of key schedule according to FIPS-197 appendix 2")
def test_sbox_lookup_2(self): bv = aes.key_bv("d8") self.assertEqual(aes.bv_hex_str(aes.sbox_lookup(bv)),'61',\ "testing 'd8' on sbox_lookup")
def test_inv_sbox_lookup_0(self): bv = aes.key_bv("61") self.assertEqual(aes.bv_hex_str(aes.inv_sbox_lookup(bv)),'d8',\ "testing '61' on inv_sbox_lookup")
def test_gv_mult_2(self): bv_2 = aes.key_bv("e0") self.assertEqual(aes.bv_hex_str(aes.gf_mult(bv_2,3)),'3b',\ "testing gf_mult with e0 * 3 = 3b")
def test_shift_bytes_right_2(self): bv = aes.key_bv("1234abcd") self.assertEqual(aes.bv_hex_str(aes.shift_bytes_right(bv, 1)), 'cd1234ab')
def test_inv_sbox_lookup_3(self): bv = aes.key_bv("33") self.assertEqual(aes.bv_hex_str(aes.inv_sbox_lookup(bv)),'66',\ "testing '33' on inv_sbox_lookup")
def test_inv_sbox_lookup_1(self): bv = aes.key_bv("d0") self.assertEqual(aes.bv_hex_str(aes.inv_sbox_lookup(bv)),'60',\ "testing 'd0' on inv_sbox_lookup")
def test_gv_mult_1(self): bv_1 = aes.key_bv("63") self.assertEqual(aes.bv_hex_str(aes.gf_mult(bv_1,2)),'c6',\ "testing gf_mult with 63 * 2 = c6")
def test_shift_bytes_right_2(self): bv = aes.key_bv("1234abcd") self.assertEqual(aes.bv_hex_str(aes.shift_bytes_right(bv,1)),'cd1234ab')
def test_shift_bytes_left_1(self): bv = aes.key_bv("1234abcd") self.assertEqual(aes.bv_hex_str(aes.shift_bytes_left(bv,2)),'abcd1234')
def test_inv_sbox_lookup_2(self): bv = aes.key_bv("62") self.assertEqual(aes.bv_hex_str(aes.inv_sbox_lookup(bv)),'ab',\ "testing '62' on inv_sbox_lookup")
def test_sbox_lookup_3(self): bv = aes.key_bv("66") self.assertEqual(aes.bv_hex_str(aes.sbox_lookup(bv)),'33',\ "testing '66' on sbox_lookup")
def test_gv_mult_3(self): bv_1 = aes.key_bv("01") self.assertEqual(aes.bv_hex_str(aes.gf_mult(bv_1,1)),'01',\ "testing gf_mult with 63 * 2 = c6")
def test_sbox_lookup_0(self): bv = aes.key_bv("ab") self.assertEqual(aes.bv_hex_str(aes.sbox_lookup(bv)),'62',\ "testing 'ab' on sbox_lookup")
def test_shift_bytes_left_1(self): bv = aes.key_bv("1234abcd") self.assertEqual(aes.bv_hex_str(aes.shift_bytes_left(bv, 2)), 'abcd1234')
def test_sbox_lookup_1(self): bv = aes.key_bv("60") self.assertEqual(aes.bv_hex_str(aes.sbox_lookup(bv)),'d0',\ "testing '60' on sbox_lookup")