-
Notifications
You must be signed in to change notification settings - Fork 803
Updated Italian CNS to support IDEMIA (Oberthur) tokens #2483
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
0ca0c92 to
1aab1b9
Compare
49f1154 to
167dc9f
Compare
c1d5a4f to
c0821d5
Compare
|
Please check out frankmorgner@662d2a9 ... this may help you simplify the card matching process... |
c0821d5 to
a90abd4
Compare
xhanulik
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.
Some minor inconsistency in indentation
|
Any news on this? I've received one of those cards and I would be glad if it would be supported! |
|
BTW I've built and tested this change both with an older italian CNS (AC 2014) and a brand new ACe 2021. |
|
@3v1n0 did you get back to the review comments? This looks like it works ok for several users so it would be great to have this in the coming release. |
|
Comments the use of the ATR and mask: This Only supports NFC, and is very generic, and could be mistaken for some other card. Can this card be used in a normal contact reader? If so it would have a different ATR. I see you have figured out how to use already parsed ATR to get at the history bytes: |
... and modify internal data only during initialization
There's no need to use custom values, while in this way we can expose such information to the card users
Gemalto was added in the last reference of CNS – Carta Nazionale dei Servizi Functional Specification [1], while Oberthur is now named IDEMIA. [1] https://www.agid.gov.it/sites/default/files/repository_files/documentazione_trasparenza/cns_functional_specification_1.1.6_02042011.pdf
In case a card has some contents in the fetched path, but that's not an X.509 certificate, we're accepting it anyways until it's actually going to be used, and so will be listed as an available object. Instead ensure whether this is valid through openssl before adding it.
Some cards can generate very small random numbers, so perform the action multiple times to get up to the requested value. This is handled by OpenSC, when the returned size is just less than expected.
New Idemia / Oberthur cards have been provided to people and they use a slightly different protocol, as per the reverse engineering of the new protocol, I've adapted the missing bits. Main key points: - Certificate path is 140090012002 - Public key path is 11001102 - The certificate has a size of 2048 - Private key path is 14009002 - The random number generator can only provide up to 32 bytes, so we just request multiple chunks in case a bigger number is requested. Also, official driver uses chained APDU commands to handle signing operations, however the card also supports extended APDU, so we can just use that instead of using chained commands (that would require some adjustments on the main library) Fixes: OpenSC#2445
When using the card with a NFC reader the ATR is different, so we need to use hard matching.
a90abd4 to
1708c06
Compare
|
Sorry, took a while to update this, but comments should be handled now. |
Yes, it can be used both in a physical and NFC reader.
The ATR of the card I'm using here is But I didn't want to be too strict with it, in case some other card may change it. |
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.
except for the minor comments inline, looks good.
| itacns_get_challenge(sc_card_t *card, u8 *rnd, size_t len) | ||
| { | ||
| if (card->type == SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021) | ||
| len = MIN (0x20, len); |
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.
nit: using decimal representation in this context might be more readable than hexadecimal.
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.
Overall the code looks good. If you address the comments posted in the previous reviews, then I think we can move forward.
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.
I think the comments are really just nits. We should merge this PR as is and move on.
Added missing bits to support new Italian CNS cards provided by Idemia that have use now some less-standard mechanisms.
Checklist
Fixes #2445