From c97fc2e719f33d6750e6c9d6ff4e5fa9a98a167b Mon Sep 17 00:00:00 2001 From: pk Date: Sat, 28 May 2011 14:24:27 +0000 Subject: [PATCH] support for TCOS3 IdKey cards and fix for bug #256 git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5508 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/card-tcos.c | 4 ++- src/libopensc/pkcs15-tcos.c | 53 ++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/libopensc/card-tcos.c b/src/libopensc/card-tcos.c index b3f6ac60..d6362a38 100644 --- a/src/libopensc/card-tcos.c +++ b/src/libopensc/card-tcos.c @@ -1,7 +1,7 @@ /* * card-tcos.c: Support for TCOS cards * - * Copyright (C) 2007 Peter Koch + * Copyright (C) 2011 Peter Koch * Copyright (C) 2002 g10 Code GmbH * Copyright (C) 2001 Juha Yrjölä * @@ -42,6 +42,8 @@ static struct sc_atr_table tcos_atrs[] = { { "3B:BA:96:00:81:31:86:5D:00:64:05:7B:02:03:31:80:90:00:7D", NULL, NULL, SC_CARD_TYPE_TCOS_V2, 0, NULL }, /* Philips P5CT072 */ { "3B:BF:96:00:81:31:FE:5D:00:64:04:11:03:01:31:C0:73:F7:01:D0:00:90:00:7D", NULL, NULL, SC_CARD_TYPE_TCOS_V3, 0, NULL }, + /* Philips P5CT080 */ + { "3B:BF:B6:00:81:31:FE:5D:00:64:04:28:03:02:31:C0:73:F7:01:D0:00:90:00:67", NULL, NULL, SC_CARD_TYPE_TCOS_V3, 0, NULL }, { NULL, NULL, NULL, 0, 0, NULL } }; diff --git a/src/libopensc/pkcs15-tcos.c b/src/libopensc/pkcs15-tcos.c index d2b0172c..f2cd7899 100644 --- a/src/libopensc/pkcs15-tcos.c +++ b/src/libopensc/pkcs15-tcos.c @@ -1,7 +1,7 @@ /* * PKCS15 emulation layer for TCOS based preformatted cards * - * Copyright (C) 2010, Peter Koch + * Copyright (C) 2011, Peter Koch * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -275,7 +275,7 @@ static int detect_netkey( /* NKS-Applikation ? */ memset(&p, 0, sizeof(sc_path_t)); - p.len=7; p.type=SC_PATH_TYPE_DF_NAME; + p.type=SC_PATH_TYPE_DF_NAME; memcpy(p.value, "\xD2\x76\x00\x00\x03\x01\x02", p.len=7); if (sc_select_file(card,&p,&f)!=SC_SUCCESS) return 1; sprintf(dir,"%04X", f->id); @@ -303,8 +303,7 @@ static int detect_netkey( insert_key(p15card, dirpath(dir,"0000"), 0x48, 0x83, 1024, 3, "1024bit Schluessel"); insert_pin(p15card, "5000", 1, 2, 0x00, 6, "PIN", - SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED | - SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN + SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED ); insert_pin(p15card, "5001", 2, 0, 0x01, 8, "PUK", SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED | @@ -358,6 +357,43 @@ static int detect_netkey( return 0; } +static int detect_idkey( + sc_pkcs15_card_t *p15card +){ + sc_card_t *card=p15card->card; + sc_path_t p; + + /* TCKEY-Applikation ? */ + memset(&p, 0, sizeof(sc_path_t)); + p.type=SC_PATH_TYPE_DF_NAME; + memcpy(p.value, "\xD2\x76\x00\x00\x03\x0C\x01", p.len=7); + if (sc_select_file(card,&p,NULL)!=SC_SUCCESS) return 1; + + p15card->tokeninfo->manufacturer_id = strdup("TeleSec GmbH"); + p15card->tokeninfo->label = strdup("IDKey Card"); + + insert_cert(p15card, "DF074331", 0x45, 1, "Signatur Zertifikat 1"); + insert_cert(p15card, "DF074332", 0x45, 1, "Signatur Zertifikat 2"); + insert_cert(p15card, "DF074333", 0x45, 1, "Signatur Zertifikat 3"); + + insert_key(p15card, "DF074E03", 0x45, 0x84, 2048, 1, "IDKey1"); + insert_key(p15card, "DF074E04", 0x46, 0x85, 2048, 1, "IDKey2"); + insert_key(p15card, "DF074E05", 0x47, 0x86, 2048, 1, "IDKey3"); + insert_key(p15card, "DF074E06", 0x48, 0x87, 2048, 1, "IDKey4"); + insert_key(p15card, "DF074E07", 0x49, 0x88, 2048, 1, "IDKey5"); + insert_key(p15card, "DF074E08", 0x4A, 0x89, 2048, 1, "IDKey6"); + + insert_pin(p15card, "5000", 1, 2, 0x00, 6, "PIN", + SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED + ); + insert_pin(p15card, "5001", 2, 0, 0x01, 8, "PUK", + SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED | + SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN + ); + + return 0; +} + static int detect_signtrust( sc_pkcs15_card_t *p15card ){ @@ -403,8 +439,7 @@ static int detect_datev( insert_key(p15card,"DF025371", 0x47, 0x82, 1024, 1, "Authentifizierungs Schluessel"); insert_pin(p15card,"5001", 1, 0, 0x01, 6, "PIN", - SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED | - SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN + SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED ); return 0; @@ -436,8 +471,7 @@ static int detect_unicard( } else return 1; insert_pin(p15card,"5000", 1, 2, 0x00, 6, "PIN", - SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED | - SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN + SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED ); insert_pin(p15card,"5008", 2, 0, 0x01, 8, "PUK", SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED | @@ -472,9 +506,10 @@ int sc_pkcs15emu_tcos_init_ex( p15card->tokeninfo->serial_number = strdup(serial); if(!detect_netkey(p15card)) return SC_SUCCESS; + if(!detect_idkey(p15card)) return SC_SUCCESS; + if(!detect_unicard(p15card)) return SC_SUCCESS; if(!detect_signtrust(p15card)) return SC_SUCCESS; if(!detect_datev(p15card)) return SC_SUCCESS; - if(!detect_unicard(p15card)) return SC_SUCCESS; return SC_ERROR_INTERNAL; }