Skip to content

Commit

Permalink
FinnishEid: fix the symbolic names for FINeID v2 cards with 2048 keys…
Browse files Browse the repository at this point in the history
… and restore compatibility with v2 cards with 1024 keys.

The more proper name for the 2048bit cards could be "v2.5".

Thanks to jem@iki.fi, kivinen@iki.fi and tuju@iki.fi for the patch.
  • Loading branch information
martinpaljak committed Jun 15, 2011
1 parent 6e70c09 commit 2757253
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
26 changes: 7 additions & 19 deletions src/libopensc/card-setcos.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ static struct sc_atr_table setcos_atrs[] = {
/* FINEID 2264 (EIDApplet/7816-15, OPK/EMV/AVANT) */
{ "3b:6e:00:00:00:62:00:00:57:41:56:41:4e:54:10:81:90:00", NULL, NULL, SC_CARD_TYPE_SETCOS_FINEID_V2, 0, NULL },
{ "3b:7b:94:00:00:80:62:11:51:56:46:69:6e:45:49:44", NULL, NULL, SC_CARD_TYPE_SETCOS_FINEID_V2, 0, NULL },
/* New FINEID cards released after 1.3.2011 with 2048 bit keys. */
{ "3b:7b:94:00:00:80:62:12:51:56:46:69:6e:45:49:44", NULL, NULL, SC_CARD_TYPE_SETCOS_FINEID_S2, 0, NULL },
/* FINEID cards 1.3.2011 with Samsung chips (round connector) that supports 2048 bit keys. */
{ "3b:7b:94:00:00:80:62:12:51:56:46:69:6e:45:49:44", NULL, NULL, SC_CARD_TYPE_SETCOS_FINEID_V2_2048, 0, NULL },
/* Swedish NIDEL card */
{ "3b:9f:94:80:1f:c3:00:68:10:44:05:01:46:49:53:45:31:c8:07:90:00:18", NULL, NULL, SC_CARD_TYPE_SETCOS_NIDEL, 0, NULL },
/* Setcos 4.4.1 */
Expand Down Expand Up @@ -103,7 +103,7 @@ static int setcos_match_card(sc_card_t *card)
if (i < 0) {
/* Unknown card, but has the FinEID application for sure */
if (match_hist_bytes(card, "FinEID", 0)) {
card->type = SC_CARD_TYPE_SETCOS_FINEID_V2;
card->type = SC_CARD_TYPE_SETCOS_FINEID_V2_2048;
return 1;
}
if (match_hist_bytes(card, "FISE", 0)) {
Expand Down Expand Up @@ -164,8 +164,7 @@ static int setcos_init(sc_card_t *card)

switch (card->type) {
case SC_CARD_TYPE_SETCOS_FINEID:
case SC_CARD_TYPE_SETCOS_FINEID_V2:
case SC_CARD_TYPE_SETCOS_FINEID_S2:
case SC_CARD_TYPE_SETCOS_FINEID_V2_2048:
case SC_CARD_TYPE_SETCOS_NIDEL:
card->cla = 0x00;
select_pkcs15_app(card);
Expand All @@ -190,24 +189,14 @@ static int setcos_init(sc_card_t *card)

switch (card->type) {
case SC_CARD_TYPE_SETCOS_PKI:
case SC_CARD_TYPE_SETCOS_FINEID:
case SC_CARD_TYPE_SETCOS_FINEID_V2:
case SC_CARD_TYPE_SETCOS_FINEID_V2_2048:
{
unsigned long flags;

flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;

_sc_card_add_rsa_alg(card, 1024, flags, 0);
}
break;
case SC_CARD_TYPE_SETCOS_FINEID_S2:
{
unsigned long flags;

flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;

_sc_card_add_rsa_alg(card, 2048, flags, 0);
}
break;
Expand Down Expand Up @@ -603,7 +592,7 @@ static int setcos_set_security_env2(sc_card_t *card,
case SC_SEC_OPERATION_SIGN:
/* Should be 0x41 */
apdu.p1 = ((card->type == SC_CARD_TYPE_SETCOS_FINEID_V2) ||
(card->type == SC_CARD_TYPE_SETCOS_FINEID_S2) ||
(card->type == SC_CARD_TYPE_SETCOS_FINEID_V2_2048) ||
(card->type == SC_CARD_TYPE_SETCOS_44) ||
(card->type == SC_CARD_TYPE_SETCOS_NIDEL) ||
SETCOS_IS_EID_APPLET(card)) ? 0x41 : 0x81;
Expand Down Expand Up @@ -687,8 +676,7 @@ static int setcos_set_security_env(sc_card_t *card,
switch (card->type) {
case SC_CARD_TYPE_SETCOS_PKI:
case SC_CARD_TYPE_SETCOS_FINEID:
case SC_CARD_TYPE_SETCOS_FINEID_V2:
case SC_CARD_TYPE_SETCOS_FINEID_S2:
case SC_CARD_TYPE_SETCOS_FINEID_V2_2048:
case SC_CARD_TYPE_SETCOS_NIDEL:
case SC_CARD_TYPE_SETCOS_44:
case SC_CARD_TYPE_SETCOS_EID_V2_0:
Expand Down
2 changes: 1 addition & 1 deletion src/libopensc/cards.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ enum {
SC_CARD_TYPE_SETCOS_PKI,
SC_CARD_TYPE_SETCOS_FINEID,
SC_CARD_TYPE_SETCOS_FINEID_V2,
SC_CARD_TYPE_SETCOS_FINEID_S2,
SC_CARD_TYPE_SETCOS_NIDEL,
SC_CARD_TYPE_SETCOS_FINEID_V2_2048,
SC_CARD_TYPE_SETCOS_44 = 6100,
SC_CARD_TYPE_SETCOS_EID_V2_0,
SC_CARD_TYPE_SETCOS_EID_V2_1,
Expand Down

0 comments on commit 2757253

Please sign in to comment.