-
Notifications
You must be signed in to change notification settings - Fork 803
Fixes #1399, 3 certs support OpenPGP (pksc15-tool) #2103
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
Conversation
Jakuje
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looks good, but there are some cosmetic issues that should be fixed before merging this
|
thx for the feedback, |
|
all change requests resolved and some more details to integrate better into the existing code base. |
Jakuje
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing the review comments.This looks good, but there are still few nits, that I would like to get cleared before merging.
|
yeah, sorry for this being so painful, would love to just throw
next try follows shortly... |
Jakuje
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me now. I will keep it open for some time if others will have some more comments.
|
pushed the changes,
|
frankmorgner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this would solve a long standing issue.
Is this backward compatible with v2 (where only a single certificate could be stored?
|
Yes, believe it should be backwards compatible:
|
|
Now also added explicit checks for the OpenPGP version inside the certificate readout and making sure the loop is only iterated once for |
|
Could it be that you forgot to push some commit? The error checking is not visible here https://github.com/OpenSC/OpenSC/pull/2103/files |
|
sorry pushed into the wrong branch, now it's better, will be updated again in a minute because I again messed up the indentation 🙄 |
alex-nitrokey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested only importing and listing for OPCv2 and OPCv3 so far, but LGTM besides the mentioned problem in pkcs-openpgp.c for OPCv2
|
I realized the following: When importing a key-cert pair (aka a .p12 file) with
Instead it should do the following (imho):
When checking the stored certificates I get three instances which leaves me puzzled, because I would have guessed two instances, in AUT and in DEC... But it doesn't stop here, if using
Here again, I get two instances and I would have guessed only one (as both storing attempts should end up in the slot for AUT). Consequently, it works if using I couldn't find the reason in the code yet, does anyone has any idea? Can you reproduce? |
|
@daringer , could you please look at the comments from @alex-nitrokey ? |
|
@frankmorgner yeah, of course, already in the queue, will update the PR accordingly |
|
@alex-nitrokey looks like I cannot reproduce, let's automate a little. openssl genrsa -out rsa_key.pem
openssl genrsa -out server.pem
openssl req -new -key rsa_key.pem -out cert.csr
openssl x509 -req -in cert.csr -signkey server.pem -out cert_signed.crt
openssl pkcs12 -export -out certkey.pfx -inkey server.pem -in cert_signed.crtthen run the following based on sources from this branch: > openpgp-tool --erase
Using reader with a card: Nitrokey Nitrokey Pro (000000000000000000008161) 00 00
Erase card
> pkcs15-init --delete-objects privkey,pubkey --id 1 --store-private-key certkey.pfx --format pkcs12 --auth-id 3 --verify-pin --pin 12345678
Using reader with a card: Nitrokey Nitrokey Pro (000000000000000000008161) 00 00
NOTE: couldn't find privkey 01 to delete
NOTE: couldn't find pubkey 01 to delete
Deleted 0 objects
Importing 1 certificates:
0: /C=AU/ST=Some-State/O=Internet Widgits Pty Ltd
> pkcs15-tool --list-certificates
Using reader with a card: Nitrokey Nitrokey Pro (000000000000000000008161) 00 00
X.509 Certificate [SIG certificate]
Object Flags : [0x02], modifiable
Authority : no
Path : 3f007f21
ID : 01
Encoded serial : 02 14 695E59D1129E7CBC797905C28F31FE35E9D04312this is pretty much the exact opposite of your result 😄 , can you pinpoint what's the difference? I can see 2 calls to |
|
What's the status of this topic, is there anything to do? |
3e71c3d to
de54ceb
Compare
|
Revived this PR, rebased on top of master and resolved the comments accordingly:
PR cleanups: squashed into one commit, various minor additional lines removed and some whitespaces in favor of tabs removed |
|
I would love to get this merged for 0.23.0. The code looks ok and I believe it is handling all the use cases discussed above except the workaround for old Yubikey as mentioned by @ya-isakov (Yubico/yubikey-manager@0ba0ad0). Do we want to implement this? The code is also not rebased on current master and there are no CI results (can you rebase?). As part of the CI we run few tests against some old yubico openpgp applet: https://github.com/OpenSC/OpenSC/blob/master/.github/test-openpgp.sh I think this one implements only much older versions of the applet so we can not test this case. Is somebody aware of some newer applet that could be used for testing given that yubico no longer releases the source of the yubico applets? |
affirmative, taking this as a motivation to keep the pace up...
rebase on top of master + push: ✔️
Very good question, no personal preference on that. |
|
Just compiled tested on Fedora with a v3.3 card and could only see the AUT cert. Loading the extra certs appears to work as I can read them back out using gpg-card readcert x > file.pem. Does the card have to be initialised a certain way? Happy to provide ADPU logs, a card for testing (I have a few lying round). Unfortunately not a C programmer :/ |
|
@amaccuish thx a lot for testing and finding this, shot my foot during the last update! should be fixed by now - as you correctly observed the certificates are in fact added, but not correctly listed nor readable using opensc, this should be fixed now. For you and maybe others to test, I use the following: for me this now lists the certificates properly, you can extract it like this: any permutation of ids works for me, too, looking for someone to verify ... |
|
@daringer works great! Amazing 😍 I guess it's not possible to override the key usage? For example, slot 2 can never be used for TLS since the card refuses to perform the required operations? The key usage flags in the x509 certificate are ignored correct? Otherwise I've tested slot 1 and 3 for S/MIME and TLS auth and they work 🎉❤️ |
|
@amaccuish good to hear, thanks for testing!
I have to admit that I cannot tell in full detail. The OpenPGPCard spec defines SIG, DEC and AUT and for which respective operations they shall be used (and can optionally be used), so I would assume that client applications simply obey the spec - and partly the smartcard implementation also enforces that (e.g., |
|
uh nice, thanks for the thorough reviews! fixes are on the way |
frankmorgner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thank you
|
Thank you. Merging for next rc/final release of 0.23.0 |
Tested with:
Checklist
My impression is that the other checklist items do not apply, please correct me if I am wrong.