def test_ecdh_direct_hkdf_apply_and_extract_with_ecdh_es( self, sender_key_es, recipient_public_key, recipient_private_key): sender = ECDH_DirectHKDF({1: -25}, {4: b"01"}, sender_key=sender_key_es) enc_key = sender.apply(recipient_key=recipient_public_key, context={"alg": "A128GCM"}) encoded = sender.to_list() recipient = Recipient.from_list(encoded) decoded_key = recipient.extract(recipient_private_key, context={"alg": "A128GCM"}) assert enc_key.key == decoded_key.key
def test_ecdh_aes_key_wrap_encode_and_extract_with_ecdh_es( self, sender_key_es, recipient_public_key, recipient_private_key): enc_key = COSEKey.from_symmetric_key(alg="ChaCha20/Poly1305") sender = ECDH_AESKeyWrap({1: -29}, {4: b"01"}, sender_key=sender_key_es) sender.apply(enc_key, recipient_key=recipient_public_key, context={"alg": "A128GCM"}) assert sender.ciphertext is not None encoded = sender.to_list() recipient = Recipient.from_list(encoded) decoded_key = recipient.extract(recipient_private_key, alg="ChaCha20/Poly1305", context={"alg": "A128GCM"}) assert enc_key.key == decoded_key.key