()
| 1166 | |
| 1167 | |
| 1168 | def test_dir_alg(): |
| 1169 | jwe = JsonWebEncryption() |
| 1170 | key = OctKey.generate_key(128, is_private=True) |
| 1171 | protected = {"alg": "dir", "enc": "A128GCM"} |
| 1172 | data = jwe.serialize_compact(protected, b"hello", key) |
| 1173 | rv = jwe.deserialize_compact(data, key) |
| 1174 | assert rv["payload"] == b"hello" |
| 1175 | |
| 1176 | key2 = OctKey.generate_key(256, is_private=True) |
| 1177 | with pytest.raises(InvalidTag): |
| 1178 | jwe.deserialize_compact(data, key2) |
| 1179 | |
| 1180 | with pytest.raises(ValueError): |
| 1181 | jwe.serialize_compact(protected, b"hello", key2) |
| 1182 | |
| 1183 | |
| 1184 | def test_decryption_of_message_to_multiple_recipients_by_matching_key(): |
nothing calls this directly
no test coverage detected