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

Update corePKCS11 demo to read the public key #1670

Merged
merged 2 commits into from
Jul 19, 2021
Merged

Conversation

yourslab
Copy link
Contributor

Update the demo so that it doesn't treat the public key as a private key

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@yourslab yourslab requested a review from a team as a code owner July 16, 2021 21:47
paulbartell
paulbartell previously approved these changes Jul 16, 2021
@@ -155,7 +155,7 @@ CK_RV PKCS11SignVerifyDemo( void )
{
result = xFindObjectWithLabelAndClass( session,
pkcs11demoPRIVATE_KEY_LABEL,
sizeof( pkcs11demoPRIVATE_KEY_LABEL ),
sizeof( pkcs11demoPRIVATE_KEY_LABEL ) - 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change to discount the NUL character?
The comment in the pkcs11_demo_objects.c file mentions that the labels should not be NUL terminated...

/* Labels are application defined strings that are used to identify an
* object. It should not be NULL terminated. */
CK_BYTE publicKeyLabel[] = { pkcs11demoPUBLIC_KEY_LABEL };
CK_BYTE privateKeyLabel[] = { pkcs11demoPRIVATE_KEY_LABEL };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is not NUL terminated in the objects demo as well because when passed to publicKeyTemplate/privateKeyTemplate, the NUL character is removed through the length.

{ CKA_LABEL, publicKeyLabel, sizeof( publicKeyLabel ) - 1 }

Hence, NUL character must also be subtracted from the length in the sign and verify demo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, should the It should not be NULL terminated. comment be removed then as it is not fitting in declaration of the byte arrays..

@aggarw13
Copy link
Contributor

A note about this fix in the CHANGELOG would be valuable

@yourslab yourslab changed the title Update corePKCS11 demo to work with latest submodule pointer Update corePKCS11 demo to read the public key Jul 16, 2021
@yourslab yourslab merged commit 3530fa3 into aws:main Jul 19, 2021
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.

4 participants