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 command to generate keypair on a PKCS#11 token #551

Merged
merged 3 commits into from
Sep 15, 2023

Conversation

ZoltanFridrich
Copy link
Contributor

When the user builds a solution around PKCS#11, such as setting up an HTTPS server with NGINX or Apache HTTPD, they first would need to create a key pair on a PKCS#11 token, where the private key can be used to sign the certificate and TLS handshake.

The generate-keypair subcommand has been added to generate a private key and the corresponding public key. This takes a PKCS#11 URI of a token, where the generated keys are stored, and a label through the --label option. It can also take other options, such as --type to specify the key type and --bits to specify the key size.

@ZoltanFridrich ZoltanFridrich self-assigned this Sep 6, 2023
@ZoltanFridrich ZoltanFridrich changed the title Add command to generate keypair on a PKCS#11 token [WIP] Add command to generate keypair on a PKCS#11 token Sep 6, 2023
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
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.

I guess one tricky thing is that, if we want to support EC keys, we need to encode ECParamters in ASN.1 and the tool would probably need to link to libtasn1, which is currently an optional build dependency for the trust module. I guess some tweak in the build infrastructure is needed, e.g., check libtasn1 is available, and if yes, link p11-kit tool to it; otherwise we shouldn't but we can still support RSA.

common/compat.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
@ZoltanFridrich ZoltanFridrich force-pushed the zfridric_devel2 branch 3 times, most recently from 4bb00eb to 6ae757c Compare September 11, 2023 10:14
@coveralls
Copy link

coveralls commented Sep 11, 2023

Coverage Status

coverage: 68.648% (-0.1%) from 68.762% when pulling 3fbf587 on ZoltanFridrich:zfridric_devel2 into 65b2e47 on p11-glue:master.

@ZoltanFridrich ZoltanFridrich force-pushed the zfridric_devel2 branch 6 times, most recently from cb54855 to a5ef9d2 Compare September 13, 2023 15:03
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.

No test, while CKM_MOCK_GENERATE is supported?

p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Show resolved Hide resolved
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Show resolved Hide resolved
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
@ZoltanFridrich ZoltanFridrich force-pushed the zfridric_devel2 branch 3 times, most recently from e0700dc to 7cb7f2f Compare September 14, 2023 10:01
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
@ZoltanFridrich ZoltanFridrich force-pushed the zfridric_devel2 branch 2 times, most recently from 27e0129 to 04fc3e5 Compare September 14, 2023 14:21
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Outdated Show resolved Hide resolved
p11-kit/test-objects.sh Outdated Show resolved Hide resolved
p11-kit/generate-keypair.c Dismissed Show dismissed Hide dismissed
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
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.

Looks good to me, please remove "[WIP]" from the title when merging.

@ZoltanFridrich ZoltanFridrich changed the title [WIP] Add command to generate keypair on a PKCS#11 token Add command to generate keypair on a PKCS#11 token Sep 15, 2023
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
p11-kit/generate-keypair.c Fixed Show fixed Hide fixed
@ZoltanFridrich ZoltanFridrich merged commit ca5ed35 into p11-glue:master Sep 15, 2023
12 checks passed
@ueno ueno added this to the 0.25.1 milestone Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants