-
Notifications
You must be signed in to change notification settings - Fork 803
support for Slovak eID cards #2672
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
|
@jurajsarinay don't take the tests at gold standard value, if it can be fixed in a generalized way to take into account "always authenticate" behavior, would be a lovely addition together with this PR. |
… software distributed by the government
| } | ||
|
|
||
| key_id = env->key_ref[0]; | ||
| r = sc_restore_security_env(card, key_id); |
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.
This is at least weird. I would be probably for reimplementing the iso7816_restore_security_env (its just one APDU) with some comments, instead of reusing it for setting the security environment (with the key id instead of security environment number). The restore of security environment is completely different operation and that it works is probably pure coincidence.
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.
pure coincidence
... of design & luck.
I need to bolt this on top of OpenSC in one way or another. Because of use_key() there needs to be a meaningful sc_set_security_env() for the card.
OpenSC/src/libopensc/pkcs15-sec.c
Line 151 in 7077173
| r = sc_set_security_env(p15card->card, senv, 0); |
MSE RESTORE is what the proprietary module does. The operation is simply a shorthand for MSE SET, that's why I hoped this would not be viewed as utter heresy.
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.
If others dont have issue with this. I am ok with keeping this as long as it will contain some comment in the code that this is what the official driver does. Without comment it still looks like an error (and comments on github are not guaranteed to be accessible forever).
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.
Please add your card's ATR to the Windows installation so that it will be supported via Windows' Minidriver via https://github.com/OpenSC/OpenSC/blob/master/win32/customactions.cpp
|
I wonder if card-skeid.c is needed at if the difference from card-cardos.c is so small. card-cardos.c is written in a generic way, which the slowak card doesn't need. I think it should be better to use skeid_known_url() in cardos_init to get the card type and later to use the card type in cardos_set_security_env to implement the workaround for the slowak card. @Jakuje , since you are familiar with the cardos specification, do you know where the use of MSE RESTORE originates and if it could be integrated in a general way into card-cardos.c? |
That was my original plan. I went for a separate driver, because I did not feel comfortable touching (old) code in the CardOS driver(s). Apart from using a specific |
OK, fair enough, card-skeid.c is simple enough to be maintained seperately. |
|
@jurajsarinay, you should probably rebase your commits on top of the current |
This is a result of clicking "Sync fork" within GitHub, I should probably have refrained from that :-) |
|
Oh, I never used that button, I always rebase and force-push manually 🙂 |
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.
minor whitespace nits, but otherwise looks good
| } | ||
|
|
||
| key_id = env->key_ref[0]; | ||
| r = sc_restore_security_env(card, key_id); |
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.
If others dont have issue with this. I am ok with keeping this as long as it will contain some comment in the code that this is what the official driver does. Without comment it still looks like an error (and comments on github are not guaranteed to be accessible forever).
minor whitespace nits Co-authored-by: Jakub Jelen <[email protected]>
Thank you, @Jakuje! |
|
@frankmorgner Any updates as to when this could possibly be merged? |
|
done, thank you |
Checklist
Please see #208 (comment).
I propose to add a new driver to handle eID cards issued by Slovakia from mid-2021 until November 2022.
Driver
The card runs CardOS 5.4, the new driver is therefore a stripped-down version of
card-cardos.cThe only place where I have to diverge from the original driver isset_security_env, because the card expectsMSE RESTOREinstead ofMSE SET. I abusekey_refto store the correspondingseIdentifier, as our pkcs#15 structures do not include the entry.Because the card shares the ATR with other CardOS 5.4 cards, the new driver precedes
cardos-driverwithininternal_card_drivers[].PKCS#15 emulation
Within EF.DIR there are 5 applications. The last two carry (apparently not entirely usable) PKCS#15 structures.
pkcs15-skeid.cbinds the fourth application in the list. Otherwisesc_pkcs15_bind_internalwould get called and create an unusable token. In the case of the fifth application this is prevented bySC_PKCS11_FRAMEWORK_DATA_MAX_NUM = 4.Because there is no point in calling
sc_pkcs15_bind_internalfor this card, I added it tosc_pkcs15_is_emulation_only. This does not preventsc_pkcs15_bind_internalfrom getting called though (if synthetic binding was unsuccessful).I consider this behaviour a bit counterintuitive. I mention it here to report on and justify what I have done, it has no noticeable effect on my driver (any more). Let me know if
sc_pkcs15_is_emulation_onlywarrants a separate GitHub issue.PINs
There is a global User PIN labeled BOK. The qualified certificate (key) requires user consent and a separate (local) Signature PIN labeled KEP. The "official" proprietary PKCS#11 module requires both the codes for every signature. Fortunately, the card is happy with the Signature PIN only, as there seems to be no convenient way to have multiple PIN codes per slot.
I considered emulating (parts of) the "official" behaviour wihtin a custom
pin_cmdthat contained the following:I ultimately decided against the idea. It adds complexity (or confusion) and provides little benefit. I mention the issue because it is connected to a failure in
pkcs11-tool --test --slot 1 --login: log.Because the local Signature PIN is used for the session,
test_verify()fails here.The card enforces CKA_ALWAYS_AUTHENTICATE and therefore reports that the Signature PIN is (no longer) verified, apparently because signatures have been computed during
test_signature(). The only effect of this is that the built-in test fails even though the token works (reasonably) well.The above
pin_cmdhack would result in a passedpkcs11-tool --test --slot 1 --login.I include this information mainly to justify a PR with a failed test attached. If the behaviour of
pkcs11-tool --testin the context of a local Signature PIN anduser_consentwarrants a separate GitHub issue, do please let me know.For completeness, here is the output of
pkcs11-tool --test --slot 0 --login.