def test_cmac_subkeys(): k = binascii.unhexlify("8195088CE6C393708EBBE6C7914ECB0B") kx = binascii.unhexlify("2D22571A33B2965A9B49FF4395A43046") k0 = LRP.eval_lrp(LRP.generate_plaintexts(k), LRP.generate_updated_keys(k)[0], b"\x00" * 16, True) assert (_Element(k0) * _Element(4)).encode().hex() == kx.hex()
def execute_test(KEY, IV, FINALIZE, UPDATEDKEY, RES): KEY = binascii.unhexlify(KEY) RES = binascii.unhexlify(RES) FINALIZE = FINALIZE == 1 assert LRP.eval_lrp(LRP.generate_plaintexts(KEY), LRP.generate_updated_keys(KEY)[UPDATEDKEY], IV, FINALIZE)\ .hex().upper() == RES.hex().upper()
def test_eval_lrp(): p = LRP.generate_plaintexts( binascii.unhexlify("567826B8DA8E768432A9548DBE4AA3A0")) uk = LRP.generate_updated_keys( binascii.unhexlify("567826B8DA8E768432A9548DBE4AA3A0")) assert LRP.eval_lrp(p, uk[2], b"\x13\x59", final=True).hex() \ == "1ba2c0c578996bc497dd181c6885a9dd" p = LRP.generate_plaintexts( binascii.unhexlify("88B95581002057A93E421EFE4076338B")) uk = LRP.generate_updated_keys( binascii.unhexlify("88B95581002057A93E421EFE4076338B")) assert LRP.eval_lrp(p, uk[2], b"\x77\x29\x9D", final=True).hex() \ == "E9C04556A214AC3297B83E4BDF46F142".lower() p = LRP.generate_plaintexts( binascii.unhexlify("9AFF3EF56FFEC3153B1CADB48B445409")) uk = LRP.generate_updated_keys( binascii.unhexlify("9AFF3EF56FFEC3153B1CADB48B445409")) assert LRP.eval_lrp(p, uk[3], b"\x4B\x07\x3B\x24\x7C\xD4\x8F\x7E\x0A", final=False).hex() \ == "909415E5C8BE77563050F2227E17C0E4".lower()