aws-samples / aws-cloudhsm-jce-examples

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

Error while loading key by handle #35

Closed acartapanis closed 4 years ago

acartapanis commented 4 years ago

After updating to 3.1.0, we have an error while loading a key by key handle.

The exception is :

java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Byte;
  at com.cavium.key.CaviumKeyAttributes.getModulus(CaviumKeyAttributes.java:138)
  at com.cavium.key.CaviumRSAPrivateKey.<init>(CaviumRSAPrivateKey.java:48)
  at xxxx.xxxxx.xxxxx.CaviumUtils.getKeyByHandle(CaviumUtils.java:241)

The CaviumUtils.getKeyByHandle is an exact copy of https://github.com/aws-samples/aws-cloudhsm-jce-examples/blob/master/src/main/java/com/amazonaws/cloudhsm/examples/KeyUtilitiesRunner.java#L230

After some investigation, we find something strange in the CaviumKeyAttributes.getModulus method (CaviumKeyAttributes.java:106), specially when we compare it with the CloudHsmKeyAttributesMap.calculateModulus method (CloudHsmKeyAttributesMap.java:118).

acartapanis commented 4 years ago

Hi, may I know why the previous comment was deleted ?

The solution proposed in the comment is working, but because of deletion of the previous comment, we rollbacked to cloudhsm-3.0.1-1 rather than using the proposed solution.

Are we supposed to open a case on aws support for this issue ?

sveerg commented 4 years ago

Facing the same issue after the upgrade, what was the work around that worked for you?

gmudambi commented 4 years ago

Thank you for surfacing this issue. We are able to reproduce this issue and are working on a resolution.

gmudambi commented 4 years ago

This issue has been addressed with software version 3.1.1.

You can find the links to package and release notes here: https://docs.aws.amazon.com/cloudhsm/latest/userguide/client-history.html#client-version-3-1-1

Marking this issues as resolved.