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

p11-kit export-object doesn't work for public keys without SPKI stored #555

Closed
ueno opened this issue Sep 16, 2023 · 0 comments · Fixed by #568
Closed

p11-kit export-object doesn't work for public keys without SPKI stored #555

ueno opened this issue Sep 16, 2023 · 0 comments · Fixed by #568

Comments

@ueno
Copy link
Member

ueno commented Sep 16, 2023

Steps to reproduce:

$ cat softhsm2.conf
directories.tokendir = /tmp/softhsm/
$ mkdir /tmp/softhsm
$ export SOFTHSM2_CONF=$PWD/softhsm2.conf
$ softhsm2-util --init-token --free --label test
$ GNUTLS_PIN=12345 p11tool --login --generate-privkey=ecdsa --label foo 'pkcs11:model=SoftHSM%20v2'
...
$ p11tool --export 'pkcs11:model=SoftHSM%20v2;token=test;object=foo;type=public'
...
$ p11-kit export-object 'pkcs11:model=SoftHSM%20v2;token=test;object=foo;type=public'
p11-kit: ../common/pem.c:277: p11_pem_write: Assertion `len > 0' failed.

The current implementation only retrieves CKA_PUBLIC_KEY_INFO, but the spec says about the attribute: "DER-encoding of the SubjectPublicKeyInfo for this public key. (MAY be empty, DEFAULT derived from the underlying public key data)".
I guess we would need to fallback to the algorithm specific method.

@ueno ueno changed the title p11-kit export-object doesn't work reliably p11-kit export-object doesn't work for public keys without SPKI stored Sep 16, 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 a pull request may close this issue.

1 participant