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

Method test_vectors

tests/hazmat/primitives/test_aead.py:332–365  ·  view source on GitHub ↗
(self, subtests, backend)

Source from the content-addressed store, hash-verified

330 aesccm.decrypt_into(nonce[:6], b"x" * 20, None, buf)
331
332 def test_vectors(self, subtests, backend):
333 vectors = _load_all_params(
334 os.path.join("ciphers", "AES", "CCM"),
335 [
336 "DVPT128.rsp",
337 "DVPT192.rsp",
338 "DVPT256.rsp",
339 "VADT128.rsp",
340 "VADT192.rsp",
341 "VADT256.rsp",
342 "VNT128.rsp",
343 "VNT192.rsp",
344 "VNT256.rsp",
345 "VPT128.rsp",
346 "VPT192.rsp",
347 "VPT256.rsp",
348 ],
349 load_nist_ccm_vectors,
350 )
351 for vector in vectors:
352 with subtests.test():
353 key = binascii.unhexlify(vector["key"])
354 nonce = binascii.unhexlify(vector["nonce"])
355 adata = binascii.unhexlify(vector["adata"])[: vector["alen"]]
356 ct = binascii.unhexlify(vector["ct"])
357 pt = binascii.unhexlify(vector["payload"])[: vector["plen"]]
358 aesccm = AESCCM(key, vector["tlen"])
359 if vector.get("fail"):
360 with pytest.raises(InvalidTag):
361 aesccm.decrypt(nonce, ct, adata)
362 else:
363 computed_pt = aesccm.decrypt(nonce, ct, adata)
364 assert computed_pt == pt
365 assert aesccm.encrypt(nonce, pt, adata) == ct
366
367 def test_roundtrip(self, backend):
368 key = AESCCM.generate_key(128)

Callers

nothing calls this directly

Calls 5

_load_all_paramsFunction · 0.85
testMethod · 0.80
unhexlifyMethod · 0.80
decryptMethod · 0.45
encryptMethod · 0.45

Tested by

no test coverage detected