Esempio n. 1
0
    def test_add_round_key_0(self):
        rk=[aes.key_bv('00010203'),aes.key_bv('04050607'),aes.key_bv('08090a0b'),\
            aes.key_bv('0c0d0e0f')]

        sa=aes.init_state_array(aes.key_bv('00112233445566778899aabbccddeeff'))
        self.assertEqual(aes.state_str(aes.add_round_key(sa,rk)),\
                         '00102030405060708090a0b0c0d0e0f0',\
            "Test add round key from FIPS-197 C.1 round[0]")
Esempio n. 2
0
    def test_add_round_key_3(self):
        rk=[aes.key_bv('47f7f7bc'),aes.key_bv('95353e03'),aes.key_bv('f96c32bc'),\
            aes.key_bv('fd058dfd')]
        

        sa=aes.init_state_array(aes.key_bv('6385b79ffc538df997be478e7547d691'))
        self.assertEqual(aes.state_str(aes.add_round_key(sa,rk)),\
                         '247240236966b3fa6ed2753288425b6c',\
            "Test add round key from FIPS-197 C.1 round[3]")     
Esempio n. 3
0
    def test_add_round_key_1(self):
        rk=[aes.key_bv('d6aa74fd'),aes.key_bv('d2af72fa'),aes.key_bv('daa678f1'),\
            aes.key_bv('d6ab76fe')]
        

        sa=aes.init_state_array(aes.key_bv('5f72641557f5bc92f7be3b291db9f91a'))
        self.assertEqual(aes.state_str(aes.add_round_key(sa,rk)),\
                         '89d810e8855ace682d1843d8cb128fe4',\
            "Test add round key from FIPS-197 C.1 round[1]")
Esempio n. 4
0
    def test_add_round_key_2(self):
        rk=[aes.key_bv('b692cf0b'),aes.key_bv('643dbdf1'),aes.key_bv('be9bc500'),\
            aes.key_bv('6830b3fe')]
    

        sa=aes.init_state_array(aes.key_bv('ff87968431d86a51645151fa773ad009'))
        self.assertEqual(aes.state_str(aes.add_round_key(sa,rk)),\
                         '4915598f55e5d7a0daca94fa1f0a63f7',\
            "Test add round key from FIPS-197 C.1 round[2]")     
Esempio n. 5
0
 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")
Esempio n. 6
0
 def test_inv_sub_bytes_3(self):
     sa = aes.init_state_array(
         aes.key_bv('2dfb02343f6d12dd09337ec75b36e3f0'))
     self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                      'fa636a2825b339c940668a3157244d17',\
                      "testing inv_sub_bytes from FIPS-197 C.1 round[1]")
Esempio n. 7
0
 def test_sub_key_bytes_1(self):
     kw = aes.key_bv('6c76052a')
     sub = aes.key_bv('50386be5')
     self.assertEqual(
         aes.sub_key_bytes(kw), sub, "test sub_key_bytes using \
     keyword 6c76052a from FIPS-197 appendix 2")
Esempio n. 8
0
 def test_inv_sub_bytes_1(self):
     sa = aes.init_state_array(
         aes.key_bv('a761ca9b97be8b45d8ad1a611fc97369'))
     self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                      '89d810e8855ace682d1843d8cb128fe4',\
                      "testing inv_sub_bytes from FIPS-197 C.1 round[3]")
Esempio n. 9
0
 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")
Esempio n. 10
0
 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")
Esempio n. 11
0
 def test_inv_sub_bytes_0(self):
     sa=aes.init_state_array(aes.key_bv('63cab7040953d051cd60e0e7ba70e18c'))
     self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                      '00102030405060708090a0b0c0d0e0f0',\
                      "testing inv_sub_bytes from FIPS-197 C.1 round[2]")
Esempio n. 12
0
 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')
Esempio n. 13
0
 def test_inv_sub_bytes_2(self):
         sa=aes.init_state_array(aes.key_bv('3b59cb73fcd90ee05774222dc067fb68'))
         self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                          '4915598f55e5d7a0daca94fa1f0a63f7',\
                          "testing inv_sub_bytes from FIPS-197 C.1 round[4]")
Esempio n. 14
0
 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")
Esempio n. 15
0
 def test_inv_shift_rows_1(self):
     sa=aes.init_state_array(aes.key_bv('a7be1a6997ad739bd8c9ca451f618b61'))
     self.assertEqual(aes.state_str(aes.inv_shift_rows(sa)),\
                      'a761ca9b97be8b45d8ad1a611fc97369',\
         "Test shift rows from FIPS-197 C.1 round[2]")
Esempio n. 16
0
 def test_inv_shift_rows_2(self):
     sa=aes.init_state_array(aes.key_bv('3bd92268fc74fb735767cbe0c0590e2d'))
     self.assertEqual(aes.state_str(aes.inv_shift_rows(sa)),\
                      '3b59cb73fcd90ee05774222dc067fb68',\
         "Test shift rows from FIPS-197 C.1 round[3]")
Esempio n. 17
0
 def test_inv_shift_rows_0(self):
     sa=aes.init_state_array(aes.key_bv('6353e08c0960e104cd70b751bacad0e7'))
     self.assertEqual(aes.state_str(aes.inv_shift_rows(sa)),\
                      '63cab7040953d051cd60e0e7ba70e18c',\
         "Test shift rows from FIPS-197 C.1 round[1]")
Esempio n. 18
0
 def test_sub_key_bytes_2(self):
     kw = aes.key_bv('59f67f73')
     sub = aes.key_bv('cb42d28f')
     self.assertEqual(aes.sub_key_bytes(kw),sub,"test sub_key_bytes using \
     keyword 59f67f73 from FIPS-197 appendix 2")
Esempio n. 19
0
 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')       
Esempio n. 20
0
 def test_sub_key_bytes_1(self):
     kw = aes.key_bv('6c76052a')
     sub = aes.key_bv('50386be5')
     self.assertEqual(aes.sub_key_bytes(kw),sub,"test sub_key_bytes using \
     keyword 6c76052a from FIPS-197 appendix 2")
Esempio n. 21
0
 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")
Esempio n. 22
0
 def test_inv_sub_bytes_1(self):
         sa=aes.init_state_array(aes.key_bv('a761ca9b97be8b45d8ad1a611fc97369'))
         self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                          '89d810e8855ace682d1843d8cb128fe4',\
                          "testing inv_sub_bytes from FIPS-197 C.1 round[3]")
Esempio n. 23
0
 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")
Esempio n. 24
0
 def test_inv_shift_rows_3(self):
     sa=aes.init_state_array(aes.key_bv('2d6d7ef03f33e334093602dd5bfb12c7'))
     self.assertEqual(aes.state_str(aes.inv_shift_rows(sa)),\
                      '2dfb02343f6d12dd09337ec75b36e3f0',\
         "Test shift rows from FIPS-197 C.1 round[4]")
Esempio n. 25
0
 def test_inv_sub_bytes_3(self):
         sa=aes.init_state_array(aes.key_bv('2dfb02343f6d12dd09337ec75b36e3f0'))
         self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                          'fa636a2825b339c940668a3157244d17',\
                          "testing inv_sub_bytes from FIPS-197 C.1 round[1]")
Esempio n. 26
0
 def test_sub_key_bytes_0(self):
     kw = aes.key_bv('cf4f3c09')
     sub = aes.key_bv('8a84eb01')
     self.assertEqual(aes.sub_key_bytes(kw),sub,"test sub_key_bytes using \
     keyword cf4f3c09 from FIPS-197 appendix 2")
Esempio n. 27
0
 def test_sub_key_bytes_3(self):
     kw = aes.key_bv('7a883b6d')
     sub = aes.key_bv('dac4e23c')
     self.assertEqual(aes.sub_key_bytes(kw),sub,"test sub_key_bytes using \
     keyword 7a883b6d from FIPS-197 appendix 2")
Esempio n. 28
0
 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")
Esempio n. 29
0
 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")
Esempio n. 30
0
 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")
Esempio n. 31
0
 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")
Esempio n. 32
0
 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")
Esempio n. 33
0
 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")
Esempio n. 34
0
 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")
Esempio n. 35
0
 def test_inv_mix_columns_0(self):
     sa=aes.init_state_array(aes.key_bv('5f72641557f5bc92f7be3b291db9f91a'))
     self.assertEqual(aes.state_str(aes.inv_mix_columns(sa)),\
                      '6353e08c0960e104cd70b751bacad0e7',\
         "Test inv mix columns from FIPS-197 C.1 round[1]")
Esempio n. 36
0
 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")
Esempio n. 37
0
 def test_inv_mix_columns_1(self):
     sa=aes.init_state_array(aes.key_bv('ff87968431d86a51645151fa773ad009'))
     self.assertEqual(aes.state_str(aes.inv_mix_columns(sa)),\
                      'a7be1a6997ad739bd8c9ca451f618b61',\
         "Test inv mix columns from FIPS-197 C.1 round[2]")
Esempio n. 38
0
 def test_inv_sub_bytes_0(self):
     sa = aes.init_state_array(
         aes.key_bv('63cab7040953d051cd60e0e7ba70e18c'))
     self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                      '00102030405060708090a0b0c0d0e0f0',\
                      "testing inv_sub_bytes from FIPS-197 C.1 round[2]")
Esempio n. 39
0
 def test_inv_mix_columns_2(self):
     sa=aes.init_state_array(aes.key_bv('4c9c1e66f771f0762c3f868e534df256'))
     self.assertEqual(aes.state_str(aes.inv_mix_columns(sa)),\
                      '3bd92268fc74fb735767cbe0c0590e2d',\
         "Test inv mix columns from FIPS-197 C.1 round[3]")
Esempio n. 40
0
 def test_inv_sub_bytes_2(self):
     sa = aes.init_state_array(
         aes.key_bv('3b59cb73fcd90ee05774222dc067fb68'))
     self.assertEqual(aes.state_str(aes.inv_sub_bytes(sa)),\
                      '4915598f55e5d7a0daca94fa1f0a63f7',\
                      "testing inv_sub_bytes from FIPS-197 C.1 round[4]")
Esempio n. 41
0
 def test_inv_mix_columns_3(self):
     sa=aes.init_state_array(aes.key_bv('6385b79ffc538df997be478e7547d691'))
     self.assertEqual(aes.state_str(aes.inv_mix_columns(sa)),\
                      '2d6d7ef03f33e334093602dd5bfb12c7',\
         "Test inv mix columns from FIPS-197 C.1 round[4]")
Esempio n. 42
0
 def test_shift_bytes_left_0(self):
     bv = aes.key_bv("1234abcd")
     self.assertEqual(aes.bv_hex_str(aes.shift_bytes_left(bv, 3)),
                      'cd1234ab')
Esempio n. 43
0
 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")