diff --git a/src/libopensc/card-asepcos.c b/src/libopensc/card-asepcos.c index 37fbabfe..855c53a1 100644 --- a/src/libopensc/card-asepcos.c +++ b/src/libopensc/card-asepcos.c @@ -317,76 +317,7 @@ static int asepcos_select_file(sc_card_t *card, const sc_path_t *in_path, static int asepcos_set_security_env(sc_card_t *card, const sc_security_env_t *env, int se_num) { -#if 0 - /* this function doesn't seem to be necessary if RSA ENCRYPT DECRYPT - * is used. */ - - sc_apdu_t apdu; - u8 sbuf[SC_MAX_APDU_BUFFER_SIZE], *p = sbuf; - int r, locked = 0; - - SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0, 0); - switch (env->operation) { - case SC_SEC_OPERATION_DECIPHER: - apdu.p1 = 0x41; - apdu.p2 = 0xB8; - break; - case SC_SEC_OPERATION_SIGN: - apdu.p1 = 0x41; - apdu.p2 = 0xB6; - break; - default: - return SC_ERROR_INVALID_ARGUMENTS; - } - if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) { - *p++ = 0x80; /* algorithm reference */ - *p++ = 0x01; - *p++ = env->algorithm_ref & 0xFF; - } - if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) { - *p++ = 0x84; - *p++ = env->file_ref.len; - memcpy(p, env->file_ref.value, env->file_ref.len); - p += env->file_ref.len; - } - - apdu.lc = p - sbuf; - apdu.datalen = p - sbuf; - apdu.data = sbuf; - if (se_num > 0) { - r = sc_lock(card); - SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "sc_lock() failed"); - locked = 1; - } - if (apdu.datalen != 0) { - r = sc_transmit_apdu(card, &apdu); - if (r) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "%s: APDU transmit failed", sc_strerror(r)); - goto err; - } - r = sc_check_sw(card, apdu.sw1, apdu.sw2); - if (r) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "%s: Card returned error", sc_strerror(r)); - goto err; - } - } - if (se_num <= 0) - return 0; - sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xF2, se_num); - r = sc_transmit_apdu(card, &apdu); - sc_unlock(card); - SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); - return sc_check_sw(card, apdu.sw1, apdu.sw2); -err: - if (locked) - sc_unlock(card); - return r; -#else return SC_SUCCESS; -#endif } @@ -799,14 +730,6 @@ static int asepcos_delete_file(sc_card_t *card, const sc_path_t *path) sc_apdu_t apdu; u8 buf[SC_MAX_APDU_BUFFER_SIZE]; -#if 0 - /* select the file (note: if the file is already selected we do - * not re-select it as we might otherwise lose the necessary - * credential */ - r = sc_select_file(card, path, NULL); - if (r != SC_SUCCESS) - return r; -#endif /* use GET DATA to determine whether it is a DF or EF */ sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x84); apdu.le = 256; diff --git a/src/libopensc/card-authentic.c b/src/libopensc/card-authentic.c index f5f0e001..744c534b 100644 --- a/src/libopensc/card-authentic.c +++ b/src/libopensc/card-authentic.c @@ -519,41 +519,6 @@ authentic_erase_binary(struct sc_card *card, unsigned int offs, size_t count, un } -#if 0 -static int -authentic_resize_file(struct sc_card *card, unsigned file_id, unsigned new_size) -{ - struct sc_context *ctx = card->ctx; - struct sc_apdu apdu; - unsigned char data[6] = { - 0x62, 0x04, 0x80, 0x02, 0xFF, 0xFF - }; - int rv; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "try to set file size to %i bytes", new_size); - - data[4] = (new_size >> 8) & 0xFF; - data[5] = new_size & 0xFF; - - sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDB, (file_id >> 8) & 0xFF, file_id & 0xFF); - apdu.data = data; - apdu.datalen = sizeof(data); - apdu.lc = sizeof(data); - - rv = sc_transmit_apdu(card, &apdu); - LOG_TEST_RET(ctx, rv, "APDU transmit failed"); - rv = sc_check_sw(card, apdu.sw1, apdu.sw2); - LOG_TEST_RET(ctx, rv, "resize file failed"); - - if (card->cache.valid && card->cache.current_ef && card->cache.current_ef->id == file_id) - card->cache.current_ef->size = new_size; - - LOG_FUNC_RETURN(ctx, rv); -} -#endif - - static int authentic_set_current_files(struct sc_card *card, struct sc_path *path, unsigned char *resp, size_t resplen, struct sc_file **file_out) @@ -2074,9 +2039,6 @@ authentic_set_security_env(struct sc_card *card, default: LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); } -#if 0 - apdu.flags |= SC_APDU_FLAGS_CAN_WAIT; -#endif rv = sc_transmit_apdu(card, &apdu); LOG_TEST_RET(ctx, rv, "APDU transmit failed"); diff --git a/src/libopensc/card-belpic.c b/src/libopensc/card-belpic.c index 27a4947c..73969d06 100644 --- a/src/libopensc/card-belpic.c +++ b/src/libopensc/card-belpic.c @@ -99,12 +99,6 @@ #include "scr.h" #endif -/* These defines are disabled for OpenSC */ -#if 0 -#define GET_LANG_FROM_CARD -#define HAVE_ALLOW_SSO -#endif - #ifdef HAVE_GUI #include "scgui.h" #ifndef SCR_USAGE_SIGN @@ -143,12 +137,6 @@ static struct sc_atr_table belpic_atrs[] = { { "3B:98:94:40:0A:A5:03:01:01:01:AD:13:10", NULL, NULL, SC_CARD_TYPE_BELPIC_EID, 0, NULL }, /* Applet beta 5 + V1.0 */ { "3B:98:94:40:FF:A5:03:01:01:01:AD:13:10", NULL, NULL, SC_CARD_TYPE_BELPIC_EID, 0, NULL }, -#if 0 - /* Applet beta 3 + 4 */ - { "3B:98:11:40:FF:A5:03:01:01:01:AD:13:04", NULL, NULL, SC_CARD_TYPE_BELPIC_EID, 0, NULL }, - /* Applet beta 2 */ - { "3B:68:00:00:29:05:01:02:01:AD:13:03", NULL, NULL, SC_CARD_TYPE_BELPIC_EID, 0, NULL }, -#endif { NULL, NULL, NULL, 0, 0, NULL } }; @@ -382,18 +370,6 @@ static char *pin_blocked_msgs[4] = { #endif /* HAVE_GUI */ -/* To be removed */ -#if 0 -static void dumphex(char *msg, const u8 * buf, int len) -{ - int i; - printf("%s", msg); - for (i = 0; i < len; i++) - printf("%02X ", buf[i]); - printf(" (%d bytes)\n", len); -} -#endif - #ifdef BELPIC_PIN_PAD #define SCR_INIT_ID 100 @@ -702,9 +678,6 @@ static int get_language(sc_card_t *card) sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Read_Binary[prefs_file] returned %d\n", r); goto prefs_error; } -#if 0 - dumphex("Prefs: ", prefs, r); -#endif i = get_pref(prefs, r, "[gen]", "lg", &len); if (i <= 0 || len < 2) { sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Couldn't find language in prefs file: %d\n", i); @@ -809,41 +782,6 @@ static int belpic_load_pin_pad_lib(sc_card_t *card, struct belpic_priv_data *pri "Initialization of library returned UNSUPPORTED"); return SC_ERROR_READER; } -#if 0 - HINSTANCE dll = LoadLibrary(pp_reader_lib); - - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Pin pad reader \"%s\" found, now loading corresponding lib \"%s\"\n", - reader_name, pp_reader_lib); - if (dll == NULL) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to load library \"%s\", err = 0x%0x\n", - pp_reader_lib, GetLastError()); - load_pin_pad_err(reader_name, pp_reader_lib, - "library not found or unable to load it"); - return SC_ERROR_READER; - } - priv_data->scr_init = GetProcAddress(dll, "SCR_Init"); - priv_data->scr_verify_pin = GetProcAddress(dll, "SCR_VerifyPIN"); - priv_data->scr_change_pin = GetProcAddress(dll, "SCR_ChangePIN"); - if (priv_data->scr_init == NULL || priv_data->scr_verify_pin == NULL) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Function not found in \"%s\" err = 0x%0x\n", - pp_reader_lib, GetLastError()); - load_pin_pad_err(reader_name, pp_reader_lib, - "unsufficient functionality found in library"); - return SC_ERROR_READER; - } - r = priv_data->scr_init(reader_name, 1, &supported); - if (r != SCARD_S_SUCCESS) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SCR_Init() returned 0x%0x\n", r); - load_pin_pad_err(reader_name, pp_reader_lib, "Initialization of library failed"); - return SC_ERROR_READER; - } - if (supported) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SCR_init() returned not supported code 0x%0x\n", supported); - load_pin_pad_err(reader_name, pp_reader_lib, - "Initialization of library returned UNSUPPORTED"); - return SC_ERROR_READER; - } -#endif return 1; } @@ -1051,9 +989,6 @@ static int belpic_read_binary(sc_card_t *card, dur = t2 - t1; tot_dur += dur; tot_read += r; -#if 0 - printf("%d bytes: %d ms - %d bytes total: %d ms\n", r, dur, tot_read, tot_dur); -#endif return r; } @@ -1062,9 +997,6 @@ static int belpic_read_binary(sc_card_t *card, /* Test the result code of the pin pad reader + the card's status bytes */ static int belpic_pp_test_res(sc_card_t *card, int r, const u8 * card_status, int *tries_left) { -#if 0 - printf("PP res: 0x%0x (%d), SW1-SW2 = %02x %02x\n", r, r, card_status[0], card_status[1]); -#endif if (r != SCARD_S_SUCCESS) { switch (r) { case SCARD_E_CANCELLED: @@ -1136,10 +1068,6 @@ static int belpic_pp_verify(sc_card_t *card, SCR_Card * scr_card, scgui_display_message(app_msg[lang], pp_msg_login_sh, pp_msg_login, NULL, &hDlg, icon, reader_name); } -#if 0 - printf("belpic_pp_verify(): reader=%s, hCard=0x%0x\n", card->reader->name, - scr_card->hCard); -#endif r = priv->scr_verify_pin(priv->szPinPadDll, scr_card, pin_ref, &scr_pin_usage, &scr_app_belpic, card_status); if (mesg_on_screen) @@ -1470,25 +1398,6 @@ static int belpic_update_binary(sc_card_t *card, return r; } -#if 0 -static int belpic_logout(sc_card_t *card) -{ - sc_apdu_t apdu; - int r; - - sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE6, 0x00, 0x00); - apdu.cla = 0x80; - - r = sc_transmit_apdu(card, &apdu); - SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "LOGOFF: APDU transmit failed"); - - r = sc_check_sw(card, apdu.sw1, apdu.sw2); - SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "LOGOFF returned error"); - - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); -} -#endif - static struct sc_card_driver *sc_get_driver(void) { if (iso_ops == NULL) diff --git a/src/libopensc/card-epass2003.c b/src/libopensc/card-epass2003.c index a07f7474..f3d79477 100644 --- a/src/libopensc/card-epass2003.c +++ b/src/libopensc/card-epass2003.c @@ -591,31 +591,6 @@ construct_mac_tlv(unsigned char *apdu_buf, size_t data_tlv_len, size_t le_tlv_le return 0; } -#if 0 -static size_t calc_le(size_t le) -{ - size_t le_new = 0; - size_t resp_len = 0; - size_t sw_len = 4; /* T 1 L 1 V 2 */ - size_t mac_len = 10; /* T 1 L 1 V 8 */ - size_t mod = 16; - /* padding first */ - resp_len = 1 + ((le + (mod - 1)) / mod) * mod; - - if (0x7f < resp_len) { - resp_len += 0; - - } else if (0x7f <= resp_len && resp_len < 0xff) { - resp_len += 1; - } else if (0xff <= resp_len) { - resp_len += 2; - } - resp_len += 2; /* +T+L */ - le_new = resp_len + sw_len + mac_len; - return le_new; -} -#endif - /* According to GlobalPlatform Card Specification's SCP01 * encode APDU from diff --git a/src/libopensc/card-flex.c b/src/libopensc/card-flex.c index 64d9381a..ff4c5085 100644 --- a/src/libopensc/card-flex.c +++ b/src/libopensc/card-flex.c @@ -259,22 +259,6 @@ add_acl_entry(sc_card_t *card, sc_file_t *file, unsigned int op, u8 nibble) static int cryptoflex_get_ac_keys(sc_card_t *card, sc_file_t *file) { -#if 0 - sc_apdu_t apdu; - u8 rbuf[3]; - int r; - - sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xC4, 0x00, 0x00); - apdu.cla = 0xF0 /* 0x00 for Cyberflex */; - apdu.le = 3; - apdu.resplen = 3; - apdu.resp = rbuf; - r = sc_transmit_apdu(card, &apdu); - SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); - if (apdu.sw1 != 0x90 && apdu.sw2 != 0x00) - return 0; - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "AC Keys: %02X %02X %02X\n", rbuf[0], rbuf[1], rbuf[2]); -#endif return 0; } @@ -337,10 +321,6 @@ cryptoflex_process_file_attrs(sc_card_t *card, sc_file_t *file, add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F)); break; case SC_FILE_EF_CYCLIC: -#if 0 - /* FIXME */ - file->acl[SC_AC_OP_DECREASE] = ac_to_acl(p[0] & 0x0F); -#endif break; } } @@ -431,9 +411,6 @@ cyberflex_process_file_attrs(sc_card_t *card, sc_file_t *file, file->ef_structure = SC_FILE_EF_CYCLIC; break; case 0x04: -#if 0 - file->ef_structure = SC_FILE_EF_PROGRAM; -#endif break; default: sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "invalid file type: 0x%02X\n", *p); @@ -448,10 +425,6 @@ cyberflex_process_file_attrs(sc_card_t *card, sc_file_t *file, add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(pos[0] & 0x0F)); break; case SC_FILE_EF_CYCLIC: -#if 0 - /* FIXME */ - file->acl[SC_AC_OP_DECREASE] = ac_to_acl(pos[0] & 0x0F); -#endif break; } } diff --git a/src/libopensc/card-gpk.c b/src/libopensc/card-gpk.c index 0ffed379..2b44884b 100644 --- a/src/libopensc/card-gpk.c +++ b/src/libopensc/card-gpk.c @@ -219,47 +219,6 @@ gpk_finish(sc_card_t *card) return 0; } -/* - * Error code handling for the GPK4000. - * sc_check_sw doesn't seem to handle all of the - * status words the GPK is capable of returning - */ -#if 0 -static int -gpk_check_sw(sc_card_t *card, u8 sw1, u8 sw2) -{ - unsigned short int sw = (sw1 << 8) | sw2; - - if ((sw & 0xFFF0) == 0x63C0) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "wrong PIN, %u tries left\n", sw&0xf); - return SC_ERROR_PIN_CODE_INCORRECT; - } - - switch (sw) { - case 0x6400: - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "wrong crypto context\n"); - return SC_ERROR_OBJECT_NOT_VALID; /* XXX ??? */ - - /* The following are handled by iso7816_check_sw - * but all return SC_ERROR_UNKNOWN_DATA_RECEIVED - * XXX: fix in the iso driver? */ - case 0x6983: - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIN is blocked\n"); - return SC_ERROR_PIN_CODE_INCORRECT; - case 0x6581: - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "out of space on card or file\n"); - return SC_ERROR_OUT_OF_MEMORY; - case 0x6981: - return SC_ERROR_FILE_NOT_FOUND; - case 0x6A80: - case 0x6b00: - return SC_ERROR_INVALID_ARGUMENTS; - } - - return iso7816_check_sw(card, sw1, sw2); -} -#endif - /* * Select a DF/EF */ @@ -1283,14 +1242,7 @@ gpk_compute_signature(sc_card_t *card, const u8 *data, apdu.cse = SC_APDU_CASE_2_SHORT; apdu.cla = 0x80; apdu.ins = 0x86; -#if 0 - /* Don't know why I did this. It conflicts with the spec - * (but it worked with the gpk4k, strange). --okir */ - apdu.p1 = priv->sec_padding; - apdu.p2 = priv->sec_mod_len; -#else apdu.p2 = priv->sec_padding; -#endif apdu.resp= cardsig; apdu.resplen = sizeof(cardsig); apdu.le = priv->sec_mod_len; @@ -1626,33 +1578,6 @@ gpk_get_default_key(sc_card_t *card, struct sc_cardctl_default_key *data) return SC_ERROR_NO_DEFAULT_KEY; } -/* - * Get the maximum size of a session key the card is - * willing to decrypt - */ -#if 0 -static int -gpk_max_session_key(sc_card_t *card) -{ - struct gpk_private_data *priv = DRVDATA(card); - sc_path_t path; - u8 value; - int r; - - if (priv->max_session_key) - return priv->max_session_key; - - /* GPK cards limit the amount of data they're willing - * to RSA decrypt. This data is stored in EFMaxSessionKey */ - sc_format_path("01000001", &path); - if ((r = sc_select_file(card, &path, NULL)) < 0 - || (r = sc_read_binary(card, 0, &value, 1, 0)) < 0) - return r; - priv->max_session_key = value; - return value; -} -#endif - /* * GetInfo call */ diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c index 25e1b7ef..2a9dbe3f 100644 --- a/src/libopensc/card-oberthur.c +++ b/src/libopensc/card-oberthur.c @@ -253,20 +253,6 @@ auth_init(struct sc_card *card) _sc_card_add_rsa_alg(card, 512, flags, 0); _sc_card_add_rsa_alg(card, 1024, flags, 0); _sc_card_add_rsa_alg(card, 2048, flags, 0); -#if 0 - flags = SC_ALGORITHM_SKEY_CBC | SC_ALGORITHM_SKEY_ECB; - memset(&info, 0, sizeof(info)); - info.algorithm = SC_ALGORITHM_DES; - info.flags = flags; - info.key_length = 64; - _sc_card_add_algorithm(card, &info); - - flags = SC_ALGORITHM_SKEY_CBC | SC_ALGORITHM_SKEY_ECB; - info.algorithm = SC_ALGORITHM_3DES; - info.flags = flags; - info.key_length = 192; - _sc_card_add_algorithm(card, &info); -#endif sc_format_path("3F00", &path); rv = auth_select_file(card, &path, NULL); @@ -1200,17 +1186,6 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen, apdu.cla &= ~0x10; } -#if 0 - case SC_ALGORITHM_DES: - case SC_ALGORITHM_3DES: - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"algorithm SC_ALGORITHM_DES\n"); - if (crgram_len == 0 || (crgram_len%8) != 0) { - rv = SC_ERROR_INVALID_ARGUMENTS; - goto done; - } - break; -#endif - apdu.data = in; apdu.datalen = _inlen; apdu.resp = resp; diff --git a/src/libopensc/card-piv.c b/src/libopensc/card-piv.c index 017cdcaf..2ed391dc 100644 --- a/src/libopensc/card-piv.c +++ b/src/libopensc/card-piv.c @@ -177,12 +177,6 @@ static struct piv_aid piv_aids[] = { {0, 9, 0, NULL } }; -/* The EC curves supported by PIV */ -#if 0 -static u8 oid_prime256v1[] = {"\x06\x08\x2a\x86\x48\xce\x3d\x03\x01\x07"}; -static u8 oid_secp384r1[] = {"\x06\x05\x2b\x81\x04\x00\x22"}; -#endif - /* * Flags in the piv_object: * PIV_OBJECT_NOT_PRESENT: the presents of the object is diff --git a/src/libopensc/card-setcos.c b/src/libopensc/card-setcos.c index 3f30101e..3e5d499f 100644 --- a/src/libopensc/card-setcos.c +++ b/src/libopensc/card-setcos.c @@ -159,11 +159,6 @@ static int setcos_init(sc_card_t *card) /* Handle unknown or forced cards */ if (card->type < 0) { card->type = SC_CARD_TYPE_SETCOS_GENERIC; -#if 0 - /* Hmm. For now, assume it's a bank card with FinEID application */ - if (match_hist_bytes(card, "AVANT", 0)) - card->type = SC_CARD_TYPE_SETCOS_FINEID_V2; -#endif } switch (card->type) { diff --git a/src/libopensc/ctbcs.c b/src/libopensc/ctbcs.c index c76e2cf4..3dc773df 100644 --- a/src/libopensc/ctbcs.c +++ b/src/libopensc/ctbcs.c @@ -40,45 +40,6 @@ ctbcs_init_apdu(sc_apdu_t *apdu, int cse, int ins, int p1, int p2) apdu->control = 1; } -#if 0 -static int -ctbcs_build_input_apdu(sc_apdu_t *apdu, int echo, const char *prompt, - u8 *rbuf, size_t rbuflen) -{ - ctbcs_init_apdu(apdu, SC_APDU_CASE_2_SHORT, - CTBCS_INS_INPUT, - CTBCS_P1_KEYPAD, - echo? CTBCS_P2_INPUT_ECHO : CTBCS_P2_INPUT_ASTERISKS); - - if (prompt && *prompt) { - apdu->cse = SC_APDU_CASE_4_SHORT; - apdu->data = (u8 *) prompt; - apdu->lc = apdu->datalen = strlen(prompt); - } - - apdu->le = apdu->resplen = rbuflen; - apdu->resp = rbuf; - return 0; -} - -static int -ctbcs_build_output_apdu(sc_apdu_t *apdu, const char *message) -{ - ctbcs_init_apdu(apdu, - SC_APDU_CASE_3_SHORT, - CTBCS_INS_INPUT, - CTBCS_P1_DISPLAY, - 0); - - if (!message || !*message) - message = " "; - - apdu->lc = apdu->datalen = strlen(message); - - return 0; -} -#endif - static int ctbcs_build_perform_verification_apdu(sc_apdu_t *apdu, struct sc_pin_cmd_data *data) { diff --git a/src/libopensc/cwa14890.c b/src/libopensc/cwa14890.c index c7c23cae..dbbd599b 100644 --- a/src/libopensc/cwa14890.c +++ b/src/libopensc/cwa14890.c @@ -1462,21 +1462,6 @@ int cwa_encode_apdu(sc_card_t * card, memcpy(to, from, sizeof(sc_apdu_t)); return SC_SUCCESS; /* dont encode GET Response cmd */ } -#if 0 - /* For testing results according DNIe manual */ - u8 kenc[16] = - { 0x59, 0x8f, 0x26, 0xe3, 0x6e, 0x11, 0xa8, 0xec, 0x14, 0xb8, 0x1e, - 0x19, 0xbd, 0xa2, 0x23, 0xca }; - u8 kmac[16] = - { 0x5d, 0xe2, 0x93, 0x9a, 0x1e, 0xa0, 0x3a, 0x93, 0x0b, 0x88, 0x20, - 0x6d, 0x8f, 0x73, 0xe8, 0xa7 }; - u8 ssc[8] = { 0xd3, 0x1a, 0xc8, 0xec, 0x7b, 0xa0, 0xfe, 0x74 }; - memcpy(sm->kenc, kenc, 16); - memcpy(sm->kmac, kmac, 16); - memcpy(sm->ssc, ssc, 16); - from->le = 0; - /* para debugging end */ -#endif /* call provider pre-operation method */ if (provider->cwa_encode_pre_ops) { diff --git a/src/libopensc/muscle.c b/src/libopensc/muscle.c index 74627ca5..ef9322f2 100644 --- a/src/libopensc/muscle.c +++ b/src/libopensc/muscle.c @@ -680,63 +680,6 @@ int msc_compute_crypt_init(sc_card_t *card, SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); } -#if 0 -int msc_compute_crypt_process( - sc_card_t *card, - int keyLocation, - const u8* inputData, - u8* outputData, - size_t dataLength, - size_t* outputDataLength) -{ - sc_apdu_t apdu; - u8 buffer[MSC_MAX_APDU]; - u8 outputBuffer[MSC_MAX_APDU]; - u8 *ptr; - int r; - - if(dataLength > MSC_MAX_SEND - 3) - return SC_ERROR_INVALID_ARGUMENTS; - - sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x36, keyLocation, 0x02); /* Process */ - - apdu.data = buffer; - apdu.datalen = dataLength + 3; - apdu.lc = dataLength + 3; -/* Specs say crypt returns data all the time??? But... its not implemented that way */ - - memset(outputBuffer, 0, sizeof(outputBuffer)); - apdu.resp = outputBuffer; - apdu.resplen = MSC_MAX_READ; - apdu.le = dataLength; - ptr = buffer; - *ptr = 0x01; ptr++; /* DATA LOCATION: APDU */ - *ptr = (dataLength >> 8) & 0xFF; ptr++; - *ptr = dataLength & 0xFF; ptr++; - memcpy(ptr, inputData, dataLength); - - r = sc_transmit_apdu(card, &apdu); - SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed"); - if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) { - short receivedData = outputBuffer[0] << 8 | outputBuffer[1]; - *outputDataLength = receivedData; - *outputDataLength = 0; - assert(receivedData <= MSC_MAX_APDU); - memcpy(outputData, outputBuffer + 2, receivedData); - return 0; - } - r = sc_check_sw(card, apdu.sw1, apdu.sw2); - if (r) { - if (card->ctx->debug >= 2) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "process: got strange SWs: 0x%02X 0x%02X\n", - apdu.sw1, apdu.sw2); - } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); - } - SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_CARD_CMD_FAILED); -} -#endif - int msc_compute_crypt_final( sc_card_t *card, int keyLocation, diff --git a/src/libopensc/pkcs15-atrust-acos.c b/src/libopensc/pkcs15-atrust-acos.c index a3257d17..f59539bb 100644 --- a/src/libopensc/pkcs15-atrust-acos.c +++ b/src/libopensc/pkcs15-atrust-acos.c @@ -112,9 +112,6 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card) { const cdata certs[] = { {"C.CH.EKEY", 0, "DF71C001","1", 0},/* Decryption Certificate */ -#if 0 - {"C.CH.DS", 0, "DF70C002","2", 0},/* Signature Certificate */ -#endif {NULL, 0, NULL, NULL, 0} }; @@ -124,18 +121,6 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card) 4, 4, 8, SC_PKCS15_PIN_FLAG_NEEDS_PADDING | SC_PKCS15_PIN_FLAG_LOCAL, -1, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE }, -#if 0 - { "02", "PIN.SIG", "3F00DF70", 0x81, /* Signature PIN */ - SC_PKCS15_PIN_TYPE_ASCII_NUMERIC, - 6, 6, 8, SC_PKCS15_PIN_FLAG_NEEDS_PADDING | - SC_PKCS15_PIN_FLAG_LOCAL, -1, 0x00, - SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE }, - { "03", "PIN.INF", "3F00DF71", 0x83, /* Infobox PIN */ - SC_PKCS15_PIN_TYPE_ASCII_NUMERIC, - 4, 4, 8, SC_PKCS15_PIN_FLAG_NEEDS_PADDING | - SC_PKCS15_PIN_FLAG_LOCAL, -1, 0x00, - SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE }, -#endif { NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; @@ -144,12 +129,6 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card) SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP, "", /* do not specify file here to prevent reset of security state */ 0x88, "01", SC_PKCS15_CO_FLAG_PRIVATE}, -#if 0 - { "2", "SK.CH.DS", 192, - SC_PKCS15_PRKEY_USAGE_SIGN, - "", /* do not specify file here to prevent reset of security state */ - 0x88, "02", SC_PKCS15_CO_FLAG_PRIVATE}, -#endif { NULL, NULL, 0, 0, NULL, 0, NULL, 0} }; diff --git a/src/libopensc/pkcs15-gemsafeV1.c b/src/libopensc/pkcs15-gemsafeV1.c index 2a8c3cca..aa928421 100644 --- a/src/libopensc/pkcs15-gemsafeV1.c +++ b/src/libopensc/pkcs15-gemsafeV1.c @@ -599,29 +599,4 @@ sc_pkcs15emu_add_prkey(sc_pkcs15_card_t *p15card, info, auth_id, obj_flags); } -#if 0 -static int -sc_pkcs15emu_add_pubkey(sc_pkcs15_card_t *p15card, - const sc_pkcs15_id_t *id, - const char *label, int type, - unsigned int modulus_length, int usage, - const sc_path_t *path, int ref, - const sc_pkcs15_id_t *auth_id, int obj_flags) -{ - sc_pkcs15_pubkey_info_t *info; - - info = calloc(1, sizeof(*info)); - info->id = *id; - info->modulus_length = modulus_length; - info->usage = usage; - info->access_flags = SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE; - info->key_reference = ref; - - if (path) - info->path = *path; - - return sc_pkcs15emu_add_object(p15card, type, label, info, auth_id, obj_flags); -} -#endif - /* SC_IMPLEMENT_DRIVER_VERSION("0.9.4") */ diff --git a/src/libopensc/pkcs15-skey.c b/src/libopensc/pkcs15-skey.c index 0749e3e3..353226ce 100644 --- a/src/libopensc/pkcs15-skey.c +++ b/src/libopensc/pkcs15-skey.c @@ -137,60 +137,5 @@ int sc_pkcs15_encode_skdf_entry(struct sc_context *ctx, const struct sc_pkcs15_object *obj, u8 **buf, size_t *buflen) { -#if 0 - struct sc_asn1_entry asn1_com_key_attr[6], asn1_com_skey_attr[1]; - struct sc_asn1_entry asn1_skey_des_attr[4], asn1_skey_des_type_attr[2]; - struct sc_asn1_entry asn1_skey_choice[5]; - struct sc_asn1_entry asn1_skey[2]; - struct sc_pkcs15_skey_info *skey = (struct sc_pkcs15_skey_info *) obj->data; - struct sc_asn1_pkcs15_object skey_des_obj = { - (struct sc_pkcs15_object *) obj, - asn1_com_key_attr, - asn1_com_skey_attr, - asn1_skey_des_type_attr - }; - int r; - size_t af_len, usage_len; - - sc_copy_asn1_entry(c_asn1_skey, asn1_skey); - sc_copy_asn1_entry(c_asn1_skey_choice, asn1_skey_choice); - sc_copy_asn1_entry(c_asn1_skey_des_type_attr, asn1_skey_des_type_attr); - sc_copy_asn1_entry(c_asn1_skey_des_attr, asn1_skey_des_attr); - sc_copy_asn1_entry(c_asn1_com_skey_attr, asn1_com_skey_attr); - sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr); - - switch (obj->type) { - case SC_PKCS15_TYPE_SKEY_DES: - case SC_PKCS15_TYPE_SKEY_2DES: - case SC_PKCS15_TYPE_SKEY_3DES: - sc_format_asn1_entry(asn1_skey_choice + 0, &skey_des_obj, NULL, 1); - - sc_format_asn1_entry(asn1_skey_des_type_attr + 0, asn1_skey_des_attr, NULL, 1); - - sc_format_asn1_entry(asn1_skey_des_attr + 0, &skey->path, NULL, 1); - sc_format_asn1_entry(asn1_skey_des_attr + 1, &skey->type, NULL, 1); - sc_format_asn1_entry(asn1_skey_des_attr + 2, &skey->size, NULL, 1); - break; - - default: - sc_log(ctx, "Unsupported skey type: %X\n", obj->type); - LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL); - break; - } - - sc_format_asn1_entry(asn1_com_key_attr + 0, &skey->id, NULL, 1); - usage_len = sizeof(skey->usage); - sc_format_asn1_entry(asn1_com_key_attr + 1, &skey->usage, &usage_len, 1); - if (skey->access_flags) { - af_len = sizeof(skey->access_flags); - sc_format_asn1_entry(asn1_com_key_attr + 3, &skey->access_flags, &af_len, 1); - } - sc_format_asn1_entry(asn1_skey + 0, asn1_skey_choice, NULL, 1); - - r = sc_asn1_encode(ctx, asn1_skey, buf, buflen); - - return r; -#else LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); -#endif } diff --git a/src/libopensc/reader-ctapi.c b/src/libopensc/reader-ctapi.c index c85c560f..a3d0cce1 100644 --- a/src/libopensc/reader-ctapi.c +++ b/src/libopensc/reader-ctapi.c @@ -256,26 +256,6 @@ static int ctapi_connect(sc_reader_t *reader) memcpy(reader->atr.value, rbuf, lr); r = _sc_parse_atr(reader); -#if 0 - if (reader->atr_info.Fi > 0) { - /* Perform PPS negotiation */ - cmd[1] = CTBCS_INS_RESET; - cmd[4] = 0x03; - cmd[5] = 0xFF; - cmd[6] = 0x10; - cmd[7] = (reader->atr_info.FI << 4) | reader->atr_info.DI; - cmd[8] = 0x00; - dad = 1; - sad = 2; - lr = 256; - - rv = priv->funcs.CT_data(priv->ctn, &dad, &sad, 9, cmd, &lr, rbuf); - if (rv) { - sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "Error negotiating PPS: %d\n", rv); - return SC_ERROR_TRANSMIT_FAILED; - } - } -#endif return 0; } diff --git a/src/pkcs11/framework-pkcs15.c b/src/pkcs11/framework-pkcs15.c index 79c0bdee..4f25d287 100644 --- a/src/pkcs11/framework-pkcs15.c +++ b/src/pkcs11/framework-pkcs15.c @@ -981,12 +981,6 @@ pkcs15_init_slot(struct sc_pkcs15_card *p15card, struct sc_pkcs11_slot *slot, slot->token_info.ulMinPinLen = 4; } -#if 0 -FIXME: configurable option - if (p15card->flags & SC_PKCS15_CARD_FLAG_EMULATED) - slot->token_info.flags |= CKF_WRITE_PROTECTED; -#endif - slot->app_info = app_info; sc_log(context, "Initialized token '%s' in slot 0x%lx", label, slot->id); } @@ -1384,14 +1378,8 @@ pkcs15_create_tokens(struct sc_pkcs11_card *p11card, struct sc_app_info *app_inf static CK_RV pkcs15_release_token(struct sc_pkcs11_card *p11card, void *fw_token) { -#if 0 - unlock_card((struct pkcs15_fw_data *) p11card->fws_data[0]); - free(fw_token); - return CKR_OK; -#else sc_log(context, "pkcs15_release_token() not implemented"); return CKR_FUNCTION_REJECTED; -#endif } @@ -1468,16 +1456,6 @@ pkcs15_login(struct sc_pkcs11_slot *slot, CK_USER_TYPE userType, rc = 0; if (sc_pkcs11_conf.lock_login) rc = lock_card(fw_data); -#if 0 - /* TODO: Look for pkcs15 auth object with 'unblockingPin' flag activated. - * If exists, do verification of PIN (in fact PUK). */ - if (sc_pkcs11_conf.pin_unblock_style == SC_PKCS11_PIN_UNBLOCK_SCONTEXT_SETPIN) { - if (ulPinLen && ulPinLen < sizeof(fw_data->user_puk)) { - memcpy(fw_data->user_puk, pPin, ulPinLen); - fw_data->user_puk_len = ulPinLen; - } - } -#endif sc_log(context, "context specific login returns %d", rc); return sc_to_cryptoki_error(rc, "C_Login"); default: @@ -2106,12 +2084,6 @@ pkcs15_create_secret_key(struct sc_pkcs11_slot *slot, struct sc_profile *profile fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx]; if (!fw_data) return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_CreateObject"); -#if 0 - /* See if the "slot" is pin protected. If so, get the - * PIN id */ - if ((pin = slot_data_auth_info(slot->fw_data)) != NULL) - args.auth_id = pin->auth_id; -#endif /* Get the key type */ rv = attr_find(pTemplate, ulCount, CKA_KEY_TYPE, &key_type, NULL); @@ -3558,20 +3530,6 @@ pkcs15_prkey_sign(struct sc_pkcs11_session *session, void *obj, case CKM_ECDSA_SHA1: flags = SC_ALGORITHM_ECDSA_HASH_SHA1; break; -#if 0 - case CKM_ECDSA_SHA224: - flags = SC_ALGORITHM_ECDSA_HASH_SHA224; - break; - case CKM_ECDSA_SHA256: - flags = SC_ALGORITHM_ECDSA_HASH_SHA256; - break; - case CKM_ECDSA_SHA384: - flags = SC_ALGORITHM_ECDSA_HASH_SHA384; - break; - case CKM_ECDSA_SHA512: - flags = SC_ALGORITHM_ECDSA_HASH_SHA512; - break; -#endif default: sc_log(context, "DEE - need EC for %d",pMechanism->mechanism); return CKR_MECHANISM_INVALID; @@ -4224,43 +4182,6 @@ pkcs15_skey_set_attribute(struct sc_pkcs11_session *session, return CKR_OK; } -#if 0 -static int pkcs15_skey_get_value(struct sc_pkcs11_session *session, - struct pkcs15_skey_object *skey, - struct sc_pkcs15_skey **out_data) -{ - int rv; - struct sc_pkcs15_skey * skey_data = NULL; - struct pkcs15_fw_data *fw_data = - (struct pkcs15_fw_data *) session->slot->card->fw_data; - sc_card_t *card = session->slot->card->card; - - if (!out_data) - return SC_ERROR_INVALID_ARGUMENTS; - - /*TODO could try and read extractable secret keys - * but for now we only work with session objects - * derived from other keys - */ - skey_data= calloc(1, sizeof(struct sc_pkcs15_skey)); - if (skey_data == NULL) - return SC_ERROR_OUT_OF_MEMORY; - - if (skey->value && skey->value->data_len) { - skey_data->data = calloc(1, skey_data->data_len); - if (skey_data->data == NULL) { - free(skey_data); - return SC_ERROR_OUT_OF_MEMORY; - } - skey_data->data_len = skey->value->data_len; - memcpy(skey_data->data, skey->value->data, skey->value->data_len); - return 0; - } - *out_data = skey_data; - return 0; -} -#endif - static CK_RV pkcs15_skey_get_attribute(struct sc_pkcs11_session *session, diff --git a/src/pkcs11/pkcs11-object.c b/src/pkcs11/pkcs11-object.c index d1c43803..1be59d9b 100644 --- a/src/pkcs11/pkcs11-object.c +++ b/src/pkcs11/pkcs11-object.c @@ -113,13 +113,6 @@ CK_RV sc_create_object_int(CK_SESSION_HANDLE hSession, /* the session's handle * goto out; } -#if 0 -/* TODO DEE what should we check here */ - if (!(session->flags & CKF_RW_SESSION)) { - rv = CKR_SESSION_READ_ONLY; - goto out; - } -#endif card = session->slot->card; if (card->framework->create_object == NULL) rv = CKR_FUNCTION_NOT_SUPPORTED; @@ -1188,10 +1181,6 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession, /* the session's handle */ #ifndef ENABLE_OPENSSL return CKR_FUNCTION_NOT_SUPPORTED; #else -#if 0 - CK_BBOOL can_verify; - CK_ATTRIBUTE verify_attribute = { CKA_VERIFY, &can_verify, sizeof(can_verify) }; -#endif CK_KEY_TYPE key_type; CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE, &key_type, sizeof(key_type) }; CK_RV rv; @@ -1212,13 +1201,6 @@ CK_RV C_VerifyInit(CK_SESSION_HANDLE hSession, /* the session's handle */ rv = CKR_KEY_HANDLE_INVALID; goto out; } -#if 0 - rv = object->ops->get_attribute(session, object, &verify_attribute); - if (rv != CKR_OK || !can_verify) { - rv = CKR_KEY_TYPE_INCONSISTENT; - goto out; - } -#endif rv = object->ops->get_attribute(session, object, &key_type_attr); if (rv != CKR_OK) { rv = CKR_KEY_TYPE_INCONSISTENT; diff --git a/src/pkcs15init/pkcs15-asepcos.c b/src/pkcs15init/pkcs15-asepcos.c index 547b48f6..310c6f92 100644 --- a/src/pkcs15init/pkcs15-asepcos.c +++ b/src/pkcs15init/pkcs15-asepcos.c @@ -245,11 +245,7 @@ static int asepcos_do_store_pin(sc_profile_t *profile, sc_card_t *card, *p++ = 0x00; *p++ = 0x00; /* key attributes (SO PIN) */ -#if 0 - *p++ = (pinfo->flags & SC_PKCS15_PIN_FLAG_SO_PIN) ? 0x08 : 0x00; -#else *p++ = 0x00; -#endif /* the PIN */ *p++ = 0x81; *p++ = pinlen & 0xff; @@ -598,12 +594,6 @@ static int asepcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, } afileid = st.fileid; } -#if 0 - /* select the DF */ - r = sc_select_file(card, &profile->df_info->file->path, NULL); - if (r != SC_SUCCESS) - return r; -#endif /* authenticate if necessary */ r = asepcos_do_authenticate(profile, p15card, &profile->df_info->file->path, SC_AC_OP_CREATE); @@ -615,19 +605,11 @@ static int asepcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, *p++ = 0xc1; *p++ = 0x82; p += 2; -#if 0 - /* private exponent */ - *p++ = 0x92; - SET_TLV_LENGTH(p, blen); - memset(p, 0xff, blen); - p += blen; -#else /* public exponent */ *p++ = 0x90; SET_TLV_LENGTH(p, 3); memset(p, 0xff, 3); p += 3; -#endif /* primes p, q */ *p++ = 0x93; SET_TLV_LENGTH(p, blen); @@ -700,19 +682,11 @@ static int asepcos_do_store_rsa_key(sc_pkcs15_card_t *p15card, sc_profile_t *pro *p++ = 0xc1; *p++ = 0x82; p += 2; -#if 0 - /* private exponent */ - *p++ = 0x92; - SET_TLV_LENGTH(p, key->d.len); - memcpy(p, key->d.data, key->d.len); - p += key->d.len; -#else /* public exponent */ *p++ = 0x90; SET_TLV_LENGTH(p, key->exponent.len); memcpy(p, key->exponent.data, key->exponent.len); p += key->exponent.len; -#endif /* primes p, q */ *p++ = 0x93; SET_TLV_LENGTH(p, (key->p.len + key->q.len)); diff --git a/src/pkcs15init/pkcs15-cardos.c b/src/pkcs15init/pkcs15-cardos.c index 9d1f658c..160b975b 100644 --- a/src/pkcs15init/pkcs15-cardos.c +++ b/src/pkcs15init/pkcs15-cardos.c @@ -612,11 +612,7 @@ cardos_store_key_component(sc_card_t *card, tlv_add(&tlv, 0); /* rfu */ tlv_add(&tlv, 0); /* rfu */ tlv_add(&tlv, 0); /* rfu */ -#if 0 - tlv_add(&tlv, pin_id); /* AC GENKEY */ -#else tlv_add(&tlv, 0); -#endif #ifdef SET_SM_BYTES /* it shouldn't be necessary to set the default value */ diff --git a/src/pkcs15init/pkcs15-jcop.c b/src/pkcs15init/pkcs15-jcop.c index 9ff9dd38..b20e09f2 100644 --- a/src/pkcs15init/pkcs15-jcop.c +++ b/src/pkcs15init/pkcs15-jcop.c @@ -44,20 +44,6 @@ jcop_erase_card(struct sc_profile *pro, sc_pkcs15_card_t *p15card) { return SC_ERROR_NOT_SUPPORTED; } -#if 0 -/* - * Create a new DF - * This will usually be the application DF - * for JCOP, it must be the application DF. no other DF's may exist. - */ -static int -jcop_init_app(sc_profile_t *profile, sc_card_t *card, - struct sc_pkcs15_pin_info *pin_info, - const u8 *pin, size_t pin_len, const u8 *puk, size_t puk_len) { - return SC_ERROR_NOT_SUPPORTED; -} - -#else static int jcop_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *file) @@ -65,8 +51,6 @@ jcop_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *fil return SC_ERROR_NOT_SUPPORTED; }; -#endif - /* * Select a PIN reference diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c index 8587b8db..cac658c8 100644 --- a/src/pkcs15init/pkcs15-lib.c +++ b/src/pkcs15init/pkcs15-lib.c @@ -838,10 +838,6 @@ sc_pkcs15init_add_app(struct sc_card *card, struct sc_profile *profile, r = profile->ops->create_pin(profile, p15card, df, pin_obj, args->so_pin, args->so_pin_len, args->so_puk, args->so_puk_len); -#if 0 - if (r > 0 && profile->ops->finalize_dir) - r = profile->ops->finalize_dir(profile, p15card); -#endif if (pin_obj) /* Remove 'virtual' AUTH object . */ diff --git a/src/pkcs15init/pkcs15-oberthur.c b/src/pkcs15init/pkcs15-oberthur.c index 1c6e6e7f..34185987 100644 --- a/src/pkcs15init/pkcs15-oberthur.c +++ b/src/pkcs15init/pkcs15-oberthur.c @@ -228,24 +228,11 @@ cosm_create_dir(struct sc_profile *profile, struct sc_pkcs15_card *p15card, COSM_TITLE"-container-list", COSM_TITLE"-public-list", COSM_TITLE"-private-list", -#if 0 - "PKCS15-AppDF", - "PKCS15-ODF", - "PKCS15-AODF", - "PKCS15-PrKDF", - "PKCS15-PuKDF", - "PKCS15-CDF", - "PKCS15-DODF", -#endif NULL }; SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE); -#if 0 - rv = sc_pkcs15init_create_file(profile, p15card, df); - SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to create DIR DF"); -#endif /* Oberthur AWP file system is expected.*/ /* Create private objects DF */ for (ii = 0; create_dfs[ii]; ii++) { diff --git a/src/scconf/parse.c b/src/scconf/parse.c index a399f4ed..2a9aed3f 100644 --- a/src/scconf/parse.c +++ b/src/scconf/parse.c @@ -350,13 +350,6 @@ void scconf_parse_token(scconf_parser * parser, int token_type, const char *toke parser->state = STATE_VALUE; break; case ';': -#if 0 - if ((parser->state & STATE_VALUE) == 0 || - (parser->state & STATE_SET) == 0) { - scconf_parse_error_not_expect(parser, ";"); - break; - } -#endif scconf_parse_reset_state(parser); break; default: diff --git a/src/scconf/sclex.c b/src/scconf/sclex.c index c8bc05b9..b16db4b7 100644 --- a/src/scconf/sclex.c +++ b/src/scconf/sclex.c @@ -57,9 +57,6 @@ static void buf_addch(BUFHAN * bp, char ch) bp->bufmax += 256; bp->buf = (char *) realloc(bp->buf, bp->bufmax); } -#if 0 - printf("pushback %c\n", ch); -#endif bp->buf[bp->bufcur++] = ch; bp->buf[bp->bufcur] = '\0'; } diff --git a/src/smm/sm-card-authentic.c b/src/smm/sm-card-authentic.c index 8ebfbdc0..77fe1d71 100644 --- a/src/smm/sm-card-authentic.c +++ b/src/smm/sm-card-authentic.c @@ -38,9 +38,6 @@ #include "libopensc/opensc.h" #include "libopensc/log.h" -#if 0 -#include "libopensc/hash-strings.h" -#endif #include "sm-module.h" @@ -135,140 +132,6 @@ sm_authentic_encode_apdu(struct sc_context *ctx, struct sm_info *sm_info) } -#if 0 -static int -sm_authentic_get_apdu_read_binary(struct sc_context *ctx, struct sm_info *sm_info, - char *init_data, struct sc_remote_apdu **rapdus) -{ - struct sm_info_read_binary *rb = &sm_info->cmd_params.read_binary; - size_t offs = rb->offset, size = rb->size; - int rv = SC_ERROR_INVALID_ARGUMENTS; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM get 'READ BINARY' APDUs: offset:%i,size:%i", offs, size); - while (size) { - int sz = size > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : size; - struct sc_remote_apdu *rapdu = NULL; - - rv = sc_remote_apdu_allocate(rapdus, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'READ BINARY' APDUs: cannot allocate remote apdu"); - - rapdu->apdu.cse = SC_APDU_CASE_2_SHORT; - rapdu->apdu.cla = 0x00; - rapdu->apdu.ins = 0xB0; - rapdu->apdu.p1 = (offs>>8)&0xFF; - rapdu->apdu.p2 = offs&0xFF; - rapdu->apdu.resplen = sz; - rapdu->apdu.le = sz; - - rv = sm_gp_securize_apdu(ctx, sm_info, init_data, &rapdu->apdu); - LOG_TEST_RET(ctx, rv, "SM get 'READ BINARY' APDUs: securize error"); - - offs += sz; - size -= sz; - } - - LOG_FUNC_RETURN(ctx, rv); -} - - -static int -sm_authentic_get_apdu_update_binary(struct sc_context *ctx, struct sm_info *sm_info, - char *init_data, struct sc_remote_apdu **rapdus) -{ - struct sm_info_update_binary *ub = &sm_info->cmd_params.update_binary; - size_t offs = ub->offset, size = ub->size, data_offs = 0; - int rv = SC_ERROR_INVALID_ARGUMENTS; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM get 'UPDATE BINARY' APDUs: offset:%i,size:%i", offs, size); - while (size) { - int sz = size > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : size; - struct sc_remote_apdu *rapdu = NULL; - - rv = sc_remote_apdu_allocate(rapdus, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'UPDATE BINARY' APDUs: cannot allocate remote apdu"); - - rapdu->apdu.cse = SC_APDU_CASE_3_SHORT; - rapdu->apdu.cla = 0x00; - rapdu->apdu.ins = 0xD6; - rapdu->apdu.p1 = (offs>>8)&0xFF; - rapdu->apdu.p2 = offs&0xFF; - memcpy((unsigned char *)rapdu->apdu.data, ub->data + data_offs, sz); - rapdu->apdu.datalen = sz; - rapdu->apdu.lc = sz; - - rv = sm_gp_securize_apdu(ctx, sm_info, init_data, &rapdu->apdu); - LOG_TEST_RET(ctx, rv, "SM get 'READ BINARY' APDUs: securize error"); - - offs += sz; - data_offs += sz; - size -= sz; - } - - LOG_FUNC_RETURN(ctx, rv); -} - - -static int -sm_authentic_get_apdu_create_file(struct sc_context *ctx, struct sm_info *sm_info, - char *init_data, struct sc_remote_apdu **rapdus) -{ - struct sm_info_create_file *cf = &sm_info->cmd_params.create_file; - struct sc_remote_apdu *rapdu = NULL; - int rv; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM get 'CREATE FILE' APDU: FCP(%i) %p", cf->fcp_len, cf->fcp); - - rv = sc_remote_apdu_allocate(rapdus, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'CREATE FILE' APDU: cannot allocate remote apdu"); - - rapdu->apdu.cse = SC_APDU_CASE_3_SHORT; - rapdu->apdu.cla = 0x00; - rapdu->apdu.ins = 0xE0; - rapdu->apdu.p1 = 0x00; - rapdu->apdu.p2 = 0x00; - memcpy((unsigned char *)rapdu->apdu.data, cf->fcp, cf->fcp_len); - rapdu->apdu.datalen = cf->fcp_len; - rapdu->apdu.lc = cf->fcp_len; - - rv = sm_gp_securize_apdu(ctx, sm_info, init_data, &rapdu->apdu); - LOG_TEST_RET(ctx, rv, "SM get 'CREATE FILE' APDU: securize error"); - - LOG_FUNC_RETURN(ctx, rv); -} - -static int -sm_authentic_get_apdu_release(struct sc_context *ctx, struct sm_info *sm_info, - char *init_data, struct sc_remote_data *rdata) -{ - struct sc_remote_apdu *rapdu = NULL; - int rv; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM get 'SM RELEASE' APDU"); - - if (!rdata || !rdata->alloc) - LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "SM get 'SM RELEASE' APDU: invalid remote data"); - - rv = rdata->alloc(rdata, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'SM RELEASE' APDU: cannot allocate remote apdu"); - - rapdu->apdu.cse = SC_APDU_CASE_1; - rapdu->apdu.cla = 0x00; - rapdu->apdu.ins = 0x20; - rapdu->apdu.p1 = 0x00; - rapdu->apdu.p2 = 0xC0; - - rv = sm_gp_securize_apdu(ctx, sm_info, init_data, &rapdu->apdu); - LOG_TEST_RET(ctx, rv, "SM get 'SM RELEASE' APDUs: securize error"); - - LOG_FUNC_RETURN(ctx, rv); -} -#endif - - int sm_authentic_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, unsigned char *init_data, size_t init_len, struct sc_remote_data *rdata, @@ -289,32 +152,6 @@ sm_authentic_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, } switch (sm_info->cmd) { -#if 0 - case SM_CMD_FILE_READ: - rv = sm_authentic_get_apdu_read_binary(ctx, sm_info, init_data, &rapdus); - LOG_TEST_RET(ctx, rv, "SM get APDUs: add 'READ BINARY' failed"); - break; - case SM_CMD_FILE_UPDATE: - rv = sm_authentic_get_apdu_update_binary(ctx, sm_info, init_data, &rapdus); - LOG_TEST_RET(ctx, rv, "SM get APDUs: add 'UPDATE BINARY' failed"); - break; - case SM_CMD_FILE_CREATE: - rv = sm_authentic_get_apdu_create_file(ctx, sm_info, init_data, &rapdus); - LOG_TEST_RET(ctx, rv, "SM get APDUs: add 'FILE CREATE' failed"); - break; - case SM_CMD_PIN_VERIFY: - rv = sm_authentic_get_apdu_verify_pin(ctx, sm_info, init_data, &rapdus); - LOG_TEST_RET(ctx, rv, "SM get APDUs: add 'VERIFY PIN' failed"); - break; - case SM_CMD_PIN_RESET: - break; - case SM_CMD_PIN_CREATE: - break; - case SM_CMD_RSA_GENERATE: - break; - case SM_CMD_RSA_UPDATE: - break; -#endif case SM_CMD_APDU_TRANSMIT: rv = sm_authentic_encode_apdu(ctx, sm_info); LOG_TEST_RET(ctx, rv, "SM get APDUs: cannot encode APDU"); @@ -325,13 +162,5 @@ sm_authentic_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported SM command"); } -#if 0 - if (release_sm) { - rv = sm_authentic_get_apdu_release(ctx, sm_info, init_data, init_len, out, out_num); - LOG_TEST_RET(ctx, rv, "SM get APDUs: add 'release' failed"); - - sm_gp_close_session(ctx, &sm_info->session.gp); - } -#endif LOG_FUNC_RETURN(ctx, rv); } diff --git a/src/smm/sm-card-iasecc.c b/src/smm/sm-card-iasecc.c index 0169bd6f..d7b6998f 100644 --- a/src/smm/sm-card-iasecc.c +++ b/src/smm/sm-card-iasecc.c @@ -499,100 +499,6 @@ sm_iasecc_get_apdu_update_rsa(struct sc_context *ctx, struct sm_info *sm_info, s } -#if 0 -static int -sm_iasecc_get_apdu_pso_dst(struct sc_context *ctx, struct sm_info *sm_info, struct sc_remote_apdu **rapdus) -{ - struct sm_info_iasecc_pso_dst *ipd = &sm_info->cmd_params.iasecc_pso_dst; - struct sc_remote_apdu *rapdu = NULL; - int rv; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM get 'PSO DST' APDU"); - - if (ipd->pso_data_len > SM_MAX_DATA_SIZE) - LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - - rv = sc_remote_apdu_allocate(rapdus, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'PSO HASH' APDU: cannot allocate remote apdu"); - - rapdu->apdu.cse = SC_APDU_CASE_3_SHORT; - rapdu->apdu.cla = 0x00; - rapdu->apdu.ins = 0x2A; - rapdu->apdu.p1 = 0x90; - rapdu->apdu.p2 = 0xA0; - memcpy((unsigned char *)rapdu->apdu.data, ipd->pso_data, ipd->pso_data_len); - rapdu->apdu.datalen = ipd->pso_data_len; - rapdu->apdu.lc = ipd->pso_data_len; - - rv = sm_iasecc_securize_apdu(ctx, sm_info, rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'PSO HASH' APDU: securize error"); - - rapdu->get_response = 1; - - rv = sc_remote_apdu_allocate(rapdus, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'PSO DST' APDU: cannot allocate remote apdu"); - - rapdu->apdu.cse = SC_APDU_CASE_2_SHORT; - rapdu->apdu.cla = 0x00; - rapdu->apdu.ins = 0x2A; - rapdu->apdu.p1 = 0x9E; - rapdu->apdu.p2 = 0x9A; - rapdu->apdu.le = ipd->key_size; - - rv = sm_iasecc_securize_apdu(ctx, sm_info, rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'PSO DST' APDU: securize error"); - - rapdu->get_response = 1; - - - LOG_FUNC_RETURN(ctx, rv); -} -#endif - - -#if 0 -static int -sm_iasecc_get_apdu_raw_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_remote_apdu **rapdus) -{ - struct sc_apdu *apdu = sm_info->cmd_params.raw_apdu.apdu; - size_t data_offs, data_len = apdu->datalen; - int rv = SC_ERROR_INVALID_ARGUMENTS; - - LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM get 'RAW APDU' APDU"); - - data_offs = 0; - data_len = apdu->datalen; - for (; data_len; ) { - int sz = data_len > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : data_len; - struct sc_remote_apdu *rapdu = NULL; - - rv = sc_remote_apdu_allocate(rapdus, &rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'RAW APDU' APDUs: cannot allocate remote apdu"); - - rapdu->apdu.cse = apdu->cse; - rapdu->apdu.cla = apdu->cla | ((data_offs + sz) < data_len ? 0x10 : 0x00); - rapdu->apdu.ins = apdu->ins; - rapdu->apdu.p1 = apdu->p1; - rapdu->apdu.p2 = apdu->p2; - memcpy((unsigned char *)rapdu->apdu.data, apdu->data + data_offs, sz); - rapdu->apdu.datalen = sz; - rapdu->apdu.lc = sz; - - rv = sm_iasecc_securize_apdu(ctx, sm_info, rapdu); - LOG_TEST_RET(ctx, rv, "SM get 'UPDATE BINARY' APDUs: securize error"); - - rapdu->get_response = 1; - - data_offs += sz; - data_len -= sz; - } - - LOG_FUNC_RETURN(ctx, rv); -} -#endif - int sm_iasecc_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, unsigned char *init_data, size_t init_len, struct sc_remote_data *rdata, int release_sm) @@ -652,16 +558,6 @@ sm_iasecc_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, rv = sm_iasecc_get_apdu_sdo_update(ctx, sm_info, rdata); LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: 'SDO UPDATE' failed"); break; -#if 0 - case SM_CMD_PSO_DST: - rv = sm_iasecc_get_apdu_pso_dst(ctx, sm_info, &rapdus); - LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: 'PSO DST' failed"); - break; - case SM_CMD_APDU_RAW: - rv = sm_iasecc_get_apdu_raw_apdu(ctx, sm_info, &rapdus); - LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: 'RAW APDU' failed"); - break; -#endif case SM_CMD_PIN_VERIFY: rv = sm_iasecc_get_apdu_verify_pin(ctx, sm_info, rdata); LOG_TEST_RET(ctx, rv, "SM IAS/ECC get APDUs: 'RAW APDU' failed"); diff --git a/src/smm/sm-cwa14890.c b/src/smm/sm-cwa14890.c index df8bfee1..810a5a9c 100644 --- a/src/smm/sm-cwa14890.c +++ b/src/smm/sm-cwa14890.c @@ -43,9 +43,6 @@ #include "libopensc/asn1.h" #include "libopensc/iasecc.h" #include "libopensc/iasecc-sdo.h" -#if 0 -#include "libopensc/hash-strings.h" -#endif #include "sm-module.h" static const struct sc_asn1_entry c_asn1_card_response[2] = { diff --git a/src/smm/sm-global-platform.c b/src/smm/sm-global-platform.c index d7561e7b..f71a774f 100644 --- a/src/smm/sm-global-platform.c +++ b/src/smm/sm-global-platform.c @@ -42,9 +42,6 @@ #include "libopensc/sm.h" #include "libopensc/log.h" #include "libopensc/asn1.h" -#if 0 -#include "libopensc/hash-strings.h" -#endif #include "sm-module.h" @@ -62,78 +59,7 @@ static const struct sc_asn1_entry c_asn1_card_response[2] = { int sm_gp_decode_card_answer(struct sc_context *ctx, struct sc_remote_data *rdata, unsigned char *out, size_t out_len) { -#if 0 - struct sc_asn1_entry asn1_authentic_card_response[4], asn1_card_response[2]; - struct sc_hash *hash = NULL; - unsigned char *hex = NULL; - size_t hex_len; - int rv, offs; - unsigned char card_data[SC_MAX_APDU_BUFFER_SIZE]; - size_t card_data_len = sizeof(card_data), len_left = 0; - - LOG_FUNC_CALLED(ctx); - - if (!out || !out_len) - LOG_FUNC_RETURN(ctx, 0); - if (strstr(str_data, "DATA=")) { - rv = sc_hash_parse(ctx, str_data, strlen(str_data), &hash); - LOG_TEST_RET(ctx, rv, "SM GP decode card answer: parse input data error"); - - str_data = sc_hash_get(hash, "DATA"); - } - - if (!strlen(str_data)) - LOG_FUNC_RETURN(ctx, 0); - - hex_len = strlen(str_data) / 2; - hex = calloc(1, hex_len); - if (!hex) - LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "SM GP decode card answer: hex allocate error"); - - sc_log(ctx, "SM GP decode card answer: hex length %i", hex_len); - rv = sc_hex_to_bin(str_data, hex, &hex_len); - LOG_TEST_RET(ctx, rv, "SM GP decode card answer: data 'HEX to BIN' conversion error"); - sc_log(ctx, "SM GP decode card answer: hex length %i", hex_len); - - if (hash) - sc_hash_free(hash); - - for (offs = 0, len_left = hex_len; len_left; ) { - int num, status; - - sc_copy_asn1_entry(c_asn1_authentic_card_response, asn1_authentic_card_response); - sc_copy_asn1_entry(c_asn1_card_response, asn1_card_response); - sc_format_asn1_entry(asn1_authentic_card_response + 0, &num, NULL, 0); - sc_format_asn1_entry(asn1_authentic_card_response + 1, &status, NULL, 0); - card_data_len = sizeof(card_data); - sc_format_asn1_entry(asn1_authentic_card_response + 2, &card_data, &card_data_len, 0); - sc_format_asn1_entry(asn1_card_response + 0, asn1_authentic_card_response, NULL, 0); - - rv = sc_asn1_decode(ctx, asn1_card_response, hex + hex_len - len_left, len_left, NULL, &len_left); - if (rv) { - sc_log(ctx, "SM GP decode card answer: ASN.1 parse error: %s", sc_strerror(rv)); - return rv; - } - if (status != 0x9000) - continue; - - if (asn1_authentic_card_response[2].flags & SC_ASN1_PRESENT) { - sc_log(ctx, "SM GP decode card answer: card_data_len %i", card_data_len); - if (out_len < offs + card_data_len) - LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "SM GP decode card answer: buffer too small"); - - memcpy(out + offs, card_data, card_data_len); - offs += card_data_len; - } - - sc_log(ctx, "SM GP decode card answer: offs:%i,left:%i", offs, len_left); - } - - free(hex); - LOG_FUNC_RETURN(ctx, offs); -#else LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); -#endif } diff --git a/src/tests/sc-test.c b/src/tests/sc-test.c index 14071c70..a311d733 100644 --- a/src/tests/sc-test.c +++ b/src/tests/sc-test.c @@ -24,14 +24,6 @@ static const struct option options[] = { { NULL, 0, NULL, 0 } }; -#if 0 -const char * option_help[] = { - "Uses reader number [0]", - "Forces the use of driver [auto-detect]", - "Debug output -- may be supplied several times", -}; -#endif - int sc_test_init(int *argc, char *argv[]) { char *opt_driver = NULL, *app_name; diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c index 3f5d1f1b..5c68ba68 100644 --- a/src/tools/pkcs11-tool.c +++ b/src/tools/pkcs11-tool.c @@ -2321,33 +2321,17 @@ get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount) \ * Define attribute accessors */ ATTR_METHOD(CLASS, CK_OBJECT_CLASS); -#if 0 -ATTR_METHOD(TOKEN, CK_BBOOL); -ATTR_METHOD(LOCAL, CK_BBOOL); -ATTR_METHOD(SENSITIVE, CK_BBOOL); -ATTR_METHOD(ALWAYS_SENSITIVE, CK_BBOOL); -ATTR_METHOD(NEVER_EXTRACTABLE, CK_BBOOL); -#endif ATTR_METHOD(ALWAYS_AUTHENTICATE, CK_BBOOL); ATTR_METHOD(PRIVATE, CK_BBOOL); ATTR_METHOD(MODIFIABLE, CK_BBOOL); ATTR_METHOD(ENCRYPT, CK_BBOOL); ATTR_METHOD(DECRYPT, CK_BBOOL); ATTR_METHOD(SIGN, CK_BBOOL); -#if 0 -ATTR_METHOD(SIGN_RECOVER, CK_BBOOL); -#endif ATTR_METHOD(VERIFY, CK_BBOOL); -#if 0 -ATTR_METHOD(VERIFY_RECOVER, CK_BBOOL); -#endif ATTR_METHOD(WRAP, CK_BBOOL); ATTR_METHOD(UNWRAP, CK_BBOOL); ATTR_METHOD(DERIVE, CK_BBOOL); ATTR_METHOD(OPENSC_NON_REPUDIATION, CK_BBOOL); -#if 0 -ATTR_METHOD(EXTRACTABLE, CK_BBOOL); -#endif ATTR_METHOD(KEY_TYPE, CK_KEY_TYPE); ATTR_METHOD(CERTIFICATE_TYPE, CK_CERTIFICATE_TYPE); ATTR_METHOD(MODULUS_BITS, CK_ULONG); diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index 8aced169..3c920dd6 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -829,36 +829,6 @@ static int read_ssh_key(void) return 1; } - /* rsa1 keys */ -# if 0 - if (pubkey->algorithm == SC_ALGORITHM_RSA) { - int bits; - BIGNUM *bn; - char *exp,*mod; - - bn = BN_new(); - BN_bin2bn((unsigned char*)pubkey->u.rsa.modulus.data, pubkey->u.rsa.modulus.len, bn); - bits = BN_num_bits(bn); - exp = BN_bn2dec(bn); - BN_free(bn); - - bn = BN_new(); - BN_bin2bn((unsigned char*)pubkey->u.rsa.exponent.data, pubkey->u.rsa.exponent.len, bn); - mod = BN_bn2dec(bn); - BN_free(bn); - - if (bits && exp && mod) - fprintf(outf, "%u %s %s\n", bits,mod,exp); - else - fprintf(stderr, "decoding rsa key failed!\n"); - - OPENSSL_free(exp); - OPENSSL_free(mod); - } -#endif - /* rsa and des keys - ssh2 */ - /* key_to_blob */ - if (pubkey->algorithm == SC_ALGORITHM_RSA) { unsigned char buf[2048]; unsigned char *uu;