Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the PKCS11Exception: CKR_KEY_TYPE_INCONSISTENT in FIPS mode #622

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

WilburZjh
Copy link
Contributor

@WilburZjh WilburZjh commented Oct 7, 2022

Refer to Redhat-2007331. Add a CKA_SIGN attribute to a key that is generated by the MAC service initialization in the FIPS mode.

Signed-off-by: Jinhang Zhang Jinhang.Zhang@ibm.com

@WilburZjh
Copy link
Contributor Author

This PR aims to solve the following exception:

com.ibm.cloud.objectstorage.SdkClientException: Unable to calculate a request signature: Unable to calculate a request signature: init() failed
	at com.ibm.cloud.objectstorage.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:109)
	at com.ibm.cloud.objectstorage.auth.AWS4Signer.newSigningKey(AWS4Signer.java:643)
	at com.ibm.cloud.objectstorage.auth.AWS4Signer.deriveSigningKey(AWS4Signer.java:408)
	at com.ibm.cloud.objectstorage.auth.AWS4Signer.presignRequest(AWS4Signer.java:313)
	at com.ibm.cloud.objectstorage.services.s3.AmazonS3Client.generatePresignedUrl(AmazonS3Client.java:3553)
	at com.ibm.catalog.unified.storage.BluemixS3Connection.generatePreSignedURL(BluemixS3Connection.java:959)
	at com.ibm.catalog.unified.storage.BluemixS3Connection.generatePreSignedURL(BluemixS3Connection.java:109)
	at com.ibm.catalog.v2.controllers.AttachmentController.addURLsToResponse(AttachmentController.java:502)
	at com.ibm.catalog.v2.controllers.AttachmentController.processGetRemoteAttachment(AttachmentController.java:1289)
	at com.ibm.catalog.unified.controllers.AttachmentControllerBase.retrieveAttachment(AttachmentControllerBase.java:698)
	at com.ibm.catalog.v2.services.AttachmentServiceNew.retrieveAttachmentNewV2(AttachmentServiceNew.java:248)
	... ...
Caused by: com.ibm.cloud.objectstorage.SdkClientException: Unable to calculate a request signature: init() failed
	at com.ibm.cloud.objectstorage.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:132)
	at com.ibm.cloud.objectstorage.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:105)
	... 57 more
Caused by: java.security.InvalidKeyException: init() failed
	at sun.security.pkcs11.P11Mac.engineInit(Unknown Source)
	at java.base/javax.crypto.Mac.chooseProvider(Unknown Source)
	at java.base/javax.crypto.Mac.init(Unknown Source)
	at com.ibm.cloud.objectstorage.auth.AbstractAWSSigner.sign(AbstractAWSSigner.java:127)
	... 58 more
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_KEY_TYPE_INCONSISTENT
	at jdk.crypto.cryptoki/sun.security.pkcs11.P11Mac.initialize(Unknown Source)
	... 62 more

@WilburZjh
Copy link
Contributor Author

it is essentially a duplicate of a bug at Redhat-2007331

@WilburZjh
Copy link
Contributor Author

@alon-sh please help to review

Refer to [Redhat-2007331](https://bugzilla.redhat.com/show_bug.cgi?id=2007331). Add a CKA_SIGN attribute to a key that is generated by the MAC service initialization in the FIPS mode.

Signed-off-by: Jinhang Zhang <Jinhang.Zhang@ibm.com>
@WilburZjh WilburZjh changed the title Fix init() function Fix the PKCS11Exception: CKR_KEY_TYPE_INCONSISTENT in FIPS mode Oct 11, 2022
@WilburZjh
Copy link
Contributor Author

This sun.security.pkcs11.wrapper.PKCS11Exception: CKR_KEY_TYPE_INCONSISTENT exception shows in the following tests.

Grinder

<<javax/crypto/Mac/ByteBuffers.java.ByteBuffers>>
<<sun/security/pkcs11/Mac/MacKAT.java.MacKAT>>
<<sun/security/pkcs11/Mac/MacSameTest.java.MacSameTest>>
<<sun/security/pkcs11/Mac/ReinitMac.java>>
<<sun/security/pkcs11/tls/TestPRF.java.TestPRF>>

@pshipton
Copy link
Member

Approving based on the reviews in ibmruntimes/openj9-openjdk-jdk11#581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants