aws-samples / aws-cloudhsm-jce-examples

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

AesKey getEncoded() returns null #87

Closed mnylen closed 5 months ago

mnylen commented 5 months ago

Some libraries like the popular jjwt for JSON web tokens try to validate the key length to match the requested encryption algorithm (in my case, A256GCM).

This fails however because AesKey#getEncoded() returns null, which the jjwt library treats as 0 bits.

Would it be better if AesKey#getEncoded() threw UnsupportedOperationException, especially if the key is not extractable?