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

Support for new MinInt agent card #1092

Merged
merged 8 commits into from
Aug 21, 2017
Merged

Support for new MinInt agent card #1092

merged 8 commits into from
Aug 21, 2017

Conversation

af-anssi
Copy link
Contributor

@af-anssi af-anssi commented Jul 7, 2017

This card uses the same ATR as the existing card, but the applet installed
does not have the same AID. This card actually works exactly as the
IASECC_SAGEM.

LOG_TEST_RET(ctx, rv, "Could not select MI's AID");
resp_len = sizeof(resp);
rv = iasecc_select_aid(card, &MIIASECC_AID, resp, &resp_len);
LOG_TEST_GOTO_ERR(ctx, rv, "Could not select MI's AID");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only use the err: label (and goto in general) for cleanup.

@@ -264,6 +264,9 @@ iasecc_select_mf(struct sc_card *card, struct sc_file **file_out)
apdu.resplen = sizeof(apdu_resp);
apdu.resp = apdu_resp;

if (card->type == SC_CARD_TYPE_IASECC_MI2)
apdu.p2 = 0x04;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this change required if the applet only changes the AID?

@@ -323,6 +326,9 @@ iasecc_select_aid(struct sc_card *card, struct sc_aid *aid, unsigned char *out,
apdu.resplen = sizeof(apdu_resp);
apdu.resp = apdu_resp;

if (card->type == SC_CARD_TYPE_IASECC_MI2)
apdu.p2 = 0x04;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this change required if the applet only changes the AID?

Copy link
Member

@frankmorgner frankmorgner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In principal, the change is OK, but please unify the usage of iasecc_init_amos, iasecc_init_sagem.


rv = iasecc_mi_match(card);
LOG_TEST_RET(ctx, rv, "Could not match MI's AID");

if(rv) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use if (rv) {


if(rv) {
card->type = SC_CARD_TYPE_IASECC_MI2;
rv = iasecc_init_sagem(card);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please unify the usage of iasecc_init_amos, iasecc_init_sagem and your card? Currently, they all do the same, which should be generalized under a different name.

I think the driver is not very consistently written; iasecc_init_oberthur and iasecc_init_gemalto also shares most of the code...

resp_len = sizeof(resp);
rv = iasecc_select_aid(card, &MIIASECC_AID, resp, &resp_len);

rv = iasecc_mi_match(card);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, the match function should be used to determine the card's type. I suggest you add iasecc_select_aid(card, &MIIASECC_AID, resp, &resp_len); to iasecc_mi_match() (note that you should check rv when selecting the applet!). (Yes, I know that this has been a mistake of the past, but giving some love to the code today, will benefit all contributors in the future.)

if (rv)
card->type = SC_CARD_TYPE_IASECC_MI2;
else
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If iasecc_mi_match() doesn't succeed, you should not return with SC_SUCCESS. I think would break all other cards that are initialized with iasecc_init_amos(), right?

@@ -562,65 +557,26 @@ iasecc_init_amos(struct sc_card *card)
card->caps |= SC_CARD_CAP_APDU_EXT;
card->caps |= SC_CARD_CAP_USE_FCI_AC;

if (card->type == SC_CARD_TYPE_IASECC_MI) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the type of card is tested here, there is no issue with other cards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the clearification

@@ -562,65 +557,26 @@ iasecc_init_amos(struct sc_card *card)
card->caps |= SC_CARD_CAP_APDU_EXT;
card->caps |= SC_CARD_CAP_USE_FCI_AC;

if (card->type == SC_CARD_TYPE_IASECC_MI) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the clearification

@frankmorgner
Copy link
Member

Can you check whether the "old" iasecc cards are still functioning as expected?

@af-anssi
Copy link
Contributor Author

af-anssi commented Aug 21, 2017

For the SAGEM_MI2 card, the applet actually differs a bit from the one installed on SAGEM_MI cards as it really requires P2 to be set to 0x04 when selecting the MF; that is why I reintroduced this change.

I tested both SAGEM_MI and SAGEM_MI2 cards, as well as the "simple" SAGEM IAS/ECC. All are working fine via pkcs11-tool (provisioning, encryption, signature). I have no AMOS card so I cannot test if it is impacted.

@frankmorgner
Copy link
Member

OK, fine.

@frankmorgner frankmorgner merged commit 2765b7b into OpenSC:master Aug 21, 2017
metsma pushed a commit to metsma/OpenSC that referenced this pull request Dec 6, 2017
* Support for new MinInt agent card

This card uses the same ATR as the existing card, but the applet installed
does not have the same AID. This card actually works exactly as the
IASECC_SAGEM.

Unify iasecc_init for AMOS/SAGEM and MI cards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants