MCPcopy
hub / github.com/pyca/cryptography / test_aes_cmac

Function test_aes_cmac

tests/wycheproof/test_cmac.py:17–34  ·  view source on GitHub ↗
(backend, wycheproof)

Source from the content-addressed store, hash-verified

15
16@wycheproof_tests("aes_cmac_test.json")
17def test_aes_cmac(backend, wycheproof):
18 key = binascii.unhexlify(wycheproof.testcase["key"])
19 msg = binascii.unhexlify(wycheproof.testcase["msg"])
20 tag = binascii.unhexlify(wycheproof.testcase["tag"])
21
22 # skip truncated tags, which we don't support in the API
23 if wycheproof.valid and len(tag) == 16:
24 ctx = CMAC(AES(key), backend)
25 ctx.update(msg)
26 ctx.verify(tag)
27 elif len(key) not in [16, 24, 32]:
28 with pytest.raises(ValueError):
29 CMAC(AES(key), backend)
30 else:
31 ctx = CMAC(AES(key), backend)
32 ctx.update(msg)
33 with pytest.raises(InvalidSignature):
34 ctx.verify(tag)

Callers

nothing calls this directly

Calls 4

AESClass · 0.90
unhexlifyMethod · 0.80
updateMethod · 0.45
verifyMethod · 0.45

Tested by

no test coverage detected