Add PKCS#11 provider support for ECDH and XDH key exchange#660
Add PKCS#11 provider support for ECDH and XDH key exchange#660olszomal wants to merge 3 commits into
Conversation
Add OSSL_OP_KEYEXCH support for EC, X25519, and X448 keys in the PKCS#11 provider path. This includes ECDH derive support, cofactor mode handling, peer public key handling, X25519/X448 key generation, and XDH derive plumbing through PKCS#11.
[Medium] Provider ECDH derive fails when the peer key is also loaded from
|
Pull Request Type
Related Issue
Issue number: N/A
Current Behavior
The PKCS#11 provider does not implement
OSSL_OP_KEYEXCH.New Behavior
This change adds PKCS#11 provider support for key exchange operations.
The provider now implements
OSSL_OP_KEYEXCHand routes EC, X25519, and X448 derive operations through PKCS#11. For EC keys, ECDH shared-secret derivation is performed withCKM_ECDH1_DERIVEorCKM_ECDH1_COFACTOR_DERIVE, including cofactor mode handling and peer public key import.The change also adds X25519 and X448 key generation support using
CKM_EC_MONTGOMERY_KEY_PAIR_GEN, detects XDH key types fromCKA_EC_PARAMS, handles raw public key export/import for X25519 and X448, and wires XDH derive plumbing through the provider path.Scope of Changes
OSSL_OP_KEYEXCHdispatch and provider registration.PKCS11_evp_pkey_derive()as the common front-end derive helper.EC_MONTGOMERY.EVP_PKEY_METHODderive hooks for X25519/X448 on OpenSSL versions before 4.0.Testing
New SoftHSM tests generate an EC key pair with derive usage on the token and verify that:
ECDH(token_private, software_public) == ECDH(software_private, token_public)
Additional Notes
X25519/X448 derive support is wired through the provider path, but the actual hardware derive path remains untested for now because no available token/module advertises
EC_MONTGOMERYderive support.License Declaration