aws-samples / aws-cloudhsm-jce-examples

Sample applications demonstrating how to use the CloudHSM JCE
MIT No Attribution
36 stars 56 forks source link

Add private exponent and token attributes to RSA KeyAttributesMap in ImportKey sample #58

Closed nikran-amzn closed 1 year ago

nikran-amzn commented 1 year ago

Issue #, if available: The RSA Private Key import sample was missing the PRIVATE_EXPONENT attribute in order to successfully import into the HSM.

Description of changes:

Testing

openssl genrsa -out rsa_private_key.pem -f4 2048
openssl rsa -in rsa_private_key.pem -noout -check
openssl pkcs8 -topk8 -in rsa_private_key.pem -inform pem -out rsa_private_key_pkcs8.pem -outform pem -nocrypt
openssl rsa -in rsa_private_key_pkcs8.pem -noout -check
java -ea -Djava.library.path=/opt/cloudhsm/lib/ -cp ".:/opt/cloudhsm/java/*" -jar target/assembly/key-utility-runner.jar --import-rsa-pem rsa_private_key_pkcs8.pem

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.