()
| 25 | |
| 26 | |
| 27 | def test_dir_alg_xc20p(): |
| 28 | pytest.importorskip("Cryptodome.Cipher.ChaCha20_Poly1305") |
| 29 | |
| 30 | jwe = JsonWebEncryption() |
| 31 | key = OctKey.generate_key(256, is_private=True) |
| 32 | protected = {"alg": "dir", "enc": "XC20P"} |
| 33 | data = jwe.serialize_compact(protected, b"hello", key) |
| 34 | rv = jwe.deserialize_compact(data, key) |
| 35 | assert rv["payload"] == b"hello" |
| 36 | |
| 37 | key2 = OctKey.generate_key(128, is_private=True) |
| 38 | with pytest.raises(ValueError): |
| 39 | jwe.deserialize_compact(data, key2) |
| 40 | |
| 41 | with pytest.raises(ValueError): |
| 42 | jwe.serialize_compact(protected, b"hello", key2) |
| 43 | |
| 44 | |
| 45 | def test_xc20p_content_encryption_decryption(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…