MCPcopy
hub / github.com/authlib/authlib / test_dir_alg_xc20p

Function test_dir_alg_xc20p

tests/jose/test_chacha20.py:27–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26
27def 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
45def test_xc20p_content_encryption_decryption():

Callers

nothing calls this directly

Calls 4

serialize_compactMethod · 0.95
deserialize_compactMethod · 0.95
JsonWebEncryptionClass · 0.90
generate_keyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…