In PKCS#11 documentation § 2.1.23 is described how to wrap and unwrap a target asymmetric key of any length and type using an RSA key, called CKM_RSA_AES_KEY_WRAP
. This mechanism could be easily implemented by hand in case it is not available in HSM.
The counterpart exists for EC, CKM_EC_AES_KEY_WRAP
can wrap and unwrap an asymmetric target key of any length and type using an EC key. Unfortunately, the description of the wrapping mechanism only refers to EC wrapping key:
- Generates a temporary random EC key (transport key) having the same parameters as the wrapping EC key (and domain parameters). Saves the transport key public key material.
- Performs ECDH operation using CKM_ECDH1_DERIVE with parameters of kdf, ulSharedDataLen and pSharedData using the private key of the transport EC key and the public key of wrapping EC key and gets the first ulAESKeyBits bits of the derived key to be the temporary AES key.
Could someone explain to me and describe precisely how to wrap an RSA asymmetric target key using an EC key?
Obviously, if this is not recommended or not possible, I would also like to have an explanation of why.