(self, subtests, backend)
| 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) |
nothing calls this directly
no test coverage detected