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

Add support for some IBM specific mechanisms supported by OpenCryptoki for the RPC protocol #415

Merged
merged 11 commits into from
May 16, 2022

Conversation

ifranzki
Copy link
Contributor

@ifranzki ifranzki commented May 2, 2022

This patch series adds support for a couple of IBM specific mechanisms (and attributes), as well as some standard mechanisms that use mechanism parameters that were not supported so far for the RPC protocol.
All these mechanisms are supported by OpenCryptoki (https:/opencryptoki/opencryptoki) and we would like to make sure that those mechanisms can be used with p11-kit's remote-PKCS#11 feature.

I have tested this by running OpenCryptoki's testcases (https:/opencryptoki/opencryptoki/tree/master/testcases - slightly modified) over p11-kit's remote PKCS#11 interface. Some modifications in OpenCryptoki's testcases were required to let it use the p11-kit's p11-kit-client.so instead of OpenCryptkis's shared library, as well as to avoid the use of things not supported by p11-kit: Attribute-array attributes (CKA_WRAP_TEMPLATE etc), and PKCS#11 version 3.0 interfaces.

@coveralls
Copy link

coveralls commented May 11, 2022

Coverage Status

Coverage decreased (-0.4%) to 71.355% when pulling 6c07b98 on ifranzki:ibm-specific-mechs into 7233528 on p11-glue:master.

common/pkcs11.h Outdated Show resolved Hide resolved
p11-kit/rpc-message.c Outdated Show resolved Hide resolved
Copy link
Member

@ueno ueno left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. The changes look good to me, though I have a few concerns: whether those new mechanisms work without recursive attributes (#366) and need to wait for PKCS#11 3.0 support. Perhaps you could point me to the actual usage in openCryptoki?

All in all, the RPC changes seem reasonable and we could merge them first.

common/pkcs11x.h Outdated Show resolved Hide resolved
p11-kit/rpc-message.c Outdated Show resolved Hide resolved
@ifranzki
Copy link
Contributor Author

By the way I wonder if we can handle AES-GCM properly with the PKCS#11 2.40 interface alone, which lacks message based functions.

Yes this works with just regular C_Encrypt/C_Decrypt functions as of PKCS v2.40.

@ifranzki
Copy link
Contributor Author

whether those new mechanisms work without recursive attributes (#366) and need to wait for PKCS#11 3.0 support. Perhaps you could point me to the actual usage in openCryptoki?

None if these changes are dependent to recursive attributes.

Commit a8f205c is the only one that is related to attribute-array attributes, but is not really required for this PR.

Opencryptoki does support attribute-array attributes in general, and some of the opencryptoki testcases use them, so I thought I could get those tests to work without your PR, but it seems not. But this does not matter for these changes.

Used by CKM_ECDH1_DERIVE, CKM_IBM_EC_X25519 and CKM_IBM_EC_X448.

Signed-off-by: Ingo Franzki <[email protected]>
They take a 16 byte (AES) or 8 byte (DES/DES3) IV as mechanism parameter.

Signed-off-by: Ingo Franzki <[email protected]>
The take a mechanism parameter of type CK_MAC_GENERAL_PARAMS which
is a CK_ULONG.

Signed-off-by: Ingo Franzki <[email protected]>
It takes the the public value of the other party as mechanism parameter.

Signed-off-by: Ingo Franzki <[email protected]>
When the buffer is not NULL, but the length is zero then treat this as an
empty message. Serialize this in a special way so that the server can
restore the same situation.

Example: Terminate an operation via C_XxxFinal, but there is no more
data for the final part. A call to C_XxxFinal with buffer=NULL and length=0
would be treated as a size query, and would not terminate the operation.
So the way to terminate the operation without more data is to specify
buffer!=NULL but length=0.

When sending a byte array, and the buffer is NULL, and the length is
zero, don't treat this is invalid, but as empty message.

Example: C_XxxUpdate with an empty message.

Signed-off-by: Ingo Franzki <[email protected]>
It takes a CK_AES_CTR_PARAMS structure as mechanism parameter.

Signed-off-by: Ingo Franzki <[email protected]>
It takes a CK_GCM_PARAMS structure as mechanism parameter.

Signed-off-by: Ingo Franzki <[email protected]>
@ueno ueno merged commit 7ea5901 into p11-glue:master May 16, 2022
@ueno
Copy link
Member

ueno commented May 16, 2022

Thank you!

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