def test_set_key(self): key = m2.aes_new() m2.AES_set_key(key, KEY_TEXT, 128, 1) m2.AES_free(key) key2 = m2.aes_new() m2.AES_set_key(key2, KEY_TEXT, 128, 0) m2.AES_free(key2)
def test_crypt(self): padded = b'zezulicka ' # len(padded) % 16 == 0 key = m2.aes_new() # op == 0: encrypt # otherwise: decrypt (Python code will supply the value 1.) m2.AES_set_key(key, KEY_TEXT, 128, 0) enc = m2.AES_crypt(key, padded, len(padded), 0) m2.AES_free(key) key2 = m2.aes_new() m2.AES_set_key(key2, KEY_TEXT, 128, 1) observed = m2.AES_crypt(key2, enc, len(enc), 1) m2.AES_free(key2) self.assertEqual(padded, observed)
def test_type_check(self): key = m2.aes_new() m2.AES_set_key(key, KEY_TEXT, 128, 1) res = m2.AES_type_check(key) m2.AES_free(key) self.assertEqual(res, 1) # Just to make sure nothing crashed