How to get public key from private key stored in HSMs

Viewed 1663

I have some private keys stored in the HSM but without public keys. I want to get the corresponding public key using PKCS11 interface.

If the private key is a RSA key, I can extract the modulus from CKA_MODULUS and exponent from CKA_PUBLIC_EXPONENT, and then construct the public key with these two numbers.

However, when it comes to ECDSA(or DSA) keys, how can I achieve the same goal?
CKA_EC_POINT attribute is not available for private keys.
I think the only useful information I can get is its curve parameters from CKA_EC_PARAMS, which is not enough to get the public point.

1 Answers

If you're using PKCS#11 library that implements PKCS#11 specification v2.40 then CKA_PUBLIC_KEY_INFO attribute is what you are looking for.

If you're using PKCS#11 library that implements PKCS#11 specification older than 2.40 then you cannot read EC public key value from EC private key object unless your device vendor provides some vendor specific attribute similar to CKA_PUBLIC_KEY_INFO attribute.

Related