replace sc_debug with sc_log

This commit is contained in:
Frank Morgner 2018-11-22 09:31:29 +01:00
parent cf55cdc637
commit 24b50a4277
71 changed files with 697 additions and 697 deletions

View File

@ -170,7 +170,7 @@ akis_list_files(sc_card_t *card, u8 *buf, size_t buflen)
while (left > 19) {
if (p[0] != 0x2f && p[0] != 0x3d) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Malformatted list reply %02x", p[0]);
sc_log(card->ctx, "Malformatted list reply %02x", p[0]);
return SC_ERROR_INTERNAL;
}
if (buflen >= 2) {
@ -204,7 +204,7 @@ akis_process_fci(sc_card_t *card, sc_file_t *file,
*/
p = sc_asn1_find_tag(card->ctx, buf, buflen, 0x90, &len);
if (p == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Security tag missing");
sc_log(card->ctx, "Security tag missing");
return SC_ERROR_INTERNAL;
}
perms = p[0];
@ -274,7 +274,7 @@ akis_create_file(sc_card_t *card, sc_file_t *file)
type = 0x45;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "This EF structure is not supported yet");
sc_log(card->ctx, "This EF structure is not supported yet");
return SC_ERROR_NOT_SUPPORTED;
}
apdu.p1 = type;
@ -286,7 +286,7 @@ akis_create_file(sc_card_t *card, sc_file_t *file)
} else if (file->type == SC_FILE_TYPE_DF) {
apdu.ins = 0x10;
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown file type");
sc_log(card->ctx, "Unknown file type");
return SC_ERROR_NOT_SUPPORTED;
}
@ -319,7 +319,7 @@ akis_delete_file(sc_card_t *card, const sc_path_t *path)
type = 0x08;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be FID or PATH");
sc_log(card->ctx, "File type has to be FID or PATH");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x16, type, 0x00);
@ -373,7 +373,7 @@ akis_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, int *tries_left
return r;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Other pin cmds not supported yet");
sc_log(card->ctx, "Other pin cmds not supported yet");
return SC_ERROR_NOT_SUPPORTED;
}

View File

@ -65,7 +65,7 @@ static int asepcos_select_asepcos_applet(sc_card_t *card)
r = sc_select_file(card, &tpath, NULL);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to select ASEPCOS applet");
sc_log(card->ctx, "unable to select ASEPCOS applet");
return r;
}
@ -170,7 +170,7 @@ static int asepcos_parse_sec_attr(sc_card_t *card, sc_file_t *file, const u8 *bu
while (len != 0) {
unsigned int amode, tlen = 3;
if (len < 5 || p[0] != 0x80 || p[1] != 0x01) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid access mode encoding");
sc_log(card->ctx, "invalid access mode encoding");
return SC_ERROR_INTERNAL;
}
amode = p[2];
@ -197,7 +197,7 @@ static int asepcos_parse_sec_attr(sc_card_t *card, sc_file_t *file, const u8 *bu
return r;
tlen += 2 + p[4]; /* FIXME */
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid security condition");
sc_log(card->ctx, "invalid security condition");
return SC_ERROR_INTERNAL;
}
p += tlen;
@ -311,7 +311,7 @@ static int asepcos_select_file(sc_card_t *card, const sc_path_t *in_path,
if (r == SC_SUCCESS && file != NULL && *file != NULL) {
r = asepcos_parse_sec_attr(card, *file, (*file)->sec_attr, (*file)->sec_attr_len);
if (r != SC_SUCCESS)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error parsing security attributes");
sc_log(card->ctx, "error parsing security attributes");
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
}
@ -420,7 +420,7 @@ static int asepcos_set_security_attributes(sc_card_t *card, sc_file_t *file)
*p++ = (st.fileid >> 8 ) & 0xff;
*p++ = st.fileid & 0xff;
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unknown auth method: '%d'", ent->method);
sc_log(card->ctx, "unknown auth method: '%d'", ent->method);
return SC_ERROR_INTERNAL;
}
}
@ -487,7 +487,7 @@ static int asepcos_compute_signature(sc_card_t *card, const u8 *data, size_t dat
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) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error creating signature");
sc_log(card->ctx, "error creating signature");
return sc_check_sw(card, apdu.sw1, apdu.sw2);
}
@ -565,7 +565,7 @@ static int asepcos_create_file(sc_card_t *card, sc_file_t *file)
/* set security attributes */
r = asepcos_set_security_attributes(card, file);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to set security attributes");
sc_log(card->ctx, "unable to set security attributes");
return r;
}
return SC_SUCCESS;
@ -611,7 +611,7 @@ static int asepcos_create_file(sc_card_t *card, sc_file_t *file)
/* set security attributes */
r = asepcos_set_security_attributes(card, file);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to set security attributes");
sc_log(card->ctx, "unable to set security attributes");
return r;
}
return asepcos_activate_file(card, file->id, 1);
@ -638,7 +638,7 @@ static int asepcos_create_file(sc_card_t *card, sc_file_t *file)
/* set security attributes */
r = asepcos_set_security_attributes(card, file);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to set security attributes");
sc_log(card->ctx, "unable to set security attributes");
return r;
}
return asepcos_activate_file(card, file->id, 1);
@ -672,7 +672,7 @@ static int asepcos_list_files(sc_card_t *card, u8 *buf, size_t blen)
return r;
if (tfile->prop_attr_len != 6 || tfile->prop_attr == NULL) {
sc_file_free(tfile);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to parse proprietary FCI attributes");
sc_log(card->ctx, "unable to parse proprietary FCI attributes");
return SC_ERROR_INTERNAL;
}
dfFID = (tfile->prop_attr[2] << 8) | tfile->prop_attr[3];
@ -794,7 +794,7 @@ static int asepcos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
return SC_ERROR_INTERNAL;
if (apdu.resplen != 8) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unexpected response to GET DATA serial number\n");
sc_log(card->ctx, "unexpected response to GET DATA serial number\n");
return SC_ERROR_INTERNAL;
}
/* cache serial number */
@ -934,7 +934,7 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
/* check PIN length */
if (pdata->pin1.len < 4 || pdata->pin1.len > 16) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid PIN1 length");
sc_log(card->ctx, "invalid PIN1 length");
return SC_ERROR_INVALID_PIN_LENGTH;
}
@ -951,13 +951,13 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
break;
r = sc_transmit_apdu(card, &apdu);
if (r != SC_SUCCESS)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
sc_log(card->ctx, "APDU transmit failed");
break;
case SC_PIN_CMD_CHANGE:
if (pdata->pin_type != SC_AC_CHV)
return SC_ERROR_INVALID_ARGUMENTS;
if (pdata->pin2.len < 4 || pdata->pin2.len > 16) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid PIN2 length");
sc_log(card->ctx, "invalid PIN2 length");
return SC_ERROR_INVALID_PIN_LENGTH;
}
/* 1. step: verify the old pin */
@ -966,7 +966,7 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
break;
r = sc_transmit_apdu(card, &apdu);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
sc_log(card->ctx, "APDU transmit failed");
break;
}
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00) {
@ -979,13 +979,13 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
break;
r = sc_transmit_apdu(card, &apdu);
if (r != SC_SUCCESS)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
sc_log(card->ctx, "APDU transmit failed");
break;
case SC_PIN_CMD_UNBLOCK:
if (pdata->pin_type != SC_AC_CHV)
return SC_ERROR_INVALID_ARGUMENTS;
if (pdata->pin2.len < 4 || pdata->pin2.len > 16) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid PIN2 length");
sc_log(card->ctx, "invalid PIN2 length");
return SC_ERROR_INVALID_PIN_LENGTH;
}
/* 1. step: verify the puk */
@ -994,7 +994,7 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
break;
r = sc_transmit_apdu(card, &apdu);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
sc_log(card->ctx, "APDU transmit failed");
break;
}
/* 2, step: unblock and change the pin */
@ -1003,12 +1003,12 @@ static int asepcos_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *pdata,
break;
r = sc_transmit_apdu(card, &apdu);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed");
sc_log(card->ctx, "APDU transmit failed");
break;
}
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error: unknown cmd type");
sc_log(card->ctx, "error: unknown cmd type");
return SC_ERROR_INTERNAL;
}
/* Clear the buffer - it may contain pins */

View File

@ -153,7 +153,7 @@ static int process_fci(struct sc_context *ctx, struct sc_file *file,
size_t taglen, len = buflen;
const u8 *tag = NULL, *p;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "processing FCI bytes\n");
sc_log(ctx, "processing FCI bytes\n");
if (buflen < 2)
return SC_ERROR_INTERNAL;
@ -175,7 +175,7 @@ static int process_fci(struct sc_context *ctx, struct sc_file *file,
tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " bytes in file: %d\n", bytes);
sc_log(ctx, " bytes in file: %d\n", bytes);
file->size = bytes;
}
@ -224,8 +224,8 @@ static int process_fci(struct sc_context *ctx, struct sc_file *file,
}
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " type: %s\n", type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " EF structure: %s\n", structure);
sc_log(ctx, " type: %s\n", type);
sc_log(ctx, " EF structure: %s\n", structure);
}
file->magic = SC_FILE_MAGIC;
@ -392,7 +392,7 @@ static int atrust_acos_select_file(struct sc_card *card,
if (r != SC_SUCCESS)
pbuf[0] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"current path (%s, %s): %s (len: %"SC_FORMAT_LEN_SIZE_T"u)\n",
card->cache.current_path.type == SC_PATH_TYPE_DF_NAME ?
"aid" : "path",
@ -417,7 +417,7 @@ static int atrust_acos_select_file(struct sc_card *card,
&& card->cache.current_path.len == pathlen
&& memcmp(card->cache.current_path.value, pathbuf, pathlen) == 0 )
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cache hit\n");
sc_log(card->ctx, "cache hit\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
}
else
@ -489,7 +489,7 @@ static int atrust_acos_select_file(struct sc_card *card,
{
/* done: we are already in the
* requested directory */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cache hit\n");
sc_log(card->ctx, "cache hit\n");
/* copy file info (if necessary) */
if (file_out) {
sc_file_t *file = sc_file_new();
@ -802,13 +802,13 @@ static int atrust_acos_check_sw(struct sc_card *card, unsigned int sw1,
unsigned int sw2)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
sc_log(card->ctx, "sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
if (sw1 == 0x90)
return SC_SUCCESS;
if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Verification failed (remaining tries: %d)\n",
sc_log(card->ctx, "Verification failed (remaining tries: %d)\n",
(sw2 & 0x0f));
return SC_ERROR_PIN_CODE_INCORRECT;
}

View File

@ -174,7 +174,7 @@ static int get_carddata(sc_card_t *card, u8* carddata_loc, unsigned int carddata
r = sc_bytes2apdu(card->ctx, carddata_cmd, sizeof(carddata_cmd), &apdu);
if(r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "bytes to APDU conversion failed: %d\n", r);
sc_log(card->ctx, "bytes to APDU conversion failed: %d\n", r);
return r;
}
@ -183,17 +183,17 @@ static int get_carddata(sc_card_t *card, u8* carddata_loc, unsigned int carddata
r = sc_transmit_apdu(card, &apdu);
if(r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GetCardData command failed: %d\n", r);
sc_log(card->ctx, "GetCardData command failed: %d\n", r);
return r;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if(r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GetCardData: card returned %d\n", r);
sc_log(card->ctx, "GetCardData: card returned %d\n", r);
return r;
}
if(apdu.resplen < carddataloc_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"GetCardData: card returned %"SC_FORMAT_LEN_SIZE_T"u bytes rather than expected %d\n",
apdu.resplen, carddataloc_len);
return SC_ERROR_WRONG_LENGTH;
@ -217,7 +217,7 @@ static int belpic_init(sc_card_t *card)
int key_size = 1024;
int r;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Belpic V%s\n", BELPIC_VERSION);
sc_log(card->ctx, "Belpic V%s\n", BELPIC_VERSION);
if (card->type < 0)
card->type = SC_CARD_TYPE_BELPIC_EID; /* Unknown card: assume it's the Belpic Card */
@ -339,7 +339,7 @@ static int belpic_set_security_env(sc_card_t *card,
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
int r;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "belpic_set_security_env(), keyRef = 0x%0x, algo = 0x%0x\n",
sc_log(card->ctx, "belpic_set_security_env(), keyRef = 0x%0x, algo = 0x%0x\n",
*env->key_ref, env->algorithm_flags);
assert(card != NULL && env != NULL);
@ -357,7 +357,7 @@ static int belpic_set_security_env(sc_card_t *card,
else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_MD5)
sbuf[2] = 0x04;
else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Set Sec Env: unsupported algo 0X%0X\n",
sc_log(card->ctx, "Set Sec Env: unsupported algo 0X%0X\n",
env->algorithm_flags);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -390,7 +390,7 @@ static int belpic_set_security_env(sc_card_t *card,
* the next function to be executed will be the compute_signature function.
*/
if (*env->key_ref == BELPIC_KEY_REF_NONREP) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No GUI for NonRep key present, signature cancelled\n");
sc_log(card->ctx, "No GUI for NonRep key present, signature cancelled\n");
return SC_ERROR_NOT_SUPPORTED;
}

View File

@ -261,7 +261,7 @@ static int cac_apdu_io(sc_card_t *card, int ins, int p1, int p2,
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%02x %02x %02x %"SC_FORMAT_LEN_SIZE_T"u : %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u\n",
ins, p1, p2, sendbuflen, card->max_send_size,
card->max_recv_size);
@ -300,25 +300,25 @@ static int cac_apdu_io(sc_card_t *card, int ins, int p1, int p2,
apdu.resplen = 0;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"calling sc_transmit_apdu flags=%lx le=%"SC_FORMAT_LEN_SIZE_T"u, resplen=%"SC_FORMAT_LEN_SIZE_T"u, resp=%p",
apdu.flags, apdu.le, apdu.resplen, apdu.resp);
/* with new adpu.c and chaining, this actually reads the whole object */
r = sc_transmit_apdu(card, &apdu);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"result r=%d apdu.resplen=%"SC_FORMAT_LEN_SIZE_T"u sw1=%02x sw2=%02x",
r, apdu.resplen, apdu.sw1, apdu.sw2);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Transmit failed");
sc_log(card->ctx, "Transmit failed");
goto err;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Card returned error ");
sc_log(card->ctx, "Card returned error ");
goto err;
}
@ -465,7 +465,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx,
/* if we didn't return it all last time, return the remainder */
if (priv->cached) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"returning cached value idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u",
idx, count);
if (idx > priv->cache_buf_len) {
@ -476,7 +476,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx,
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"clearing cache idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u",
idx, count);
if (priv->cache_buf) {
@ -537,7 +537,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx,
case CAC_OBJECT_TYPE_CERT:
/* read file */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" obj= cert_file, val_len=%"SC_FORMAT_LEN_SIZE_T"u (0x%04"SC_FORMAT_LEN_SIZE_T"x)",
val_len, val_len);
cert_len = 0;
@ -750,7 +750,7 @@ static int cac_set_security_env(sc_card_t *card, const sc_security_env_t *env, i
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"flags=%08lx op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%"SC_FORMAT_LEN_SIZE_T"u\n",
env->flags, env->operation, env->algorithm,
env->algorithm_flags, env->algorithm_ref, env->key_ref[0],
@ -782,7 +782,7 @@ static int cac_rsa_op(sc_card_t *card,
size_t rbuflen, outplen;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"datalen=%"SC_FORMAT_LEN_SIZE_T"u outlen=%"SC_FORMAT_LEN_SIZE_T"u\n",
datalen, outlen);

View File

@ -136,7 +136,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx,
/* if we didn't return it all last time, return the remainder */
if (priv->cached) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"returning cached value idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u",
idx, count);
if (idx > priv->cache_buf_len) {
@ -147,7 +147,7 @@ static int cac_read_binary(sc_card_t *card, unsigned int idx,
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"clearing cache idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u",
idx, count);
free(priv->cache_buf);

View File

@ -96,7 +96,7 @@ static int cardos_match_card(sc_card_t *card)
return 0;
/* get the os version using GET DATA and compare it with
* version in the ATR */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "checking cardos version ...");
sc_log(card->ctx, "checking cardos version ...");
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x82);
apdu.resp = rbuf;
apdu.resplen = sizeof(rbuf);
@ -111,19 +111,19 @@ static int cardos_match_card(sc_card_t *card)
/* version mismatch */
return 0;
if (atr[11] <= 0x04) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found cardos m4.01");
sc_log(card->ctx, "found cardos m4.01");
card->type = SC_CARD_TYPE_CARDOS_M4_01;
} else if (atr[11] == 0x08) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found cardos v4.3b");
sc_log(card->ctx, "found cardos v4.3b");
card->type = SC_CARD_TYPE_CARDOS_M4_3;
} else if (atr[11] == 0x09) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found cardos v4.2b");
sc_log(card->ctx, "found cardos v4.2b");
card->type = SC_CARD_TYPE_CARDOS_M4_2B;
} else if (atr[11] >= 0x0B) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found cardos v4.2c or higher");
sc_log(card->ctx, "found cardos v4.2c or higher");
card->type = SC_CARD_TYPE_CARDOS_M4_2C;
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found cardos m4.2");
sc_log(card->ctx, "found cardos m4.2");
}
}
return 1;
@ -315,13 +315,13 @@ static int cardos_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
for (i = 0; i < err_count; i++) {
if (cardos_errors[i].SWs == ((sw1 << 8) | sw2)) {
if ( cardos_errors[i].errorstr )
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n",
sc_log(card->ctx, "%s\n",
cardos_errors[i].errorstr);
return cardos_errors[i].errorno;
}
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
return SC_ERROR_CARD_CMD_FAILED;
}
@ -351,7 +351,7 @@ get_next_part:
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "DIRECTORY command returned error");
if (apdu.resplen > 256) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "directory listing > 256 bytes, cutting");
sc_log(card->ctx, "directory listing > 256 bytes, cutting");
}
len = apdu.resplen;
@ -360,7 +360,7 @@ get_next_part:
/* is there a file information block (0x6f) ? */
p = sc_asn1_find_tag(card->ctx, p, len, 0x6f, &tlen);
if (p == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "directory tag missing");
sc_log(card->ctx, "directory tag missing");
return SC_ERROR_INTERNAL;
}
if (tlen == 0)
@ -368,7 +368,7 @@ get_next_part:
break;
q = sc_asn1_find_tag(card->ctx, p, tlen, 0x86, &ilen);
if (q == NULL || ilen != 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error parsing file id TLV object");
sc_log(card->ctx, "error parsing file id TLV object");
return SC_ERROR_INTERNAL;
}
/* put file id in buf */
@ -510,7 +510,7 @@ static int cardos_acl_to_bytes(sc_card_t *card, const sc_file_t *file,
else
byte = acl_to_byte(sc_file_get_acl_entry(file, idx[i]));
if (byte < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid ACL\n");
sc_log(card->ctx, "Invalid ACL\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
buf[i] = byte;
@ -643,7 +643,7 @@ static int cardos_construct_fcp(sc_card_t *card, const sc_file_t *file,
buf[4] |= (u8) file->record_count;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unknown EF type: %u", file->type);
sc_log(card->ctx, "unknown EF type: %u", file->type);
return SC_ERROR_INVALID_ARGUMENTS;
}
if (file->ef_structure == SC_FILE_EF_CYCLIC ||
@ -720,7 +720,7 @@ static int cardos_create_file(sc_card_t *card, sc_file_t *file)
r = cardos_construct_fcp(card, file, sbuf, &len);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to create FCP");
sc_log(card->ctx, "unable to create FCP");
return r;
}
@ -1045,7 +1045,7 @@ cardos_lifecycle_get(sc_card_t *card, int *mode)
*mode = SC_CARDCTRL_LIFECYCLE_OTHER;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown lifecycle byte %d", rbuf[0]);
sc_log(card->ctx, "Unknown lifecycle byte %d", rbuf[0]);
r = SC_ERROR_INTERNAL;
}
@ -1191,7 +1191,7 @@ static int cardos_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
return SC_ERROR_INTERNAL;
if (apdu.resplen != 32) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unexpected response to GET DATA serial"
sc_log(card->ctx, "unexpected response to GET DATA serial"
" number\n");
return SC_ERROR_INTERNAL;
}

View File

@ -894,7 +894,7 @@ coolkey_number_of_error_codes = sizeof(coolkey_error_codes)/sizeof(coolkey_error
static int coolkey_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
if (sw1 == 0x90)
@ -941,7 +941,7 @@ static int coolkey_apdu_io(sc_card_t *card, int cla, int ins, int p1, int p2,
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%02x %02x %02x %"SC_FORMAT_LEN_SIZE_T"u : %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u\n",
ins, p1, p2, sendbuflen, card->max_send_size,
card->max_recv_size);
@ -1006,24 +1006,24 @@ static int coolkey_apdu_io(sc_card_t *card, int cla, int ins, int p1, int p2,
apdu.resplen = 0;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"calling sc_transmit_apdu flags=%lx le=%"SC_FORMAT_LEN_SIZE_T"u, resplen=%"SC_FORMAT_LEN_SIZE_T"u, resp=%p",
apdu.flags, apdu.le, apdu.resplen, apdu.resp);
/* with new adpu.c and chaining, this actually reads the whole object */
r = sc_transmit_apdu(card, &apdu);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"result r=%d apdu.resplen=%"SC_FORMAT_LEN_SIZE_T"u sw1=%02x sw2=%02x",
r, apdu.resplen, apdu.sw1, apdu.sw2);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Transmit failed");
sc_log(card->ctx, "Transmit failed");
goto err;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Transmit failed");
sc_log(card->ctx, "Transmit failed");
goto err;
}
@ -1216,7 +1216,7 @@ static int coolkey_read_binary(sc_card_t *card, unsigned int idx,
/* if we've already read the data, just return it */
if (priv->obj->data) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"returning cached value idx=%u count=%"SC_FORMAT_LEN_SIZE_T"u",
idx, count);
len = MIN(count, priv->obj->length-idx);
@ -1224,7 +1224,7 @@ static int coolkey_read_binary(sc_card_t *card, unsigned int idx,
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"clearing cache idx=%u count=%"SC_FORMAT_LEN_SIZE_T"u",
idx, count);
@ -1641,7 +1641,7 @@ static int coolkey_set_security_env(sc_card_t *card, const sc_security_env_t *en
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"flags=%08lx op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%"SC_FORMAT_LEN_SIZE_T"u\n",
env->flags, env->operation, env->algorithm,
env->algorithm_flags, env->algorithm_ref, env->key_ref[0],
@ -1700,7 +1700,7 @@ static int coolkey_rsa_op(sc_card_t *card,
u8 *buf_out;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"datalen=%"SC_FORMAT_LEN_SIZE_T"u outlen=%"SC_FORMAT_LEN_SIZE_T"u\n",
datalen, max_out_len);
@ -1803,7 +1803,7 @@ static int coolkey_ecc_op(sc_card_t *card,
u8 key_number;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"datalen=%"SC_FORMAT_LEN_SIZE_T"u outlen=%"SC_FORMAT_LEN_SIZE_T"u\n",
datalen, outlen);

View File

@ -229,7 +229,7 @@ static int entersafe_cipher_apdu(sc_card_t *card, sc_apdu_t *apdu,
len = apdu->lc;
if(!EVP_EncryptUpdate(ctx, buff, &len, buff, buffsize)){
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "entersafe encryption error.");
sc_log(card->ctx, "entersafe encryption error.");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
}
apdu->lc = len;
@ -238,7 +238,7 @@ static int entersafe_cipher_apdu(sc_card_t *card, sc_apdu_t *apdu,
if(apdu->lc!=buffsize)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "entersafe build cipher apdu failed.");
sc_log(card->ctx, "entersafe build cipher apdu failed.");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INTERNAL);
}
@ -643,7 +643,7 @@ static int entersafe_select_path(sc_card_t *card,
{
/* done: we are already in the
* requested directory */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"cache hit\n");
/* copy file info (if necessary) */
if (file_out) {
@ -691,7 +691,7 @@ static int entersafe_select_file(sc_card_t *card,
if (r != SC_SUCCESS)
pbuf[0] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"current path (%s, %s): %s (len: %"SC_FORMAT_LEN_SIZE_T"u)\n",
card->cache.current_path.type == SC_PATH_TYPE_DF_NAME ?
"aid" : "path",
@ -1008,7 +1008,7 @@ static int entersafe_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
if(data->cmd!=SC_PIN_CMD_UNBLOCK)
{
r = iso_ops->pin_cmd(card,data,tries_left);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Verify rv:%i", r);
sc_log(card->ctx, "Verify rv:%i", r);
}
else
{

View File

@ -304,7 +304,7 @@ cryptoflex_process_file_attrs(sc_card_t *card, sc_file_t *file,
file->type = SC_FILE_TYPE_DF;
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "invalid file type: 0x%02X\n", *p);
sc_log(ctx, "invalid file type: 0x%02X\n", *p);
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
}
p += 2;
@ -368,7 +368,7 @@ cyberflex_process_file_attrs(sc_card_t *card, sc_file_t *file,
file->type = SC_FILE_TYPE_WORKING_EF;
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "invalid file type: 0x%02X\n", *p);
sc_log(ctx, "invalid file type: 0x%02X\n", *p);
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
}
@ -415,7 +415,7 @@ cyberflex_process_file_attrs(sc_card_t *card, sc_file_t *file,
case 0x04:
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "invalid file type: 0x%02X\n", *p);
sc_log(ctx, "invalid file type: 0x%02X\n", *p);
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
}
switch (file->ef_structure) {
@ -515,7 +515,7 @@ static int select_file_id(sc_card_t *card, const u8 *buf, size_t buflen,
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
sc_file_t *file;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called, p1=%u\n", p1);
sc_log(card->ctx, "called, p1=%u\n", p1);
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "path", buf, buflen);
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, p1, 0);
@ -542,7 +542,7 @@ static int select_file_id(sc_card_t *card, const u8 *buf, size_t buflen,
if (apdu.resplen < 14)
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
if (apdu.resp[0] == 0x6F) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unsupported: card returned FCI\n");
sc_log(card->ctx, "unsupported: card returned FCI\n");
return SC_ERROR_UNKNOWN_DATA_RECEIVED; /* FIXME */
}
file = sc_file_new();
@ -575,7 +575,7 @@ static int flex_select_file(sc_card_t *card, const sc_path_t *path,
if (r != SC_SUCCESS)
pbuf[0] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called, cached path=%s\n", pbuf);
sc_log(card->ctx, "called, cached path=%s\n", pbuf);
switch (path->type) {
case SC_PATH_TYPE_PATH:
@ -641,7 +641,7 @@ static int cryptoflex_list_files(sc_card_t *card, u8 *buf, size_t buflen)
if (r)
return r;
if (apdu.resplen != 4) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"expected 4 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n",
apdu.resplen);
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
@ -678,7 +678,7 @@ static int cyberflex_list_files(sc_card_t *card, u8 *buf, size_t buflen)
if (r)
return r;
if (apdu.resplen != 6) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"expected 6 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n",
apdu.resplen);
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
@ -698,7 +698,7 @@ static int flex_delete_file(sc_card_t *card, const sc_path_t *path)
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID\n");
sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
@ -783,7 +783,7 @@ cryptoflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file,
p[6] = 0x06;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid EF structure\n");
sc_log(card->ctx, "Invalid EF structure\n");
return -1;
}
p[7] = 0xFF; /* allow Decrease and Increase */
@ -849,7 +849,7 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file,
break;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Creating %02x:%02x, size %"SC_FORMAT_LEN_SIZE_T"u %02"SC_FORMAT_LEN_SIZE_T"x:%02"SC_FORMAT_LEN_SIZE_T"x\n",
file->id >> 8,
file->id & 0xFF,
@ -878,7 +878,7 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file,
p[4] = 0x1D;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid EF structure\n");
sc_log(card->ctx, "Invalid EF structure\n");
return -1;
}
p[5] = 0x01; /* status?? */
@ -903,7 +903,7 @@ static int flex_create_file(sc_card_t *card, sc_file_t *file)
* abstracting the Cryptoflex/Cyberflex differences */
r = card->ops->construct_fci(card, file, sbuf, &sendlen);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File structure encoding failed.\n");
sc_log(card->ctx, "File structure encoding failed.\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
@ -940,33 +940,33 @@ static int flex_set_security_env(sc_card_t *card,
if (env->operation != SC_SEC_OPERATION_SIGN &&
env->operation != SC_SEC_OPERATION_DECIPHER) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid crypto operation supplied.\n");
sc_log(card->ctx, "Invalid crypto operation supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (env->algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid crypto algorithm supplied.\n");
sc_log(card->ctx, "Invalid crypto algorithm supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if ((env->algorithm_flags & SC_ALGORITHM_RSA_PADS) ||
(env->algorithm_flags & SC_ALGORITHM_RSA_HASHES)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Card supports only raw RSA.\n");
sc_log(card->ctx, "Card supports only raw RSA.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
if (env->key_ref_len != 1 ||
(env->key_ref[0] != 0 && env->key_ref[0] != 1)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid key reference supplied.\n");
sc_log(card->ctx, "Invalid key reference supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
prv->rsa_key_ref = env->key_ref[0];
}
if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Algorithm reference not supported.\n");
sc_log(card->ctx, "Algorithm reference not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT)
if (memcmp(env->file_ref.value, "\x00\x12", 2) != 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File reference is not 0012.\n");
sc_log(card->ctx, "File reference is not 0012.\n");
return SC_ERROR_NOT_SUPPORTED;
}
return 0;
@ -988,13 +988,13 @@ cryptoflex_compute_signature(sc_card_t *card, const u8 *data,
size_t i, i2;
if (data_len != 64 && data_len != 96 && data_len != 128 && data_len != 256) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Illegal input length: %"SC_FORMAT_LEN_SIZE_T"u\n",
data_len);
return SC_ERROR_INVALID_ARGUMENTS;
}
if (outlen < data_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Output buffer too small.\n");
sc_log(card->ctx, "Output buffer too small.\n");
return SC_ERROR_BUFFER_TOO_SMALL;
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x88, 0x00, prv->rsa_key_ref);
@ -1049,7 +1049,7 @@ cyberflex_compute_signature(sc_card_t *card, const u8 *data,
case 96: alg_id = 0xC6; break;
case 128: alg_id = 0xC8; break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Illegal input length: %"SC_FORMAT_LEN_SIZE_T"u\n",
data_len);
return SC_ERROR_INVALID_ARGUMENTS;
@ -1057,7 +1057,7 @@ cyberflex_compute_signature(sc_card_t *card, const u8 *data,
key_id = prv->rsa_key_ref + 1; /* Why? */
if (outlen < data_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Output buffer too small.\n");
sc_log(card->ctx, "Output buffer too small.\n");
return SC_ERROR_BUFFER_TOO_SMALL;
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x88, alg_id, key_id);
@ -1123,7 +1123,7 @@ static int flex_generate_key(sc_card_t *card, struct sc_cardctl_cryptoflex_genke
case 1024: p2 = 0x80; break;
case 2048: p2 = 0x00; break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Illegal key length: %d\n", data->key_bits);
sc_log(card->ctx, "Illegal key length: %d\n", data->key_bits);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -1175,7 +1175,7 @@ static int flex_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
len = tfile->size;
sc_file_free(tfile);
if (len != 8) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unexpected file length of EF_ICCSN (%lu)\n",
sc_log(card->ctx, "unexpected file length of EF_ICCSN (%lu)\n",
(unsigned long) len);
return SC_ERROR_INTERNAL;
}

View File

@ -105,13 +105,13 @@ static int get_conf_aid(sc_card_t *card, u8 *aid, size_t *len)
}
if (!conf_block) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "no card specific options configured, trying default AID\n");
sc_log(ctx, "no card specific options configured, trying default AID\n");
return SC_ERROR_INTERNAL;
}
str_aid = scconf_get_str(conf_block, "aid", NULL);
if (!str_aid) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "no aid configured, trying default AID\n");
sc_log(ctx, "no aid configured, trying default AID\n");
return SC_ERROR_INTERNAL;
}
return sc_hex_to_bin(str_aid, aid, len);
@ -191,7 +191,7 @@ static int gemsafe_init(struct sc_card *card)
r = gp_select_applet(card, exdata->aid, exdata->aid_len);
if (r < 0) {
free(exdata);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "applet selection failed\n");
sc_log(card->ctx, "applet selection failed\n");
return SC_ERROR_INVALID_CARD;
}
card->lock_count--;
@ -292,7 +292,7 @@ static int gemsafe_setacl(sc_card_t *card, sc_file_t *file, const u8 *data,
cond = *p++;
else
cond = 0xff;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"DF security byte CREATE DF: %02x\n", cond);
r = gemsafe_sc2acl(file, SC_AC_OP_CREATE, cond);
if (r < 0)
@ -301,7 +301,7 @@ static int gemsafe_setacl(sc_card_t *card, sc_file_t *file, const u8 *data,
cond = *p;
else
cond = 0xff;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"DF security byte CREATE EF: %02x\n", cond);
/* XXX: opensc doesn't currently separate access conditions for
* CREATE EF and CREATE DF, this should be changed */
@ -315,7 +315,7 @@ static int gemsafe_setacl(sc_card_t *card, sc_file_t *file, const u8 *data,
cond = *p++;
else
cond = 0xff;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"EF security byte UPDATE/ERASE BINARY: %02x\n", cond);
r = gemsafe_sc2acl(file, SC_AC_OP_UPDATE, cond);
if (r < 0)
@ -330,7 +330,7 @@ static int gemsafe_setacl(sc_card_t *card, sc_file_t *file, const u8 *data,
cond = *p;
else
cond = 0xff;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"EF security byte READ BINARY: %02x\n", cond);
r = gemsafe_sc2acl(file, SC_AC_OP_READ, cond);
if (r < 0)
@ -354,7 +354,7 @@ static int gemsafe_process_fci(struct sc_card *card, struct sc_file *file,
r = iso_ops->process_fci(card, file, buf, len);
if (r < 0)
return r;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"processing GemSAFE V1 specific FCI information\n");
@ -368,17 +368,17 @@ static int gemsafe_process_fci(struct sc_card *card, struct sc_file *file,
file->type = SC_FILE_TYPE_WORKING_EF;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file type: %s\n", type);
sc_log(ctx, "file type: %s\n", type);
tag = sc_asn1_find_tag(ctx, p, len, 0x8C, &tlen);
if (tag) {
r = gemsafe_setacl(card, file, tag, strcmp(type, "DF") ? 0 : 1);
if (r < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to set ACL\n");
sc_log(ctx, "unable to set ACL\n");
return SC_ERROR_INTERNAL;
}
} else
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: AM and SC bytes missing\n");
sc_log(ctx, "error: AM and SC bytes missing\n");
return SC_SUCCESS;
}
@ -443,7 +443,7 @@ static int gemsafe_set_security_env(struct sc_card *card,
}
}
if (!(se_env.flags & SC_SEC_ENV_ALG_REF_PRESENT))
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown algorithm flags '%x'\n", se_env.algorithm_flags);
sc_log(ctx, "unknown algorithm flags '%x'\n", se_env.algorithm_flags);
se_env.flags &= ~SC_SEC_ENV_FILE_REF_PRESENT;
return iso_ops->set_security_env(card, &se_env, se_num);
@ -462,7 +462,7 @@ static int gemsafe_compute_signature(struct sc_card *card, const u8 * data,
/* the card can sign 36 bytes of free form data */
if (data_len > 36) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"error: input data too long: %"SC_FORMAT_LEN_SIZE_T"u bytes\n",
data_len);
return SC_ERROR_INVALID_ARGUMENTS;

View File

@ -170,12 +170,12 @@ static int gids_get_identifiers(sc_card_t* card, u8* masterfile, size_t masterfi
if (strcmp(directory, records[i].directory) == 0 && strcmp(filename, records[i].filename) == 0) {
*fileIdentifier = records[i].fileIdentifier;
*dataObjectIdentifier = records[i].dataObjectIdentifier;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Identifiers of %s %s is fileIdentifier=%x, dataObjectIdentifier=%x\n", directory, filename, *fileIdentifier, *dataObjectIdentifier);
return 0;
}
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "file %s %s not found\n", directory, filename);
sc_log(card->ctx, "file %s %s not found\n", directory, filename);
return SC_ERROR_FILE_NOT_FOUND;
}
@ -214,7 +214,7 @@ static int gids_get_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdenti
u8 buffer[MAX_GIDS_FILE_SIZE];
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
fileIdentifier, dataObjectIdentifier, response,
responselen ? *responselen : 0);
@ -251,7 +251,7 @@ static int gids_put_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdenti
u8 buffer[SC_MAX_EXT_APDU_BUFFER_SIZE];
u8* p = buffer;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Got args: fileIdentifier=%x, dataObjectIdentifier=%x, data=%p, datalen=%"SC_FORMAT_LEN_SIZE_T"u\n",
fileIdentifier, dataObjectIdentifier, data, datalen);
@ -279,7 +279,7 @@ static int gids_select_aid(sc_card_t* card, u8* aid, size_t aidlen, u8* response
int r;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Got args: aid=%p, aidlen=%"SC_FORMAT_LEN_SIZE_T"u, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
aid, aidlen, response, responselen ? *responselen : 0);
@ -552,7 +552,7 @@ static int gids_get_pin_status(sc_card_t *card, int pinreference, int *tries_lef
*max_tries = p[0];
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Pin information for PIN 0x%x: triesleft=%d trieslimit=%d\n", pinreference, (tries_left?*tries_left:-1), (max_tries?*max_tries:-1));
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
}
@ -579,7 +579,7 @@ static int gids_match_card(sc_card_t * card)
if (tag != NULL) {
aid = sc_asn1_find_tag(card->ctx, tag, taglen, GIDS_APPLICATION_AID_TAG, &aidlen);
if (aid != NULL ) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"found AID");
sc_log(card->ctx, "found AID");
for (i = 0; gids_aids[i].len_long != 0; i++) {
if ( aidlen > gids_aids[i].len_long && memcmp(aid, gids_aids[i].value,
gids_aids[i].len_long) == 0) {
@ -856,7 +856,7 @@ static int gids_read_public_key (struct sc_card *card , unsigned int algorithm,
size_t buffersize = sizeof(buffer);
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Got args: key_reference=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
key_reference, response, responselen ? *responselen : 0);
@ -876,7 +876,7 @@ static int gids_read_public_key (struct sc_card *card , unsigned int algorithm,
keytemplate = sc_asn1_find_tag(card->ctx, buffer, buffersize, GIDS_PUBKEY_TAG, &tlen);
if (keytemplate == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid public key data: missing tag");
sc_log(card->ctx, "invalid public key data: missing tag");
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
}
@ -900,7 +900,7 @@ static int gids_read_public_key (struct sc_card *card , unsigned int algorithm,
r = sc_pkcs15_encode_pubkey_rsa(card->ctx, &rsa_key, response, responselen);
LOG_TEST_RET(card->ctx, r, "failed to read public key: cannot encode RSA public key");
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "it is not a known public key");
sc_log(card->ctx, "it is not a known public key");
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
}
@ -1004,17 +1004,17 @@ static int gids_read_binary(sc_card_t *card, unsigned int offset,
data->buffersize = sizeof(data->buffer);
r = sc_decompress(data->buffer, &(data->buffersize), buffer+4, buffersize-4, COMPRESSION_ZLIB);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Zlib error: %d", r);
sc_log(card->ctx, "Zlib error: %d", r);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
}
if (data->buffersize != expectedsize) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"expected size: %"SC_FORMAT_LEN_SIZE_T"u real size: %"SC_FORMAT_LEN_SIZE_T"u",
expectedsize, data->buffersize);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA);
}
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unknown compression method %d", buffer[0] + (buffer[1] <<8));
sc_log(card->ctx, "unknown compression method %d", buffer[0] + (buffer[1] <<8));
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA);
}
data->state = GIDS_STATE_READ_DATA_PRESENT;
@ -1123,11 +1123,11 @@ gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t* key_info) {
// key was specified. Search if the key can be used
size_t i = key_info->key_reference - GIDS_FIRST_KEY_IDENTIFIER;
if (i > GIDS_MAX_CONTAINER) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid key ref %d", key_info->key_reference);
sc_log(card->ctx, "invalid key ref %d", key_info->key_reference);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
if (i > recordsnum) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"container num is not allowed %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u",
i, recordsnum);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
@ -1266,8 +1266,8 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) {
} else {
keymaprecordnum = (keymapbuffersize - 1) / sizeof(struct gids_keymap_record);
if (keymaprecordnum != recordnum) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL , "Error: Unable to create the key file because the keymap and cmapfile are inconsistent");
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL ,
sc_log(card->ctx , "Error: Unable to create the key file because the keymap and cmapfile are inconsistent");
sc_log(card->ctx ,
"keymaprecordnum = %"SC_FORMAT_LEN_SIZE_T"u recordnum = %"SC_FORMAT_LEN_SIZE_T"u",
keymaprecordnum, recordnum);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
@ -1435,11 +1435,11 @@ static int gids_import_key(sc_card_t *card, sc_pkcs15_object_t *object, sc_pkcs1
assert((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY);
if (object->type != SC_PKCS15_TYPE_PRKEY_RSA || key->algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GIDS supports RSA keys only (but may support ECC one day).");
sc_log(card->ctx, "GIDS supports RSA keys only (but may support ECC one day).");
return SC_ERROR_NOT_SUPPORTED;
}
if (!key->u.rsa.dmp1.len || !key->u.rsa.dmq1.len || !key->u.rsa.iqmp.len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GIDS needs dmp1 & dmq1 & iqmp");
sc_log(card->ctx, "GIDS needs dmp1 & dmq1 & iqmp");
return SC_ERROR_NOT_SUPPORTED;
}
sc_format_asn1_entry(asn1_rsa_priv_coefficients_gids + 0, &version, NULL, 1);
@ -1971,7 +1971,7 @@ static int gids_authenticate_admin(sc_card_t *card, u8* key) {
if (apdu.resplen != 44)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Expecting a response len of 44 - found %d",(int) apdu.resplen);
sc_log(card->ctx, "Expecting a response len of 44 - found %d",(int) apdu.resplen);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
}
// init crypto
@ -1985,26 +1985,26 @@ static int gids_authenticate_admin(sc_card_t *card, u8* key) {
}
EVP_CIPHER_CTX_set_padding(ctx,0);
if (!EVP_DecryptUpdate(ctx, buffer3, &buffer3size, apdu.resp + 4, apdu.resplen - 4)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to decrypt data");
sc_log(card->ctx, "unable to decrypt data");
EVP_CIPHER_CTX_free(ctx);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT);
}
if(!EVP_DecryptFinal(ctx, buffer3+buffer3size, &buffer3size)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to decrypt final data");
sc_log(card->ctx, "unable to decrypt final data");
EVP_CIPHER_CTX_free(ctx);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "data has been decrypted using the key");
sc_log(card->ctx, "data has been decrypted using the key");
if (memcmp(buffer3, randomR1, 16) != 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "R1 doesn't match");
sc_log(card->ctx, "R1 doesn't match");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT);
}
if (memcmp(buffer3 + 16, randomR2, 16) != 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "R2 doesn't match");
sc_log(card->ctx, "R2 doesn't match");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT);
}
if (buffer[39] != 0x80) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Padding not found");
sc_log(card->ctx, "Padding not found");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PIN_CODE_INCORRECT);
}
EVP_CIPHER_CTX_free(ctx);

View File

@ -534,7 +534,7 @@ gpk_select_id(sc_card_t *card, int kind, unsigned int fid,
u8 fbuf[2];
int r;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"gpk_select_id(0x%04X, kind=%u)\n", fid, kind);
fbuf[0] = fid >> 8;
@ -685,7 +685,7 @@ gpk_read_binary(sc_card_t *card, unsigned int offset,
struct gpk_private_data *priv = DRVDATA(card);
if (offset & priv->offset_mask) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid file offset (not a multiple of %d)",
sc_log(card->ctx, "Invalid file offset (not a multiple of %d)",
priv->offset_mask + 1);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -700,7 +700,7 @@ gpk_write_binary(sc_card_t *card, unsigned int offset,
struct gpk_private_data *priv = DRVDATA(card);
if (offset & priv->offset_mask) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid file offset (not a multiple of %d)",
sc_log(card->ctx, "Invalid file offset (not a multiple of %d)",
priv->offset_mask + 1);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -715,7 +715,7 @@ gpk_update_binary(sc_card_t *card, unsigned int offset,
struct gpk_private_data *priv = DRVDATA(card);
if (offset & priv->offset_mask) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid file offset (not a multiple of %d)",
sc_log(card->ctx, "Invalid file offset (not a multiple of %d)",
priv->offset_mask + 1);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -785,7 +785,7 @@ gpk_verify_crycks(sc_card_t *card, sc_apdu_t *apdu, u8 *crycks)
{
if (apdu->resplen < 3
|| memcmp(apdu->resp + apdu->resplen - 3, crycks, 3)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Invalid secure messaging reply\n");
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
}
@ -808,7 +808,7 @@ gpk_create_file(sc_card_t *card, sc_file_t *file)
size_t datalen, namelen;
int r;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"gpk_create_file(0x%04X)\n", file->id);
/* Prepare APDU */
@ -1014,7 +1014,7 @@ gpk_set_security_env(sc_card_t *card,
if (env->flags & SC_SEC_ENV_ALG_PRESENT)
algorithm = env->algorithm;
if (algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Algorithm not supported.\n");
sc_log(card->ctx, "Algorithm not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
priv->sec_algorithm = algorithm;
@ -1022,7 +1022,7 @@ gpk_set_security_env(sc_card_t *card,
/* If there's a key reference, it must be 0 */
if ((env->flags & SC_SEC_ENV_KEY_REF_PRESENT)
&& (env->key_ref_len != 1 || env->key_ref[0] != 0)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown key referenced.\n");
sc_log(card->ctx, "Unknown key referenced.\n");
return SC_ERROR_NOT_SUPPORTED;
}
@ -1035,7 +1035,7 @@ gpk_set_security_env(sc_card_t *card,
else if (env->flags & SC_ALGORITHM_RSA_PAD_ISO9796)
priv->sec_padding = 2;
else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Padding algorithm not supported.\n");
sc_log(card->ctx, "Padding algorithm not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
@ -1058,7 +1058,7 @@ gpk_set_security_env(sc_card_t *card,
context = GPK_SIGN_RSA_MD5;
priv->sec_hash_len = 16;
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported signature algorithm");
sc_log(card->ctx, "Unsupported signature algorithm");
return SC_ERROR_NOT_SUPPORTED;
}
break;
@ -1066,20 +1066,20 @@ gpk_set_security_env(sc_card_t *card,
context = GPK_UNWRAP_RSA;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Crypto operation not supported.\n");
sc_log(card->ctx, "Crypto operation not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
/* Get the file ID */
if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) {
if (env->file_ref.len != 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File reference: invalid length.\n");
sc_log(card->ctx, "File reference: invalid length.\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
file_id = (env->file_ref.value[0] << 8)
| env->file_ref.value[1];
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File reference missing.\n");
sc_log(card->ctx, "File reference missing.\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -1093,11 +1093,11 @@ gpk_set_security_env(sc_card_t *card,
SC_RECORD_BY_REC_NR);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "Failed to read PK sysrec");
if (r != 7 || sysrec[0] != 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "First record of file is not the sysrec");
sc_log(card->ctx, "First record of file is not the sysrec");
return SC_ERROR_OBJECT_NOT_VALID;
}
if (sysrec[5] != 0x00) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Public key is not an RSA key");
sc_log(card->ctx, "Public key is not an RSA key");
return SC_ERROR_OBJECT_NOT_VALID;
}
switch (sysrec[1]) {
@ -1105,7 +1105,7 @@ gpk_set_security_env(sc_card_t *card,
case 0x10: priv->sec_mod_len = 768 / 8; break;
case 0x11: priv->sec_mod_len = 1024 / 8; break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported modulus length");
sc_log(card->ctx, "Unsupported modulus length");
return SC_ERROR_OBJECT_NOT_VALID;
}
@ -1237,7 +1237,7 @@ gpk_compute_signature(sc_card_t *card, const u8 *data,
int r;
if (data_len > priv->sec_mod_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Data length (%"SC_FORMAT_LEN_SIZE_T"u) does not match key modulus %u.\n",
data_len, priv->sec_mod_len);
return SC_ERROR_INTERNAL;
@ -1291,7 +1291,7 @@ gpk_decipher(sc_card_t *card, const u8 *in, size_t inlen,
int r;
if (inlen != priv->sec_mod_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Data length (%"SC_FORMAT_LEN_SIZE_T"u) does not match key modulus %u.\n",
inlen, priv->sec_mod_len);
return SC_ERROR_INVALID_ARGUMENTS;
@ -1388,7 +1388,7 @@ gpk_lock(sc_card_t *card, struct sc_cardctl_gpk_lock *args)
u8 data[8], crycks[3], resp[3];
int r;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"gpk_lock(0x%04X, %u)\n", file->id, args->operation);
memset(data, 0, sizeof(data));
@ -1445,7 +1445,7 @@ gpk_pkfile_init(sc_card_t *card, struct sc_cardctl_gpk_pkinit *args)
sc_apdu_t apdu;
int r;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"gpk_pkfile_init(%u)\n", args->privlen);
memset(&apdu, 0, sizeof(apdu));
@ -1473,10 +1473,10 @@ gpk_generate_key(sc_card_t *card, struct sc_cardctl_gpk_genkey *args)
int r;
u8 buffer[256];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"gpk_generate_key(%u)\n", args->privlen);
if (args->privlen != 512 && args->privlen != 1024) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Key generation not supported for key length %d",
args->privlen);
return SC_ERROR_NOT_SUPPORTED;
@ -1522,7 +1522,7 @@ gpk_pkfile_load(sc_card_t *card, struct sc_cardctl_gpk_pkload *args)
int r = SC_SUCCESS, outl;
EVP_CIPHER_CTX * ctx;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "gpk_pkfile_load(fid=%04x, len=%d, datalen=%d)\n",
sc_log(card->ctx, "gpk_pkfile_load(fid=%04x, len=%d, datalen=%d)\n",
args->file->id, args->len, args->datalen);
ctx = EVP_CIPHER_CTX_new();
@ -1545,7 +1545,7 @@ gpk_pkfile_load(sc_card_t *card, struct sc_cardctl_gpk_pkload *args)
/* encrypt the private key material */
assert(args->datalen <= sizeof(temp));
if (!priv->key_set) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No secure messaging key set!\n");
sc_log(card->ctx, "No secure messaging key set!\n");
return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
}
@ -1624,7 +1624,7 @@ static int gpk_get_info(sc_card_t *card, int p1, int p2, u8 *buf,
apdu.resplen = buflen;
if ((r = sc_transmit_apdu(card, &apdu)) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed: %s",
sc_log(card->ctx, "APDU transmit failed: %s",
sc_strerror(r));
sc_unlock(card);
return r;

View File

@ -152,13 +152,13 @@ static int incrypto34_check_sw(sc_card_t *card, unsigned int sw1, unsigned int s
for (i = 0; i < err_count; i++) {
if (incrypto34_errors[i].SWs == ((sw1 << 8) | sw2)) {
if ( incrypto34_errors[i].errorstr )
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n",
sc_log(card->ctx, "%s\n",
incrypto34_errors[i].errorstr);
return incrypto34_errors[i].errorno;
}
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
return SC_ERROR_CARD_CMD_FAILED;
}
@ -327,7 +327,7 @@ static int incrypto34_create_file(sc_card_t *card, sc_file_t *file)
"%02X", file->path.value[n]);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "incrypto34_create_file(%s)\n", pbuf);
sc_log(card->ctx, "incrypto34_create_file(%s)\n", pbuf);
if (file->type_attr_len == 0) {
memset(type, 0, sizeof(type));
@ -388,7 +388,7 @@ static int incrypto34_create_file(sc_card_t *card, sc_file_t *file)
byte = acl_to_byte(
sc_file_get_acl_entry(file, idx[i]));
if (byte < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid ACL\n");
sc_log(card->ctx, "Invalid ACL\n");
r = SC_ERROR_INVALID_ARGUMENTS;
goto out;
}
@ -448,7 +448,7 @@ static int incrypto34_set_security_env(sc_card_t *card,
if (!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT)
|| env->key_ref_len != 1) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No or invalid key reference\n");
sc_log(card->ctx, "No or invalid key reference\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
key_id = env->key_ref[0];
@ -546,12 +546,12 @@ incrypto34_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
* succeeds (this is not really beautiful, but currently the
* only way I see) -- Nils
*/
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"trying RSA_PURE_SIG (padded DigestInfo)\n");
r = do_compute_signature(card, data, datalen, out, outlen);
if (r >= SC_SUCCESS)
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"trying RSA_SIG (just the DigestInfo)\n");
/* remove padding: first try pkcs1 bt01 padding */
r = sc_pkcs1_strip_01_padding(ctx, data, datalen, buf, &tmp_len);
@ -570,7 +570,7 @@ incrypto34_compute_signature(sc_card_t *card, const u8 *data, size_t datalen,
r = do_compute_signature(card, buf, tmp_len, out, outlen);
if (r >= SC_SUCCESS)
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"trying to sign raw hash value\n");
r = sc_pkcs1_strip_digest_info_prefix(NULL,buf,tmp_len,buf,&buf_len);
if (r != SC_SUCCESS)
@ -615,7 +615,7 @@ incrypto34_lifecycle_get(sc_card_t *card, int *mode)
*mode = SC_CARDCTRL_LIFECYCLE_OTHER;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown lifecycle byte %d", rbuf[0]);
sc_log(card->ctx, "Unknown lifecycle byte %d", rbuf[0]);
r = SC_ERROR_INTERNAL;
}

View File

@ -108,7 +108,7 @@ static int itacns_match_cns_card(sc_card_t *card, unsigned int i)
if(atr[i] != 0x10) {
char version[8];
snprintf(version, sizeof(version), "%d.%d", (atr[i] >> 4) & 0x0f, atr[i] & 0x0f);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "CNS card version %s; no official specifications "
sc_log(card->ctx, "CNS card version %s; no official specifications "
"are published. Proceeding anyway.\n", version);
}
i++;
@ -292,7 +292,7 @@ static int itacns_set_security_env(sc_card_t *card,
if (!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT)
|| env->key_ref_len != 1) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"No or invalid key reference\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -497,7 +497,7 @@ static int itacns_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
return SC_SUCCESS;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Reading EF_IDCarta.\n");
sc_log(card->ctx, "Reading EF_IDCarta.\n");
sc_format_path("3F0010001003", &path);
@ -512,7 +512,7 @@ static int itacns_get_serialnr(sc_card_t *card, sc_serial_number_t *serial)
//do not return FCI/FCP templates that include the file size.
//Notify abnormal length anyway.
if (len != 16) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Unexpected file length of EF_IDCarta (%lu)\n",
(unsigned long) len);
}

View File

@ -624,11 +624,11 @@ static int jcop_set_security_env(sc_card_t *card,
tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT;
tmp.flags |= SC_SEC_ENV_ALG_REF_PRESENT;
if (tmp.algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Only RSA algorithm supported.\n");
sc_log(card->ctx, "Only RSA algorithm supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1)){
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Card requires RSA padding\n");
sc_log(card->ctx, "Card requires RSA padding\n");
return SC_ERROR_NOT_SUPPORTED;
}
tmp.algorithm_ref = 0x02;
@ -681,13 +681,13 @@ static int jcop_set_security_env(sc_card_t *card,
apdu.resplen = 0;
r = sc_transmit_apdu(card, &apdu);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: APDU transmit failed", sc_strerror(r));
return r;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: Card returned error", sc_strerror(r));
return r;
}
@ -811,7 +811,7 @@ static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a)
if (a->exponent == 0x10001) {
is_f4=1;
} else if (a->exponent != 3) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: Invalid exponent", sc_strerror(SC_ERROR_NOT_SUPPORTED));
return SC_ERROR_NOT_SUPPORTED;
}
@ -841,13 +841,13 @@ static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a)
apdu.resplen = 0;
r = sc_transmit_apdu(card, &apdu);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: APDU transmit failed", sc_strerror(r));
return r;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: Card returned error", sc_strerror(r));
return r;
}
@ -860,13 +860,13 @@ static int jcop_generate_key(sc_card_t *card, struct sc_cardctl_jcop_genkey *a)
r = sc_transmit_apdu(card, &apdu);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: APDU transmit failed", sc_strerror(r));
return r;
}
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%s: Card returned error", sc_strerror(r));
return r;
}

View File

@ -72,7 +72,7 @@ static int masktech_init(sc_card_t * card)
unsigned long flags;
struct masktech_private_data *data;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "masktech_init()\n");
sc_log(card->ctx, "masktech_init()\n");
/* private data kept during the live of the driver */
if (!(data = (struct masktech_private_data *) malloc(sizeof(*data))))
@ -104,7 +104,7 @@ static int masktech_set_security_env(sc_card_t *card,
int se_num)
{
struct masktech_private_data *private_data;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "masktech_set_security_env(), keyRef = 0x%0x, algo = 0x%0x\n",
sc_log(card->ctx, "masktech_set_security_env(), keyRef = 0x%0x, algo = 0x%0x\n",
*env->key_ref, env->algorithm_flags);
private_data = (struct masktech_private_data *) card->drv_data;
@ -114,7 +114,7 @@ static int masktech_set_security_env(sc_card_t *card,
/* save the key reference */
if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
if (env->key_ref_len != 1) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid key reference supplied.\n");
sc_log(card->ctx, "Invalid key reference supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
private_data->rsa_key_ref = env->key_ref[0];
@ -137,7 +137,7 @@ static int masktech_compute_signature(sc_card_t *card,
0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20
};
assert(card != NULL && data != NULL && out != NULL);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "masktech_compute_signature()\n");
sc_log(card->ctx, "masktech_compute_signature()\n");
/* retrieve the key reference */
private_data = (struct masktech_private_data *) card->drv_data;
@ -150,7 +150,7 @@ static int masktech_compute_signature(sc_card_t *card,
/* check that it is a SHA256 with digest info*/
if ((datalen != sizeof(hdr_sha256) + 32) || (memcmp(hdr_sha256, data, sizeof(hdr_sha256)) != 0))
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "It is not a SHA256 with digestinfo\n");
sc_log(card->ctx, "It is not a SHA256 with digestinfo\n");
return SC_ERROR_NOT_SUPPORTED;
}
/* extract the SHA-256 hash */
@ -176,7 +176,7 @@ static int masktech_decipher(sc_card_t *card,
u8 rbuf[SC_MAX_EXT_APDU_BUFFER_SIZE];
assert(card != NULL && crgram != NULL && out != NULL);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "masktech_decipher()\n");
sc_log(card->ctx, "masktech_decipher()\n");
if (crgram_len > SC_MAX_EXT_APDU_BUFFER_SIZE) {
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
@ -343,7 +343,7 @@ static int masktech_get_serialnr(sc_card_t * card, sc_serial_number_t * serial)
static int masktech_card_ctl(sc_card_t * card, unsigned long cmd, void *ptr)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "masktech_card_ctl()\n");
sc_log(card->ctx, "masktech_card_ctl()\n");
switch (cmd) {
case SC_CARDCTL_GET_SERIALNR:
return masktech_get_serialnr(card, (sc_serial_number_t *) ptr);

View File

@ -1397,7 +1397,7 @@ static int mcrd_decipher(struct sc_card *card,
if (crgram_len > 255)
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Will derive (%d) for %"SC_FORMAT_LEN_SIZE_T"u (0x%02"SC_FORMAT_LEN_SIZE_T"x) bytes using key %d algorithm %d flags %d\n",
env->operation, crgram_len, crgram_len, env->key_ref[0],
env->algorithm, env->algorithm_flags);

View File

@ -139,7 +139,7 @@ static int encode_file_structure(sc_card_t *card, const sc_file_t *file,
*p++ = 0x43;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid EF structure\n");
sc_log(card->ctx, "Invalid EF structure\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
ops = ef_ops;
@ -149,7 +149,7 @@ static int encode_file_structure(sc_card_t *card, const sc_file_t *file,
ops = key_ops;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown file type\n");
sc_log(card->ctx, "Unknown file type\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
if (file->type == SC_FILE_TYPE_DF) {
@ -170,7 +170,7 @@ static int encode_file_structure(sc_card_t *card, const sc_file_t *file,
else {
int byte = acl_to_byte(sc_file_get_acl_entry(file, ops[i]));
if (byte < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid ACL\n");
sc_log(card->ctx, "Invalid ACL\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
nibble = byte;
@ -237,7 +237,7 @@ static int miocos_set_security_env(sc_card_t *card,
tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT;
tmp.flags |= SC_SEC_ENV_ALG_REF_PRESENT;
if (tmp.algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Only RSA algorithm supported.\n");
sc_log(card->ctx, "Only RSA algorithm supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
tmp.algorithm_ref = 0x00;
@ -414,7 +414,7 @@ static int miocos_delete_file(sc_card_t *card, const sc_path_t *path)
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID\n");
sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
r = sc_select_file(card, path, NULL);
@ -452,7 +452,7 @@ static int miocos_create_ac(sc_card_t *card,
sendsize = 20;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "AC type %d not supported\n", ac->type);
sc_log(card->ctx, "AC type %d not supported\n", ac->type);
return SC_ERROR_NOT_SUPPORTED;
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x1E, miocos_type,
@ -472,7 +472,7 @@ static int miocos_card_ctl(sc_card_t *card, unsigned long cmd,
case SC_CARDCTL_MIOCOS_CREATE_AC:
return miocos_create_ac(card, (struct sc_cardctl_miocos_ac_info *) arg);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "card_ctl command 0x%lX not supported\n", cmd);
sc_log(card->ctx, "card_ctl command 0x%lX not supported\n", cmd);
return SC_ERROR_NOT_SUPPORTED;
}

View File

@ -277,7 +277,7 @@ static int muscle_delete_mscfs_file(sc_card_t *card, mscfs_file_t *file_data)
/* Delete children */
mscfs_check_cache(fs);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"DELETING Children of: %02X%02X%02X%02X\n",
oid[0],oid[1],oid[2],oid[3]);
for(x = 0; x < fs->cache.size; x++) {
@ -286,7 +286,7 @@ static int muscle_delete_mscfs_file(sc_card_t *card, mscfs_file_t *file_data)
objectId = childFile->objectId;
if(0 == memcmp(oid + 2, objectId.id, 2)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"DELETING: %02X%02X%02X%02X\n",
objectId.id[0],objectId.id[1],
objectId.id[2],objectId.id[3]);
@ -525,7 +525,7 @@ static int muscle_list_files(sc_card_t *card, u8 *buf, size_t bufLen)
u8* oid = fs->cache.array[x].objectId.id;
if (bufLen < 2)
break;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"FILE: %02X%02X%02X%02X\n",
oid[0],oid[1],oid[2],oid[3]);
if(0 == memcmp(fs->currentPath, oid, 2)) {
@ -565,7 +565,7 @@ static int muscle_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *cmd,
case SC_AC_AUT:
case SC_AC_NONE:
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported authentication method\n");
sc_log(card->ctx, "Unsupported authentication method\n");
return SC_ERROR_NOT_SUPPORTED;
}
case SC_PIN_CMD_CHANGE:
@ -581,7 +581,7 @@ static int muscle_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *cmd,
case SC_AC_AUT:
case SC_AC_NONE:
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported authentication method\n");
sc_log(card->ctx, "Unsupported authentication method\n");
return SC_ERROR_NOT_SUPPORTED;
}
case SC_PIN_CMD_UNBLOCK:
@ -597,11 +597,11 @@ static int muscle_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *cmd,
case SC_AC_AUT:
case SC_AC_NONE:
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported authentication method\n");
sc_log(card->ctx, "Unsupported authentication method\n");
return SC_ERROR_NOT_SUPPORTED;
}
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported command\n");
sc_log(card->ctx, "Unsupported command\n");
return SC_ERROR_NOT_SUPPORTED;
}
@ -678,34 +678,34 @@ static int muscle_set_security_env(sc_card_t *card,
if (env->operation != SC_SEC_OPERATION_SIGN &&
env->operation != SC_SEC_OPERATION_DECIPHER) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid crypto operation supplied.\n");
sc_log(card->ctx, "Invalid crypto operation supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (env->algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid crypto algorithm supplied.\n");
sc_log(card->ctx, "Invalid crypto algorithm supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
/* ADJUST FOR PKCS1 padding support for decryption only */
if ((env->algorithm_flags & SC_ALGORITHM_RSA_PADS) ||
(env->algorithm_flags & SC_ALGORITHM_RSA_HASHES)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Card supports only raw RSA.\n");
sc_log(card->ctx, "Card supports only raw RSA.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
if (env->key_ref_len != 1 ||
(env->key_ref[0] > 0x0F)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Invalid key reference supplied.\n");
sc_log(card->ctx, "Invalid key reference supplied.\n");
return SC_ERROR_NOT_SUPPORTED;
}
priv->rsa_key_ref = env->key_ref[0];
}
if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Algorithm reference not supported.\n");
sc_log(card->ctx, "Algorithm reference not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
/* if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT)
if (memcmp(env->file_ref.value, "\x00\x12", 2) != 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File reference is not 0012.\n");
sc_log(card->ctx, "File reference is not 0012.\n");
return SC_ERROR_NOT_SUPPORTED;
} */
priv->env = *env;
@ -736,7 +736,7 @@ static int muscle_decipher(sc_card_t * card,
key_id = priv->rsa_key_ref * 2; /* Private key */
if (out_len < crgram_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Output buffer too small");
sc_log(card->ctx, "Output buffer too small");
return SC_ERROR_BUFFER_TOO_SMALL;
}
@ -762,7 +762,7 @@ static int muscle_compute_signature(sc_card_t *card, const u8 *data,
key_id = priv->rsa_key_ref * 2; /* Private key */
if (outlen < data_len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Output buffer too small");
sc_log(card->ctx, "Output buffer too small");
return SC_ERROR_BUFFER_TOO_SMALL;
}

View File

@ -1155,7 +1155,7 @@ pgp_enumerate_blob(sc_card_t *card, pgp_blob_t *blob)
r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
&cla, &tag, &len);
if (r < 0 || data == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Unexpected end of contents\n");
return SC_ERROR_OBJECT_NOT_VALID;
}

View File

@ -149,7 +149,7 @@ static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file)
{
method = sec_attr_to_method(file->sec_attr[1 + 6]);
key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 6]);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"SC_AC_OP_DELETE %i %lu\n",
(int)method, key_ref);
sc_file_add_acl_entry(file, SC_AC_OP_DELETE, method, key_ref);
@ -158,7 +158,7 @@ static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file)
{
method = sec_attr_to_method(file->sec_attr[1 + 0]);
key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 0]);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
(file->type == SC_FILE_TYPE_DF) ?
"SC_AC_OP_CREATE %i %lu\n"
: "SC_AC_OP_READ %i %lu\n",
@ -176,11 +176,11 @@ static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file)
{
method = sec_attr_to_method(file->sec_attr[1 + 1]);
key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 1]);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"SC_AC_OP_UPDATE %i %lu\n",
(int)method, key_ref);
sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, method, key_ref);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"SC_AC_OP_WRITE %i %lu\n",
(int)method, key_ref);
sc_file_add_acl_entry(file, SC_AC_OP_WRITE, method, key_ref);
@ -379,7 +379,7 @@ static int rtecp_cipher(sc_card_t *card, const u8 *data, size_t data_len,
assert(buf);
free(buf);
if (r)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "APDU transmit failed: %s\n", sc_strerror(r));
sc_log(card->ctx, "APDU transmit failed: %s\n", sc_strerror(r));
else
{
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
@ -435,7 +435,7 @@ static int rtecp_change_reference_data(sc_card_t *card, unsigned int type,
int transmits_num, r;
assert(card && card->ctx && newref);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"newlen = %"SC_FORMAT_LEN_SIZE_T"u\n", newlen);
if (newlen > 0xFFFF)
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
@ -649,12 +649,12 @@ static int rtecp_card_ctl(sc_card_t *card, unsigned long request, void *data)
apdu.le = 256;
break;
case SC_CARDCTL_LIFECYCLE_SET:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n",
sc_log(card->ctx, "%s\n",
"SC_CARDCTL_LIFECYCLE_SET not supported");
/* no call sc_debug (SC_FUNC_RETURN) */
return SC_ERROR_NOT_SUPPORTED;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"request = 0x%lx\n", request);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED);
}

View File

@ -103,7 +103,7 @@ static int rutoken_match_card(sc_card_t *card)
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (_sc_match_atr(card, rutoken_atrs, &card->type) >= 0)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "ATR recognized as Rutoken\n");
sc_log(card->ctx, "ATR recognized as Rutoken\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 1);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 0);
@ -202,12 +202,12 @@ static int rutoken_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
for (i = 0; i < sizeof(rutoken_errors)/sizeof(rutoken_errors[0]); ++i) {
if (rutoken_errors[i].SWs == ((sw1 << 8) | sw2)) {
if ( rutoken_errors[i].errorstr )
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n", rutoken_errors[i].errorstr);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "sw1 = %x, sw2 = %x", sw1, sw2);
sc_log(card->ctx, "%s\n", rutoken_errors[i].errorstr);
sc_log(card->ctx, "sw1 = %x, sw2 = %x", sw1, sw2);
return rutoken_errors[i].errorno;
}
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
return SC_ERROR_CARD_CMD_FAILED;
}
@ -312,7 +312,7 @@ static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file)
SC_AC_NONE, SC_AC_KEY_REF_NONE);
if (file->sec_attr[0] & 0x40) /* if AccessMode.6 */
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SC_AC_OP_DELETE %i %i",
sc_log(card->ctx, "SC_AC_OP_DELETE %i %i",
(int)(*(int8_t*)&file->sec_attr[1 +6]),
file->sec_attr[1+7 +6*4]);
sc_file_add_acl_entry(file, SC_AC_OP_DELETE,
@ -321,7 +321,7 @@ static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file)
}
if (file->sec_attr[0] & 0x01) /* if AccessMode.0 */
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, (file->type == SC_FILE_TYPE_DF) ?
sc_log(card->ctx, (file->type == SC_FILE_TYPE_DF) ?
"SC_AC_OP_CREATE %i %i" : "SC_AC_OP_READ %i %i",
(int)(*(int8_t*)&file->sec_attr[1 +0]),
file->sec_attr[1+7 +0*4]);
@ -339,13 +339,13 @@ static void set_acl_from_sec_attr(sc_card_t *card, sc_file_t *file)
else
if (file->sec_attr[0] & 0x02) /* if AccessMode.1 */
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SC_AC_OP_UPDATE %i %i",
sc_log(card->ctx, "SC_AC_OP_UPDATE %i %i",
(int)(*(int8_t*)&file->sec_attr[1 +1]),
file->sec_attr[1+7 +1*4]);
sc_file_add_acl_entry(file, SC_AC_OP_UPDATE,
(int)(*(int8_t*)&file->sec_attr[1 +1]),
file->sec_attr[1+7 +1*4]);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SC_AC_OP_WRITE %i %i",
sc_log(card->ctx, "SC_AC_OP_WRITE %i %i",
(int)(*(int8_t*)&file->sec_attr[1 +1]),
file->sec_attr[1+7 +1*4]);
sc_file_add_acl_entry(file, SC_AC_OP_WRITE,
@ -460,14 +460,14 @@ static int rutoken_process_fci(struct sc_card *card, sc_file_t *file,
/* Rutoken S returns buffers in little-endian. */
/* Set correct file id. */
file->id = ((file->id & 0xFF) << 8) | ((file->id >> 8) & 0xFF);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, " file identifier: 0x%04X", file->id);
sc_log(card->ctx, " file identifier: 0x%04X", file->id);
/* Determine file size. */
tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x80, &taglen);
/* Rutoken S always returns 2 bytes. */
if (tag != NULL && taglen == 2)
{
file->size = (tag[1] << 8) | tag[0];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, " bytes in file: %"SC_FORMAT_LEN_SIZE_T"u", file->size);
sc_log(card->ctx, " bytes in file: %"SC_FORMAT_LEN_SIZE_T"u", file->size);
}
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, ret);
@ -560,7 +560,7 @@ static int set_sec_attr_from_acl(sc_card_t *card, sc_file_t *file)
conv_attr = arr_convert_attr_ef;
n_conv_attr = sizeof(arr_convert_attr_ef)/sizeof(arr_convert_attr_ef[0]);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "file->type = %i", file->type);
sc_log(card->ctx, "file->type = %i", file->type);
for (i = 0; i < n_conv_attr; ++i)
{
@ -571,20 +571,20 @@ static int set_sec_attr_from_acl(sc_card_t *card, sc_file_t *file)
{
/* AccessMode.[conv_attr[i].sec_attr_pos] */
attr[0] |= 1 << conv_attr[i].sec_attr_pos;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"AccessMode.%"SC_FORMAT_LEN_SIZE_T"u, attr[0]=0x%x",
conv_attr[i].sec_attr_pos, attr[0]);
attr[1 + conv_attr[i].sec_attr_pos] = (u8)entry->method;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "method %u", (u8)entry->method);
sc_log(card->ctx, "method %u", (u8)entry->method);
if (entry->method == SC_AC_CHV)
{
attr[1+7 + conv_attr[i].sec_attr_pos*4] = (u8)entry->key_ref;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "key_ref %u", (u8)entry->key_ref);
sc_log(card->ctx, "key_ref %u", (u8)entry->key_ref);
}
}
else
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "ACL (%u) not set, set default sec_attr",
sc_log(card->ctx, "ACL (%u) not set, set default sec_attr",
conv_attr[i].ac_op);
memcpy(attr, default_sec_attr, sizeof(attr));
break;
@ -620,7 +620,7 @@ static int rutoken_delete_file(sc_card_t *card, const sc_path_t *path)
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (!path || path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2))
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID\n");
sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
if (path->len == sizeof(sbuf))
@ -739,7 +739,7 @@ static int rutoken_reset_retry_counter(sc_card_t *card, unsigned int type,
if (puk && puklen)
{
ret = rutoken_verify(card, type, ref_qualifier, puk, puklen, &left);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Tries left: %i\n", left);
sc_log(card->ctx, "Tries left: %i\n", left);
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, ret, "Invalid 'puk' pass");
}
#endif
@ -784,7 +784,7 @@ static int rutoken_set_security_env(sc_card_t *card,
senv->algorithm = SC_ALGORITHM_GOST;
if (env->key_ref_len != 1)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No or invalid key reference\n");
sc_log(card->ctx, "No or invalid key reference\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
data[2] = env->key_ref[0];
@ -1002,7 +1002,7 @@ static int rutoken_cipher_p(sc_card_t *card, const u8 * crgram, size_t crgram_le
sc_apdu_t apdu;
LOG_FUNC_CALLED(card->ctx);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
": crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u",
crgram_len, outlen);
@ -1047,7 +1047,7 @@ static int rutoken_cipher_p(sc_card_t *card, const u8 * crgram, size_t crgram_le
}
}
} while (ret == SC_SUCCESS && crgram_len != 0);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"len out cipher %"SC_FORMAT_LEN_SIZE_T"u\n",
outlen - outlen_tail);
if (ret == SC_SUCCESS)
@ -1259,7 +1259,7 @@ static int rutoken_card_ctl(sc_card_t *card, unsigned long cmd, void *ptr)
ret = rutoken_format(card, 0x7b); /* APDU: FORMAT END */
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cmd = %lu", cmd);
sc_log(card->ctx, "cmd = %lu", cmd);
ret = SC_ERROR_NOT_SUPPORTED;
break;
}

View File

@ -725,12 +725,12 @@ static int sc_hsm_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
#ifdef ENABLE_SM
if (card->sm_ctx.sm_mode != SM_MODE_TRANSMIT) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Session PIN generation only supported in SM");
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}
#else
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Session PIN generation only supported in SM");
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
#endif
@ -741,7 +741,7 @@ static int sc_hsm_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
apdu.le = 0;
if (sc_transmit_apdu(card, &apdu) != SC_SUCCESS
|| sc_check_sw(card, apdu.sw1, apdu.sw2) != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Generating session PIN failed");
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}
@ -751,12 +751,12 @@ static int sc_hsm_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
apdu.resplen);
data->pin2.len = apdu.resplen;
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Buffer too small for session PIN");
}
}
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Session PIN not supported for this PIN (0x%02X)",
data->pin_reference);
}
@ -792,7 +792,7 @@ static int sc_hsm_read_binary(sc_card_t *card,
int r;
if (idx > 0xffff) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "invalid EF offset: 0x%X > 0xFFFF", idx);
sc_log(ctx, "invalid EF offset: 0x%X > 0xFFFF", idx);
return SC_ERROR_OFFSET_TOO_LARGE;
}
@ -834,7 +834,7 @@ static int sc_hsm_write_ef(sc_card_t *card,
int r;
if (idx > 0xffff) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "invalid EF offset: 0x%X > 0xFFFF", idx);
sc_log(ctx, "invalid EF offset: 0x%X > 0xFFFF", idx);
return SC_ERROR_OFFSET_TOO_LARGE;
}
@ -946,7 +946,7 @@ static int sc_hsm_delete_file(sc_card_t *card, const sc_path_t *path)
int r;
if ((path->type != SC_PATH_TYPE_FILE_ID) || (path->len != 2)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID");
sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID");
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
}

View File

@ -130,7 +130,7 @@ static int setcos_match_card(sc_card_t *card)
card->type = SC_CARD_TYPE_SETCOS_EID_V2_1;
else {
buf[sizeof(buf) - 1] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SetCOS EID applet %s is not supported", (char *) buf);
sc_log(card->ctx, "SetCOS EID applet %s is not supported", (char *) buf);
return 0;
}
return 1;
@ -473,7 +473,7 @@ static int setcos_create_file_44(sc_card_t *card, sc_file_t *file)
break;
case SC_AC_CHV: /* pin */
if ((bNumber & 0x7F) == 0 || (bNumber & 0x7F) > 7) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "SetCOS 4.4 PIN refs can only be 1..7\n");
sc_log(card->ctx, "SetCOS 4.4 PIN refs can only be 1..7\n");
return SC_ERROR_INVALID_ARGUMENTS;
}
bCommands_pin[setcos_pin_index_44(pins, sizeof(pins), (int) bNumber)] |= 1 << i;
@ -575,11 +575,11 @@ static int setcos_set_security_env2(sc_card_t *card,
card->type == SC_CARD_TYPE_SETCOS_NIDEL ||
SETCOS_IS_EID_APPLET(card)) {
if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "symmetric keyref not supported.\n");
sc_log(card->ctx, "symmetric keyref not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
if (se_num > 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "restore security environment not supported.\n");
sc_log(card->ctx, "restore security environment not supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
}
@ -640,13 +640,13 @@ static int setcos_set_security_env2(sc_card_t *card,
if (apdu.datalen != 0) {
r = sc_transmit_apdu(card, &apdu);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"%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,
sc_log(card->ctx,
"%s: Card returned error", sc_strerror(r));
goto err;
}
@ -674,7 +674,7 @@ static int setcos_set_security_env(sc_card_t *card,
tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT;
tmp.flags |= SC_SEC_ENV_ALG_REF_PRESENT;
if (tmp.algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Only RSA algorithm supported.\n");
sc_log(card->ctx, "Only RSA algorithm supported.\n");
return SC_ERROR_NOT_SUPPORTED;
}
switch (card->type) {
@ -687,7 +687,7 @@ static int setcos_set_security_env(sc_card_t *card,
case SC_CARD_TYPE_SETCOS_EID_V2_1:
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Card does not support RSA.\n");
sc_log(card->ctx, "Card does not support RSA.\n");
return SC_ERROR_NOT_SUPPORTED;
break;
}

View File

@ -84,7 +84,7 @@ typedef struct starcos_ex_data_st {
#define CHECK_NOT_SUPPORTED_V3_4(card) \
do { \
if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
sc_debug((card)->ctx, SC_LOG_DEBUG_NORMAL, \
sc_log((card)->ctx, \
"not supported for STARCOS 3.4 cards"); \
return SC_ERROR_NOT_SUPPORTED; \
} \
@ -189,7 +189,7 @@ static int process_fci(sc_context_t *ctx, sc_file_t *file,
size_t taglen, len = buflen;
const u8 *tag = NULL, *p;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "processing FCI bytes\n");
sc_log(ctx, "processing FCI bytes\n");
if (buflen < 2)
return SC_ERROR_INTERNAL;
@ -210,7 +210,7 @@ static int process_fci(sc_context_t *ctx, sc_file_t *file,
tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" bytes in file: %d\n", bytes);
file->size = bytes;
}
@ -259,9 +259,9 @@ static int process_fci(sc_context_t *ctx, sc_file_t *file,
}
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" type: %s\n", type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" EF structure: %s\n", structure);
}
file->magic = SC_FILE_MAGIC;
@ -275,7 +275,7 @@ static int process_fci_v3_4(sc_context_t *ctx, sc_file_t *file,
size_t taglen, len = buflen;
const u8 *tag = NULL, *p;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"processing %"SC_FORMAT_LEN_SIZE_T"u FCI bytes\n", buflen);
if (buflen < 2)
@ -299,7 +299,7 @@ static int process_fci_v3_4(sc_context_t *ctx, sc_file_t *file,
if (tag != NULL && taglen > 0 && taglen <= 16) {
memcpy(file->name, tag, taglen);
file->namelen = taglen;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "filename %s",
sc_log(ctx, "filename %s",
sc_dump_hex(file->name, file->namelen));
}
return SC_SUCCESS;
@ -311,7 +311,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
size_t taglen, len = buflen;
const u8 *tag = NULL, *p;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"processing %"SC_FORMAT_LEN_SIZE_T"u FCP bytes\n", buflen);
if (buflen < 2)
@ -326,7 +326,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" bytes in file: %d\n", bytes);
file->size = bytes;
}
@ -334,7 +334,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
tag = sc_asn1_find_tag(ctx, p, len, 0xc5, &taglen);
if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" bytes in file 2: %d\n", bytes);
file->size = bytes;
}
@ -388,9 +388,9 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
break;
}
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" type: %s\n", type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" EF structure: %s\n", structure);
if (taglen >= 2) {
if (tag[1] != 0x41 || taglen != 5) {
@ -399,7 +399,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
/* formatted EF */
file->record_length = (tag[2] << 8) + tag[3];
file->record_count = tag[4];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
" rec_len: %d rec_cnt: %d\n\n",
file->record_length, file->record_count);
}
@ -408,7 +408,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
if (tag != NULL && taglen >= 2) {
file->id = (tag[0] << 8) | tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " file identifier: 0x%02X%02X\n",
sc_log(ctx, " file identifier: 0x%02X%02X\n",
tag[0], tag[1]);
}
@ -416,7 +416,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
if (tag != NULL && taglen > 0 && taglen <= 16) {
memcpy(file->name, tag, taglen);
file->namelen = taglen;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " filename %s",
sc_log(ctx, " filename %s",
sc_dump_hex(file->name, file->namelen));
}
@ -440,7 +440,7 @@ static int process_fcp_v3_4(sc_context_t *ctx, sc_file_t *file,
default:
break;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " file status: %s\n", status);
sc_log(ctx, " file status: %s\n", status);
}
file->magic = SC_FILE_MAGIC;
@ -648,7 +648,7 @@ static int starcos_select_file(sc_card_t *card,
if (r != SC_SUCCESS)
pbuf[0] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"current path (%s, %s): %s (len: %"SC_FORMAT_LEN_SIZE_T"u)\n",
card->cache.current_path.type == SC_PATH_TYPE_DF_NAME ?
"aid" : "path",
@ -673,7 +673,7 @@ static int starcos_select_file(sc_card_t *card,
&& card->cache.current_path.len == pathlen
&& memcmp(card->cache.current_path.value, pathbuf, pathlen) == 0 )
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cache hit\n");
sc_log(card->ctx, "cache hit\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
}
else
@ -757,7 +757,7 @@ static int starcos_select_file(sc_card_t *card,
{
/* done: we are already in the
* requested directory */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"cache hit\n");
/* copy file info (if necessary) */
if (file_out) {
@ -984,7 +984,7 @@ static int starcos_create_mf(sc_card_t *card, sc_starcos_create_data *data)
CHECK_NOT_SUPPORTED_V3_4(card);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "creating MF \n");
sc_log(ctx, "creating MF \n");
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
apdu.cla |= 0x80;
apdu.lc = 19;
@ -1015,9 +1015,9 @@ static int starcos_create_df(sc_card_t *card, sc_starcos_create_data *data)
CHECK_NOT_SUPPORTED_V3_4(card);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "creating DF\n");
sc_log(ctx, "creating DF\n");
/* first step: REGISTER DF */
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "calling REGISTER DF\n");
sc_log(ctx, "calling REGISTER DF\n");
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x52,
data->data.df.size[0], data->data.df.size[1]);
@ -1030,7 +1030,7 @@ static int starcos_create_df(sc_card_t *card, sc_starcos_create_data *data)
r = sc_transmit_apdu(card, &apdu);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed");
/* second step: CREATE DF */
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "calling CREATE DF\n");
sc_log(ctx, "calling CREATE DF\n");
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x01, 0x00);
apdu.cla |= 0x80;
@ -1060,7 +1060,7 @@ static int starcos_create_ef(sc_card_t *card, sc_starcos_create_data *data)
CHECK_NOT_SUPPORTED_V3_4(card);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "creating EF\n");
sc_log(ctx, "creating EF\n");
sc_format_apdu(card,&apdu,SC_APDU_CASE_3_SHORT,0xE0,0x03,0x00);
apdu.cla |= 0x80;
@ -1378,7 +1378,7 @@ static int starcos_set_security_env(sc_card_t *card,
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"not supported for STARCOS 3.4 cards");
return SC_ERROR_NOT_SUPPORTED;
}
@ -1718,14 +1718,14 @@ static int starcos_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
const int err_count = sizeof(starcos_errors)/sizeof(starcos_errors[0]);
int i;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
if (sw1 == 0x90)
return SC_SUCCESS;
if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Verification failed (remaining tries: %d)\n",
sc_log(card->ctx, "Verification failed (remaining tries: %d)\n",
(sw2 & 0x0f));
return SC_ERROR_PIN_CODE_INCORRECT;
}
@ -1734,7 +1734,7 @@ static int starcos_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
for (i = 0; i < err_count; i++)
if (starcos_errors[i].SWs == ((sw1 << 8) | sw2))
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n", starcos_errors[i].errorstr);
sc_log(card->ctx, "%s\n", starcos_errors[i].errorstr);
return starcos_errors[i].errorno;
}

View File

@ -309,7 +309,7 @@ static void parse_sec_attr(sc_card_t *card,
op = map_operations (buf[0]);
if (op == (unsigned int)-1)
{
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Unknown security command byte %02x\n",
buf[0]);
continue;
@ -397,7 +397,7 @@ static int tcos_select_file(sc_card_t *card,
if (r || file_out == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
if (apdu.resplen < 1 || apdu.resp[0] != 0x62){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "received invalid template %02X\n", apdu.resp[0]);
sc_log(ctx, "received invalid template %02X\n", apdu.resp[0]);
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);
}
@ -436,7 +436,7 @@ static int tcos_list_files(sc_card_t *card, u8 *buf, size_t buflen)
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "List Dir failed");
if (apdu.resplen > buflen) return SC_ERROR_BUFFER_TOO_SMALL;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"got %"SC_FORMAT_LEN_SIZE_T"u %s-FileIDs\n",
apdu.resplen / 2, p1 == 1 ? "DF" : "EF");
@ -457,7 +457,7 @@ static int tcos_delete_file(sc_card_t *card, const sc_path_t *path)
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID\n");
sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
sbuf[0] = path->value[0];
@ -491,15 +491,15 @@ static int tcos_set_security_env(sc_card_t *card, const sc_security_env_t *env,
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
}
if(!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT))
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"No Key-Reference in SecEnvironment\n");
else
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Key-Reference %02X (len=%"SC_FORMAT_LEN_SIZE_T"u)\n",
env->key_ref[0], env->key_ref_len);
/* Key-Reference 0x80 ?? */
default_key= !(env->flags & SC_SEC_ENV_KEY_REF_PRESENT) || (env->key_ref_len==1 && env->key_ref[0]==0x80);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"TCOS3:%d PKCS1:%d\n", tcos3,
!!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1));
@ -520,12 +520,12 @@ static int tcos_set_security_env(sc_card_t *card, const sc_security_env_t *env,
r=sc_transmit_apdu(card, &apdu);
if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"%s: APDU transmit failed", sc_strerror(r));
return r;
}
if (apdu.sw1==0x6A && (apdu.sw2==0x81 || apdu.sw2==0x88)) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Detected Signature-Only key\n");
if (env->operation==SC_SEC_OPERATION_SIGN && default_key) return SC_SUCCESS;
}
@ -554,7 +554,7 @@ static int tcos_compute_signature(sc_card_t *card, const u8 * data, size_t datal
if(((tcos_data *)card->drv_data)->next_sign){
if(datalen>48){
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Data to be signed is too long (TCOS supports max. 48 bytes)\n");
sc_log(card->ctx, "Data to be signed is too long (TCOS supports max. 48 bytes)\n");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
}
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0x9A);
@ -616,7 +616,7 @@ static int tcos_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len,
data=(tcos_data *)card->drv_data;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"TCOS3:%d PKCS1:%d\n",tcos3,
!!(data->pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1));

View File

@ -88,7 +88,7 @@ static int westcos_get_default_key(sc_card_t * card,
struct sc_cardctl_default_key *data)
{
const char *default_key;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"westcos_get_default_key:data->method=%d, data->key_ref=%d\n",
data->method, data->key_ref);
if (data->method != SC_AC_AUT || data->key_ref != 0)
@ -295,17 +295,17 @@ static int westcos_process_fci(sc_card_t * card, sc_file_t * file,
sc_context_t *ctx = card->ctx;
size_t taglen, len = buflen;
const u8 *tag = NULL, *p = buf;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "processing FCI bytes\n");
sc_log(card->ctx, "processing FCI bytes\n");
tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
if (tag != NULL && taglen == 2) {
file->id = (tag[0] << 8) | tag[1];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" file identifier: 0x%02X%02X\n", tag[0], tag[1]);
}
tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" bytes in file: %d\n", bytes);
file->size = bytes;
}
@ -313,7 +313,7 @@ static int westcos_process_fci(sc_card_t * card, sc_file_t * file,
tag = sc_asn1_find_tag(ctx, p, len, 0x81, &taglen);
if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" bytes in file: %d\n", bytes);
file->size = bytes;
}
@ -324,7 +324,7 @@ static int westcos_process_fci(sc_card_t * card, sc_file_t * file,
unsigned char byte = tag[0];
const char *type;
file->shareable = 0;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" shareable: %s\n",
(file->shareable) ? "yes" : "no");
file->ef_structure = SC_FILE_EF_UNKNOWN;
@ -351,9 +351,9 @@ static int westcos_process_fci(sc_card_t * card, sc_file_t * file,
default:
type = "unknown";
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" type: %s\n", type);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
" EF structure: %d\n", file->ef_structure);
}
}
@ -507,7 +507,7 @@ static int westcos_create_file(sc_card_t *card, struct sc_file *file)
int buflen;
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "westcos_create_file\n");
sc_log(card->ctx, "westcos_create_file\n");
memset(buf, 0, sizeof(buf));
/* transport key */
@ -593,7 +593,7 @@ static int westcos_create_file(sc_card_t *card, struct sc_file *file)
p1 = (file->id) / 256;
p2 = (file->id) % 256;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"create file %s, id %X size %"SC_FORMAT_LEN_SIZE_T"u\n",
file->path.value, file->id, file->size);
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, p1, p2);
@ -614,7 +614,7 @@ static int westcos_delete_file(sc_card_t * card, const sc_path_t * path_in)
sc_apdu_t apdu;
if (card == NULL || path_in == NULL || path_in->len < 2)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "westcos_delete_file\n");
sc_log(card->ctx, "westcos_delete_file\n");
if (path_in->len > 2) {
r = sc_select_file(card, path_in, NULL);
if (r)
@ -639,7 +639,7 @@ static int westcos_list_files(sc_card_t * card, u8 * buf, size_t buflen)
sc_apdu_t apdu;
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "westcos_list_files\n");
sc_log(card->ctx, "westcos_list_files\n");
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x34, 0x00, 0x00);
apdu.cla = 0x80;
apdu.le = buflen;
@ -688,7 +688,7 @@ static int westcos_pin_cmd(sc_card_t * card, struct sc_pin_cmd_data *data,
int pad = 0, use_pin_pad = 0, ins, p1 = 0;
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"westcos_pin_cmd:data->pin_type=%X, data->cmd=%X\n",
data->pin_type, data->cmd);
if (tries_left)
@ -859,7 +859,7 @@ static int westcos_card_ctl(sc_card_t * card, unsigned long cmd, void *ptr)
priv_data_t *priv_data = NULL;
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"westcos_card_ctl cmd = %lX\n", cmd);
priv_data = (priv_data_t *) card->drv_data;
switch (cmd) {
@ -1044,7 +1044,7 @@ static int westcos_set_security_env(sc_card_t *card,
priv_data_t *priv_data = NULL;
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"westcos_set_security_env\n");
priv_data = (priv_data_t *) card->drv_data;
priv_data->env = *env;
@ -1082,7 +1082,7 @@ static int westcos_restore_security_env(sc_card_t *card, int se_num)
{
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"westcos_restore_security_env\n");
return 0;
}
@ -1105,7 +1105,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
if (card == NULL)
return SC_ERROR_INVALID_ARGUMENTS;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"westcos_sign_decipher outlen=%"SC_FORMAT_LEN_SIZE_T"u\n",
outlen);
@ -1161,7 +1161,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
alire = min(((keyfile->size) - idx), sizeof(buf));
if (alire <= 0)
break;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"idx = %d, alire=%d\n", idx, alire);
r = sc_read_binary(card, idx, buf, alire, 0);
if (r < 0)
@ -1171,7 +1171,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
} while (1);
BIO_set_mem_eof_return(mem, -1);
if (!d2i_RSAPrivateKey_bio(mem, &rsa)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"RSA key invalid, %lu\n", ERR_get_error());
r = SC_ERROR_UNKNOWN;
goto out;
@ -1181,7 +1181,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
RSA_set_method(rsa, RSA_PKCS1_OpenSSL());
if ((size_t)RSA_size(rsa) > outlen) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Buffer too small\n");
sc_log(card->ctx, "Buffer too small\n");
r = SC_ERROR_OUT_OF_MEMORY;
goto out;
}
@ -1194,7 +1194,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
print_openssl_error();
#endif
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Decipher error %lu\n", ERR_get_error());
r = SC_ERROR_UNKNOWN;
goto out;
@ -1210,7 +1210,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
print_openssl_error();
#endif
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Signature error %lu\n", ERR_get_error());
r = SC_ERROR_UNKNOWN;
goto out;
@ -1219,7 +1219,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
#else
if (RSA_sign(nid, data, data_len, out, &outlen, rsa) != 1) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"RSA_sign error %d \n", ERR_get_error());
r = SC_ERROR_UNKNOWN;
goto out;

View File

@ -1381,7 +1381,7 @@ sc_card_sm_load(struct sc_card *card, const char *module_path, const char *in_mo
if (0 < expanded_len && expanded_len < sizeof expanded_val)
module_path = expanded_val;
#endif
sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "SM module '%s' located in '%s'", in_module, module_path);
sc_log(ctx, "SM module '%s' located in '%s'", in_module, module_path);
if (module_path && strlen(module_path) > 0) {
int sz = strlen(in_module) + strlen(module_path) + 3;
module = malloc(sz);

View File

@ -202,7 +202,7 @@ ctbcs_pin_cmd(sc_reader_t *reader, struct sc_pin_cmd_data *data)
return r;
break;
default:
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "Unknown PIN command %d", data->cmd);
sc_log(reader->ctx, "Unknown PIN command %d", data->cmd);
return SC_ERROR_NOT_SUPPORTED;
}
@ -219,7 +219,7 @@ ctbcs_pin_cmd(sc_reader_t *reader, struct sc_pin_cmd_data *data)
r = sc_transmit_apdu(card, &apdu);
s = sc_mutex_destroy(reader->ctx, card->mutex);
if (s != SC_SUCCESS) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "unable to destroy mutex\n");
sc_log(reader->ctx, "unable to destroy mutex\n");
return s;
}
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r, "APDU transmit failed");

View File

@ -58,7 +58,7 @@ int msc_list_objects(sc_card_t* card, u8 next, mscfs_file_t* file) {
if(apdu.resplen == 0) /* No more left */
return 0;
if (apdu.resplen != 14) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"expected 14 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n",
apdu.resplen);
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
@ -80,7 +80,7 @@ int msc_partial_read_object(sc_card_t *card, msc_id objectId, int offset, u8 *da
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x56, 0x00, 0x00);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"READ: Offset: %x\tLength: %"SC_FORMAT_LEN_SIZE_T"u\n", offset,
dataLength);
memcpy(buffer, objectId.id, 4);
@ -106,7 +106,7 @@ int msc_partial_read_object(sc_card_t *card, msc_id objectId, int offset, u8 *da
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
}
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2);
return dataLength;
@ -169,7 +169,7 @@ int msc_create_object(sc_card_t *card, msc_id objectId, size_t objectSize, unsig
}
}
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
msc_zero_object(card, objectId, objectSize);
@ -186,7 +186,7 @@ int msc_partial_update_object(sc_card_t *card, msc_id objectId, int offset, cons
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x54, 0x00, 0x00);
apdu.lc = dataLength + 9;
if (card->ctx->debug >= 2)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"WRITE: Offset: %x\tLength: %"SC_FORMAT_LEN_SIZE_T"u\n",
offset, dataLength);
@ -211,7 +211,7 @@ int msc_partial_update_object(sc_card_t *card, msc_id objectId, int offset, cons
}
}
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
return dataLength;
@ -250,7 +250,7 @@ int msc_delete_object(sc_card_t *card, msc_id objectId, int zero)
}
}
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
return 0;
@ -476,7 +476,7 @@ int msc_get_challenge(sc_card_t *card, unsigned short dataLength, unsigned short
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
@ -488,7 +488,7 @@ int msc_get_challenge(sc_card_t *card, unsigned short dataLength, unsigned short
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
@ -549,7 +549,7 @@ int msc_generate_keypair(sc_card_t *card, int privateKey, int publicKey, int alg
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
@ -576,7 +576,7 @@ int msc_extract_key(sc_card_t *card,
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
@ -682,7 +682,7 @@ int msc_compute_crypt_init(sc_card_t *card,
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "init: got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "init: got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
@ -732,7 +732,7 @@ int msc_compute_crypt_final(
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "final: got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "final: got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
@ -799,7 +799,7 @@ static int msc_compute_crypt_final_object(
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "final: got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "final: got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
} else {
@ -967,7 +967,7 @@ int msc_import_key(sc_card_t *card,
r = sc_check_sw(card, apdu.sw1, apdu.sw2);
if (r) {
if (card->ctx->debug >= 2) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "keyimport: got strange SWs: 0x%02X 0x%02X\n",
sc_log(card->ctx, "keyimport: got strange SWs: 0x%02X 0x%02X\n",
apdu.sw1, apdu.sw2);
}
/* this is last ditch cleanup */

View File

@ -148,32 +148,32 @@ CERT_HANDLE_FUNCTION(default_cert_handle) {
int modulus_len = 0;
const prdata* key = get_prkey_by_cert(items, cert);
if(!key) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Error: No key for this certificate");
sc_log(p15card->card->ctx, "Error: No key for this certificate");
return SC_ERROR_INTERNAL;
}
if(!d2i_X509(&cert_data, (const u8**)&data, length)) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Error converting certificate");
sc_log(p15card->card->ctx, "Error converting certificate");
return SC_ERROR_INTERNAL;
}
pkey = X509_get_pubkey(cert_data);
if(pkey == NULL) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Error: no public key associated with the certificate");
sc_log(p15card->card->ctx, "Error: no public key associated with the certificate");
r = SC_ERROR_INTERNAL;
goto err;
}
certtype = X509_certificate_type(cert_data, pkey);
if(! (EVP_PK_RSA & certtype)) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Error: certificate is not for an RSA key");
sc_log(p15card->card->ctx, "Error: certificate is not for an RSA key");
r = SC_ERROR_INTERNAL;
goto err;
}
rsa = EVP_PKEY_get0_RSA(pkey);
if( rsa == NULL) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Error: no modulus associated with the certificate");
sc_log(p15card->card->ctx, "Error: no modulus associated with the certificate");
r = SC_ERROR_INTERNAL;
goto err;
}

View File

@ -216,7 +216,7 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
*/
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"sc_card_ctl rc=%d",r);
sc_log(card->ctx, "sc_card_ctl rc=%d",r);
p15card->tokeninfo->serial_number = strdup("00000000");
} else {
sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
@ -227,7 +227,7 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
/* TODO we should not create PIN objects if it is not initialized
* (opensc-tool -s 0020000000 returns 0x6A 0x88)
*/
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "CAC adding pins...");
sc_log(card->ctx, "CAC adding pins...");
for (i = 0; pins[i].id; i++) {
struct sc_pkcs15_auth_info pin_info;
struct sc_pkcs15_object pin_obj;
@ -249,7 +249,7 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
pin_info.tries_left = -1;
label = pins[i].label;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "CAC Adding pin %d label=%s",i, label);
sc_log(card->ctx, "CAC Adding pin %d label=%s",i, label);
strncpy(pin_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
pin_obj.flags = pins[i].obj_flags;
@ -292,7 +292,7 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
* We need to read the cert, get modulus and keylen
* We use those for the pubkey, and priv key objects.
*/
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "CAC adding certs, pub and priv keys...");
sc_log(card->ctx, "CAC adding certs, pub and priv keys...");
r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_INIT_GET_CERT_OBJECTS, &count);
LOG_TEST_RET(card->ctx, r, "Can not initiate cert objects.");
@ -345,12 +345,12 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
r = sc_pkcs15_read_file(p15card, &cert_info.path, &cert_der.value, &cert_der.len);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No cert found,i=%d", i);
sc_log(card->ctx, "No cert found,i=%d", i);
continue;
}
cert_info.path.count = cert_der.len;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"cert len=%"SC_FORMAT_LEN_SIZE_T"u, cert_info.path.count=%d r=%d\n",
cert_der.len, cert_info.path.count, r);
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "cert", cert_der.value, cert_der.len);
@ -366,7 +366,7 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
/* following will find the cached cert in cert_info */
r = sc_pkcs15_read_certificate(p15card, &cert_info, &cert_out);
if (r < 0 || cert_out->key == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to read/parse the certificate r=%d",r);
sc_log(card->ctx, "Failed to read/parse the certificate r=%d",r);
if (cert_out != NULL)
sc_pkcs15_free_certificate(cert_out);
continue;
@ -374,7 +374,7 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, " Failed to add cert obj r=%d",r);
sc_log(card->ctx, " Failed to add cert obj r=%d",r);
sc_pkcs15_free_certificate(cert_out);
continue;
}
@ -411,22 +411,22 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
usage = 0xd9ULL; /* basic default usage */
}
cac_map_usage(usage, cert_out->key->algorithm, &pubkey_info.usage, &prkey_info.usage, 1);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cert %s: cert_usage=0x%x, pub_usage=0x%x priv_usage=0x%x\n",
sc_log(card->ctx, "cert %s: cert_usage=0x%x, pub_usage=0x%x priv_usage=0x%x\n",
sc_dump_hex(cert_info.id.value, cert_info.id.len),
usage, pubkey_info.usage, prkey_info.usage);
if (cert_out->key->algorithm != SC_ALGORITHM_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"unsupported key.algorithm %d", cert_out->key->algorithm);
sc_log(card->ctx, "unsupported key.algorithm %d", cert_out->key->algorithm);
sc_pkcs15_free_certificate(cert_out);
continue;
} else {
pubkey_info.modulus_length = cert_out->key->u.rsa.modulus.len * 8;
prkey_info.modulus_length = cert_out->key->u.rsa.modulus.len * 8;
r = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "adding rsa public key r=%d usage=%x",r, pubkey_info.usage);
sc_log(card->ctx, "adding rsa public key r=%d usage=%x",r, pubkey_info.usage);
if (r < 0)
goto fail;
r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "adding rsa private key r=%d usage=%x",r, prkey_info.usage);
sc_log(card->ctx, "adding rsa private key r=%d usage=%x",r, prkey_info.usage);
}
cert_out->key = NULL;

View File

@ -212,7 +212,7 @@ int sc_pkcs15_cache_file(struct sc_pkcs15_card *p15card,
c = fwrite(buf, 1, bufsize, f);
fclose(f);
if (c != bufsize) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"fwrite() wrote only %"SC_FORMAT_LEN_SIZE_T"u bytes",
c);
unlink(fname);

View File

@ -506,7 +506,7 @@ static int sc_pkcs15emu_coolkey_init(sc_pkcs15_card_t *p15card)
}
/* set pins */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Coolkey adding pins...");
sc_log(card->ctx, "Coolkey adding pins...");
for (i = 0; pins[i].id; i++) {
struct sc_pkcs15_auth_info pin_info;
struct sc_pkcs15_object pin_obj;
@ -528,7 +528,7 @@ static int sc_pkcs15emu_coolkey_init(sc_pkcs15_card_t *p15card)
pin_info.tries_left = -1;
label = pins[i].label? pins[i].label : p15card->tokeninfo->label;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Coolkey Adding pin %d label=%s",i, label);
sc_log(card->ctx, "Coolkey Adding pin %d label=%s",i, label);
strncpy(pin_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
pin_obj.flags = pins[i].obj_flags;

View File

@ -114,7 +114,7 @@ static int my_pin_cmd(sc_card_t * card, struct sc_pin_cmd_data * data,
memcpy(newpin,data->pin1.data, (size_t)data->pin1.len);
newpin[data->pin1.len] = 0x00;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "pin len=%d", data->pin1.len);
sc_log(card->ctx, "pin len=%d", data->pin1.len);
saved_data = data->pin1.data;
saved_len = data->pin1.len;
@ -253,7 +253,7 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
sc_file_free(file);
file = NULL;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GemSafe file found, id=%d",dfpath);
sc_log(card->ctx, "GemSafe file found, id=%d",dfpath);
/* There may be more then one key in the directory. */
/* we need to find them so we can associate them with the */
@ -280,14 +280,14 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
case 0x10: kinfo[num_keyinfo].modulus_len = 768 / 8; break;
case 0x11: kinfo[num_keyinfo].modulus_len = 1024 / 8; break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported modulus length");
sc_log(card->ctx, "Unsupported modulus length");
continue;
}
kinfo[num_keyinfo].fileid = i;
sc_pkcs15_format_id("", &kinfo[num_keyinfo].id);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"reading modulus");
sc_log(card->ctx, "reading modulus");
r = sc_read_record(card, 2, modulus_buf,
kinfo[num_keyinfo].modulus_len+1, SC_RECORD_BY_REC_NR);
if (r < 0)
@ -381,7 +381,7 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
idx2 = idx2 + idxlen;
}
cert_info.value.len = seq_len1 + 4;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Found cert at offset %d", idx1);
sc_log(card->ctx, "Found cert at offset %d", idx1);
cert_info.value.value = (unsigned char *)
malloc(cert_info.value.len);
if (!cert_info.value.value)
@ -416,7 +416,7 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
memcmp(cert_out->key->u.rsa.modulus.data,
&kinfo[j].modulus, cert_out->key->u.rsa.modulus.len) == 0) {
memcpy(&kinfo[j].id, &cert_info.id, sizeof(sc_pkcs15_id_t));
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found match");
sc_log(card->ctx, "found match");
}
}
sc_pkcs15_free_certificate(cert_out);
@ -489,7 +489,7 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
for (j = 0; j < num_keyinfo; j++) {
if (sc_pkcs15_compare_id(&kinfo[j].id, &prkey_info.id)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found key in file %d for id %s",
sc_log(card->ctx, "found key in file %d for id %s",
kinfo[j].fileid, prkeys[i].id);
prkey_info.path.value[0] = kinfo[j].fileid >> 8;
prkey_info.path.value[1] = kinfo[j].fileid & 0xff;
@ -515,7 +515,7 @@ int sc_pkcs15emu_gemsafeGPK_init_ex(sc_pkcs15_card_t *p15card, struct sc_aid *ai
sc_card_t *card = p15card->card;
sc_context_t *ctx = card->ctx;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Entering %s", __FUNCTION__);
sc_log(ctx, "Entering %s", __FUNCTION__);
if (opts && opts->flags & SC_PKCS15EMU_FLAGS_NO_CHECK)
return sc_pkcs15emu_gemsafeGPK_init(p15card);

View File

@ -411,7 +411,7 @@ static int sc_pkcs15emu_gemsafeV1_init( sc_pkcs15_card_t *p15card)
*/
if ( p15card->card->flags & 0x0F) {
key_ref = p15card->card->flags & 0x0F;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Overriding key_ref %d with %d\n",
gemsafe_prkeys[i].ref, key_ref);
} else

View File

@ -50,7 +50,7 @@ static int sc_pkcs15emu_gids_add_prkey(sc_pkcs15_card_t * p15card, sc_cardctl_gi
sc_pkcs15_object_t cert_obj;
int r;
char ch_tmp[10];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Got args: containerIndex=%"SC_FORMAT_LEN_SIZE_T"x\n",
container->containernum);
@ -100,7 +100,7 @@ static int sc_pkcs15emu_gids_add_prkey(sc_pkcs15_card_t * p15card, sc_cardctl_gi
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
LOG_TEST_RET(card->ctx, r, "Could not add certificate");
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No certificate found");
sc_log(card->ctx, "No certificate found");
}
return SC_SUCCESS;

View File

@ -495,7 +495,7 @@ static int loadCertificate(sc_pkcs15_card_t * p15card, int i,
sc_read_binary(card, 4, compCert, compLen, 0);
if ((r = uncompress(cert, &len, compCert, compLen)) != Z_OK) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Zlib error: %d", r);
sc_log(p15card->card->ctx, "Zlib error: %d", r);
return SC_ERROR_INTERNAL;
}
@ -579,7 +579,7 @@ static int infocamere_1400_init(sc_pkcs15_card_t * p15card)
if ((r = loadCertificate(p15card, 0, certPath[0], certLabel[0])) !=
SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "%s", sc_strerror(r));
sc_log(p15card->card->ctx, "%s", sc_strerror(r));
return SC_ERROR_WRONG_CARD;
}

View File

@ -212,7 +212,7 @@ static int itacns_add_cert(sc_pkcs15_card_t *p15card,
SC_FUNC_CALLED(p15card->card->ctx, 1);
if(type != SC_PKCS15_TYPE_CERT_X509) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Cannot add a certificate of a type other than X.509");
return 1;
}
@ -314,7 +314,7 @@ static int itacns_add_prkey(sc_pkcs15_card_t *p15card,
SC_FUNC_CALLED(p15card->card->ctx, 1);
if(type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Cannot add a private key of a type other than RSA");
return 1;
}
@ -527,7 +527,7 @@ static int itacns_add_data_files(sc_pkcs15_card_t *p15card)
rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT,
objs, 32);
if(rv < 0) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Data enumeration failed");
return SC_SUCCESS;
}
@ -539,7 +539,7 @@ static int itacns_add_data_files(sc_pkcs15_card_t *p15card)
}
if(i>=32) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Could not find EF_DatiPersonali: "
"keeping generic card name");
return SC_SUCCESS;
@ -547,7 +547,7 @@ static int itacns_add_data_files(sc_pkcs15_card_t *p15card)
rv = sc_pkcs15_read_data_object(p15card, cinfo, &p15_personaldata);
if (rv) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Could not read EF_DatiPersonali: "
"keeping generic card name");
return SC_SUCCESS;
@ -557,7 +557,7 @@ static int itacns_add_data_files(sc_pkcs15_card_t *p15card)
char fullname[160];
if(get_name_from_EF_DatiPersonali(p15_personaldata->data,
fullname, sizeof(fullname))) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Could not parse EF_DatiPersonali: "
"keeping generic card name");
sc_pkcs15_free_data_object(p15_personaldata);
@ -663,7 +663,7 @@ static int itacns_check_and_add_keyset(sc_pkcs15_card_t *p15card,
/* Certificate */
if (!cert_path) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"We cannot use keys without a matching certificate");
return SC_ERROR_NOT_SUPPORTED;
}
@ -673,7 +673,7 @@ static int itacns_check_and_add_keyset(sc_pkcs15_card_t *p15card,
if (r == SC_ERROR_FILE_NOT_FOUND)
return 0;
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Could not find certificate for %s", label);
return r;
}
@ -725,7 +725,7 @@ static int itacns_check_and_add_keyset(sc_pkcs15_card_t *p15card,
prkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_DECRYPT;
}
#else /* ENABLE_OPENSSL */
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Extended certificate info retrieved without OpenSSL. "
"How is this possible?");
return SC_ERROR_INTERNAL;

View File

@ -211,7 +211,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
if ((r = read_file(card, "006E:0073:00C4", c4data, sizeof(c4data))) < 0)
goto failed;
if (r != 7) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"CHV status bytes have unexpected length (expected 7, got %d)\n", r);
return SC_ERROR_OBJECT_NOT_VALID;
}
@ -259,7 +259,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
if ((r = read_file(card, "006E:0073:00C5", c5data, sizeof(c5data))) < 0)
goto failed;
if (r != 60) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"finger print bytes have unexpected length (expected 60, got %d)\n", r);
return SC_ERROR_OBJECT_NOT_VALID;
}
@ -279,7 +279,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
if ((r = read_file(card, path_template, cxdata, sizeof(cxdata))) < 0)
goto failed;
if (r != 6) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Key info bytes have unexpected length (expected 6, got %d)\n", r);
sc_log(ctx, "Key info bytes have unexpected length (expected 6, got %d)\n", r);
return SC_ERROR_INTERNAL;
}
@ -323,7 +323,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
if ((r = read_file(card, path_template, cxdata, sizeof(cxdata))) < 0)
goto failed;
if (r != 6) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Key info bytes have unexpected length (expected 6, got %d)\n", r);
sc_log(ctx, "Key info bytes have unexpected length (expected 6, got %d)\n", r);
return SC_ERROR_INTERNAL;
}
@ -385,7 +385,7 @@ sc_pkcs15emu_openpgp_init(sc_pkcs15_card_t *p15card)
failed:
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Failed to initialize OpenPGP emulation: %s\n",
sc_strerror(r));
}

View File

@ -634,7 +634,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"sc_card_ctl rc=%d",r);
sc_log(card->ctx, "sc_card_ctl rc=%d",r);
p15card->tokeninfo->serial_number = strdup("00000000");
} else {
sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
@ -645,7 +645,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
follows_nist_fascn = 1;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIV-II adding objects...");
sc_log(card->ctx, "PIV-II adding objects...");
/* set other objects */
for (i = 0; objects[i].label; i++) {
@ -705,7 +705,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
*/
/* set certs */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIV-II adding certs...");
sc_log(card->ctx, "PIV-II adding certs...");
for (i = 0; i < PIV_NUM_CERTS_AND_KEYS; i++) {
struct sc_pkcs15_cert_info cert_info;
struct sc_pkcs15_object cert_obj;
@ -736,14 +736,14 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
/* See if the cert might be present or not. */
r = sc_card_ctl(card, SC_CARDCTL_PIV_OBJECT_PRESENT, &cert_info.path);
if (r == 1) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Cert can not be present,i=%d", i);
sc_log(card->ctx, "Cert can not be present,i=%d", i);
continue;
}
r = sc_pkcs15_read_file(p15card, &cert_info.path, &cert_der.value, &cert_der.len);
if (r) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "No cert found,i=%d", i);
sc_log(card->ctx, "No cert found,i=%d", i);
continue;
}
@ -760,7 +760,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
/* following will find the cached cert in cert_info */
r = sc_pkcs15_read_certificate(p15card, &cert_info, &cert_out);
if (r < 0 || cert_out->key == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Failed to read/parse the certificate r=%d",r);
sc_log(card->ctx, "Failed to read/parse the certificate r=%d",r);
if (cert_out != NULL)
sc_pkcs15_free_certificate(cert_out);
continue;
@ -909,7 +909,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key.algorithm %d", cert_out->key->algorithm);
sc_log(card->ctx, "Unsupported key.algorithm %d", cert_out->key->algorithm);
ckis[i].pubkey_len = 0; /* set some value for now */
}
ckis[i].pubkey_from_cert = cert_out->key;
@ -918,13 +918,13 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, " Failed to add cert obj r=%d",r);
sc_log(card->ctx, " Failed to add cert obj r=%d",r);
continue;
}
}
/* set pins */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIV-II adding pins...");
sc_log(card->ctx, "PIV-II adding pins...");
for (i = 0; pins[i].label; i++) {
struct sc_pkcs15_auth_info pin_info;
struct sc_pkcs15_object pin_obj;
@ -955,7 +955,7 @@ static int sc_pkcs15emu_piv_init(sc_pkcs15_card_t *p15card)
pin_info.attrs.pin.flags &= ~SC_PKCS15_PIN_FLAG_LOCAL;
label = "Global PIN";
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
sc_log(card->ctx, "DEE Adding pin %d label=%s",i, label);
strncpy(pin_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
pin_obj.flags = pins[i].obj_flags;
if (i == 0 && pin_info.attrs.pin.reference == 0x80) {
@ -979,7 +979,7 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
* gets the pubkey, but it can not be read from the card
* at a later time. The piv-tool can stash pubkey in file
*/
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIV-II adding pub keys...");
sc_log(card->ctx, "PIV-II adding pub keys...");
for (i = 0; i < PIV_NUM_CERTS_AND_KEYS; i++) {
struct sc_pkcs15_pubkey_info pubkey_info;
struct sc_pkcs15_object pubkey_obj;
@ -1012,7 +1012,7 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
if (ckis[i].cert_found == 0 ) { /* no cert found */
char * filename = NULL;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"No cert for this pub key i=%d",i);
sc_log(card->ctx, "No cert for this pub key i=%d",i);
/*
* If we used the piv-tool to generate a key,
@ -1023,18 +1023,18 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
*/
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"DEE look for env %s",
sc_log(card->ctx, "DEE look for env %s",
pubkeys[i].getenvname?pubkeys[i].getenvname:"NULL");
if (pubkeys[i].getenvname == NULL)
continue;
filename = getenv(pubkeys[i].getenvname);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"DEE look for file %s", filename?filename:"NULL");
sc_log(card->ctx, "DEE look for file %s", filename?filename:"NULL");
if (filename == NULL)
continue;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Adding pubkey from file %s",filename);
sc_log(card->ctx, "Adding pubkey from file %s",filename);
r = sc_pkcs15_pubkey_from_spki_file(card->ctx, filename, &p15_key);
if (r < 0)
@ -1069,7 +1069,7 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
ckis[i].pubkey_from_file = 1;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Unsupported key_alg %d",p15_key->algorithm);
sc_log(card->ctx, "Unsupported key_alg %d",p15_key->algorithm);
continue;
}
pubkey_obj.emulated = p15_key;
@ -1082,7 +1082,7 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
pubkey_obj.emulated = ckis[i].pubkey_from_cert;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"adding pubkey for %d keyalg=%d",i, ckis[i].key_alg);
sc_log(card->ctx, "adding pubkey for %d keyalg=%d",i, ckis[i].key_alg);
switch (ckis[i].key_alg) {
case SC_ALGORITHM_RSA:
if (ckis[i].cert_keyUsage_present) {
@ -1115,16 +1115,16 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
ckis[i].pubkey_found = 1;
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"key_alg %d not supported", ckis[i].key_alg);
sc_log(card->ctx, "key_alg %d not supported", ckis[i].key_alg);
continue;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"USAGE: cert_keyUsage_present:%d usage:0x%8.8x",
sc_log(card->ctx, "USAGE: cert_keyUsage_present:%d usage:0x%8.8x",
ckis[i].cert_keyUsage_present ,pubkey_info.usage);
}
/* set private keys */
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "PIV-II adding private keys...");
sc_log(card->ctx, "PIV-II adding private keys...");
for (i = 0; i < PIV_NUM_CERTS_AND_KEYS; i++) {
struct sc_pkcs15_prkey_info prkey_info;
struct sc_pkcs15_object prkey_obj;
@ -1158,7 +1158,7 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
if (ckis[i].pubkey_from_file == 1) {
prkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Adding SC_PKCS15_PRKEY_USAGE_SIGN");
sc_log(card->ctx, "Adding SC_PKCS15_PRKEY_USAGE_SIGN");
}
switch (ckis[i].key_alg) {
@ -1186,15 +1186,15 @@ sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE Adding pin %d label=%s",i, label);
prkey_info.usage |= prkeys[i].usage_ec;
}
prkey_info.field_length = ckis[i].pubkey_len;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "DEE added key_alg %2.2x prkey_obj.flags %8.8x",
sc_log(card->ctx, "DEE added key_alg %2.2x prkey_obj.flags %8.8x",
ckis[i].key_alg, prkey_obj.flags);
r = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);
break;
default:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key_alg %d", ckis[i].key_alg);
sc_log(card->ctx, "Unsupported key_alg %d", ckis[i].key_alg);
r = 0; /* we just skip this one */
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"USAGE: cert_keyUsage_present:%d usage:0x%8.8x", ckis[i].cert_keyUsage_present ,prkey_info.usage);
sc_log(card->ctx, "USAGE: cert_keyUsage_present:%d usage:0x%8.8x", ckis[i].cert_keyUsage_present ,prkey_info.usage);
if (r < 0)
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
}

View File

@ -338,7 +338,7 @@ static int sc_pkcs15emu_postecert_init(sc_pkcs15_card_t * p15card)
return 0;
failed:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Failed to initialize Postecert and Cnipa emulation: %s\n",
sc_strerror(r));
return r;

View File

@ -230,7 +230,7 @@ static int parse_EF_CardInfo(sc_pkcs15_card_t *p15card)
| (((unsigned int) info1[info1_len-2]) << 8)
| (((unsigned int) info1[info1_len-3]) << 16)
| (((unsigned int) info1[info1_len-4]) << 24);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"found %d private keys\n", (int)key_num);
/* set p1 to the address of the first key descriptor */
offset = info1_len - 4 - key_num * 2;

View File

@ -63,17 +63,17 @@ static int insert_cert(
cert_obj.flags = writable ? SC_PKCS15_CO_FLAG_MODIFIABLE : 0;
if(sc_select_file(card, &cert_info.path, NULL)!=SC_SUCCESS){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Select(%s) failed\n", path);
return 1;
}
if(sc_read_binary(card, 0, cert, sizeof(cert), 0)<0){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"ReadBinary(%s) failed\n", path);
return 2;
}
if(cert[0]!=0x30 || cert[1]!=0x82){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Invalid Cert: %02X:%02X:...\n", cert[0], cert[1]);
return 3;
}
@ -89,10 +89,10 @@ static int insert_cert(
r=sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
if(r!=SC_SUCCESS){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_pkcs15emu_add_x509_cert(%s) failed\n", path);
sc_log(ctx, "sc_pkcs15emu_add_x509_cert(%s) failed\n", path);
return 4;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "%s: OK, Index=%d, Count=%d\n", path, cert_info.path.index, cert_info.path.count);
sc_log(ctx, "%s: OK, Index=%d, Count=%d\n", path, cert_info.path.index, cert_info.path.count);
return 0;
}
@ -133,12 +133,12 @@ static int insert_key(
if(prkey_info.path.len>=2) prkey_info.path.len-=2;
sc_append_file_id(&prkey_info.path, 0x5349);
if(sc_select_file(card, &prkey_info.path, NULL)!=SC_SUCCESS){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Select(%s) failed\n",
sc_print_path(&prkey_info.path));
return 1;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Searching for Key-Ref %02X\n", key_reference);
while((r=sc_read_record(card, ++rec_no, buf, sizeof(buf), SC_RECORD_BY_REC_NR))>0){
int found=0;
@ -149,7 +149,7 @@ static int insert_key(
if(found) break;
}
if(r<=0){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"No EF_KEYD-Record found\n");
sc_log(ctx, "No EF_KEYD-Record found\n");
return 1;
}
for(i=0;i<r;i+=2+buf[i+1]){
@ -159,7 +159,7 @@ static int insert_key(
} else {
if(sc_select_file(card, &prkey_info.path, &f)!=SC_SUCCESS
|| !f->prop_attr || f->prop_attr_len < 2){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Select(%s) failed\n",
sc_print_path(&prkey_info.path));
return 1;
@ -174,10 +174,10 @@ static int insert_key(
r=sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
if(r!=SC_SUCCESS){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_pkcs15emu_add_rsa_prkey(%s) failed\n", path);
sc_log(ctx, "sc_pkcs15emu_add_rsa_prkey(%s) failed\n", path);
return 4;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "%s: OK%s%s\n", path, can_sign ? ", Sign" : "", can_crypt ? ", Crypt" : "");
sc_log(ctx, "%s: OK%s%s\n", path, can_sign ? ", Sign" : "", can_crypt ? ", Crypt" : "");
return 0;
}
@ -224,12 +224,12 @@ static int insert_pin(
if(pin_info.path.len>=2) pin_info.path.len-=2;
sc_append_file_id(&pin_info.path, 0x5049);
if(sc_select_file(card, &pin_info.path, NULL)!=SC_SUCCESS){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Select(%s) failed\n",
sc_print_path(&pin_info.path));
return 1;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Searching for PIN-Ref %02X\n", pin_reference);
while((r=sc_read_record(card, ++rec_no, buf, sizeof(buf), SC_RECORD_BY_REC_NR))>0){
int found=0, fbz=-1;
@ -242,13 +242,13 @@ static int insert_pin(
if(found) break;
}
if(r<=0){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"No EF_PWDD-Record found\n");
sc_log(ctx, "No EF_PWDD-Record found\n");
return 1;
}
} else {
if(sc_select_file(card, &pin_info.path, &f)!=SC_SUCCESS
|| !f->prop_attr || f->prop_attr_len < 4){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"Select(%s) failed\n", path);
sc_log(ctx, "Select(%s) failed\n", path);
return 1;
}
pin_info.tries_left=f->prop_attr[3];
@ -257,10 +257,10 @@ static int insert_pin(
r=sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
if(r!=SC_SUCCESS){
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_pkcs15emu_add_pin_obj(%s) failed\n", path);
sc_log(ctx, "sc_pkcs15emu_add_pin_obj(%s) failed\n", path);
return 4;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "%s: OK, FBZ=%d\n", path, pin_info.tries_left);
sc_log(ctx, "%s: OK, FBZ=%d\n", path, pin_info.tries_left);
return 0;
}
@ -508,7 +508,7 @@ int sc_pkcs15emu_tcos_init_ex(
/* get the card serial number */
r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serialnr);
if (r < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to get ICCSN\n");
sc_log(ctx, "unable to get ICCSN\n");
return SC_ERROR_WRONG_CARD;
}
sc_bin_to_hex(serialnr.value, serialnr.len , serial, sizeof(serial), 0);

View File

@ -237,7 +237,7 @@ static int westcos_detect_card(sc_pkcs15_card_t * p15card)
sc_card_t *card = p15card->card;
sc_context_t *ctx = card->ctx;
const char *name = "WESTCOS";
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"westcos_detect_card (%s)", card->name);
if (strncmp(card->name, name, strlen(name)))
return SC_ERROR_WRONG_CARD;
@ -251,7 +251,7 @@ int sc_pkcs15emu_westcos_init_ex(sc_pkcs15_card_t * p15card,
int r;
sc_card_t *card = p15card->card;
sc_context_t *ctx = card->ctx;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"sc_pkcs15_init_func_ex westcos\n");
if (opts && opts->flags & SC_PKCS15EMU_FLAGS_NO_CHECK)
return sc_pkcs15emu_westcos_init(p15card);

View File

@ -229,21 +229,21 @@ openct_reader_connect(sc_reader_t *reader)
ct_reader_disconnect(data->h);
if (!(data->h = ct_reader_connect(data->num))) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "ct_reader_connect socket failed\n");
sc_log(reader->ctx, "ct_reader_connect socket failed\n");
return SC_ERROR_CARD_NOT_PRESENT;
}
rc = ct_card_request(data->h, data->slot, 0, NULL,
reader->atr.value, sizeof(reader->atr.value));
if (rc < 0) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"openct_reader_connect read failed: %s\n",
ct_strerror(rc));
return SC_ERROR_CARD_NOT_PRESENT;
}
if (rc == 0) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "openct_reader_connect received no data\n");
sc_log(reader->ctx, "openct_reader_connect received no data\n");
return SC_ERROR_READER;
}
@ -328,7 +328,7 @@ static int openct_reader_transmit(sc_reader_t *reader, sc_apdu_t *apdu)
rbuf, &rsize, apdu->control);
if (r < 0) {
/* unable to transmit ... most likely a reader problem */
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "unable to transmit");
sc_log(reader->ctx, "unable to transmit");
goto out;
}
sc_apdu_log(reader->ctx, SC_LOG_DEBUG_NORMAL, rbuf, rsize, 0);

View File

@ -528,7 +528,7 @@ static void initialize_uid(sc_reader_t *reader)
sc_debug_hex(reader->ctx, SC_LOG_DEBUG_NORMAL, "UID",
reader->uid.value, reader->uid.len);
} else {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL, "unable to get UID");
sc_log(reader->ctx, "unable to get UID");
}
}
}

View File

@ -664,7 +664,7 @@ static int escape_perform_verify(struct sc_reader *reader,
r = escape_pin_cmd_to_buf(reader->ctx, data,
(unsigned char **) &apdu.data, &apdu.datalen);
if (r < 0) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Error encoding PC_to_RDR_Secure");
goto err;
}
@ -672,13 +672,13 @@ static int escape_perform_verify(struct sc_reader *reader,
r = reader->ops->transmit(reader, &apdu);
if (r < 0) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Error performing PC_to_RDR_Secure");
goto err;
}
if (apdu.sw1 != 0x90 && apdu.sw2 != 0x00) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Error decoding PC_to_RDR_Secure");
r = SC_ERROR_NOT_SUPPORTED;
goto err;
@ -723,7 +723,7 @@ static int escape_perform_pace(struct sc_reader *reader,
r = escape_pace_input_to_buf(reader->ctx, input,
(unsigned char **) &apdu.data, &apdu.datalen);
if (r < 0) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Error encoding EstablishPACEChannel");
goto err;
}
@ -731,13 +731,13 @@ static int escape_perform_pace(struct sc_reader *reader,
r = reader->ops->transmit(reader, &apdu);
if (r < 0) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Error performing EstablishPACEChannel");
goto err;
}
if (apdu.sw1 != 0x90 && apdu.sw2 != 0x00) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Error decoding EstablishPACEChannel");
r = SC_ERROR_NOT_SUPPORTED;
goto err;
@ -945,7 +945,7 @@ void sc_detect_escape_cmds(sc_reader_t *reader)
&& !(reader->capabilities & SC_READER_CAP_PIN_PAD)) {
((struct sc_reader_operations *) reader->ops)->perform_verify =
escape_perform_verify;
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Added escape command wrappers for PIN verification/modification to '%s'", reader->name);
}
@ -953,14 +953,14 @@ void sc_detect_escape_cmds(sc_reader_t *reader)
&& !(reader->capabilities & SC_READER_CAP_PACE_GENERIC)) {
((struct sc_reader_operations *) reader->ops)->perform_pace =
escape_perform_pace;
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"Added escape command wrappers for PACE to '%s'", reader->name);
}
reader->capabilities |= capabilities;
} else {
error++;
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"%s does not support escape commands", reader->name);
}
@ -997,7 +997,7 @@ void sc_detect_escape_cmds(sc_reader_t *reader)
}
if (error && reader) {
sc_debug(reader->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(reader->ctx,
"%d escape command%s failed, need to reset the card",
error, error == 1 ? "" : "s");
if (reader->ops && reader->ops->transmit) {

View File

@ -238,10 +238,10 @@ int sc_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data,
break;
}
if (r == SC_ERROR_NOT_SUPPORTED)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unsupported PIN operation (%d)",
sc_log(card->ctx, "unsupported PIN operation (%d)",
data->cmd);
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Use of pin pad not supported by card driver");
sc_log(card->ctx, "Use of pin pad not supported by card driver");
r = SC_ERROR_NOT_SUPPORTED;
}
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);

View File

@ -206,7 +206,7 @@ static int asepcos_pinid_to_akn(sc_card_t *card, int fileid, int *akn)
if (r != SC_SUCCESS)
return r;
if (nfile->prop_attr == NULL || nfile->prop_attr_len != 11) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to determine AKN");
sc_log(card->ctx, "unable to determine AKN");
sc_file_free(nfile);
return SC_ERROR_INTERNAL;
}
@ -234,7 +234,7 @@ static int asepcos_do_store_pin(sc_profile_t *profile, sc_card_t *card,
*p++ = pinid & 0xff;
/* pin length */
if (pinlen < 4 || pinlen > 16) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid PIN length");
sc_log(card->ctx, "invalid PIN length");
return SC_ERROR_INVALID_ARGUMENTS;
}
*p++ = 0x00;
@ -296,7 +296,7 @@ static int asepcos_do_store_pin(sc_profile_t *profile, sc_card_t *card,
r = sc_create_file(card, nfile);
sc_file_free(nfile);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to create PIN file");
sc_log(card->ctx, "unable to create PIN file");
return r;
}
/* get AKN of the newly created PIN */
@ -367,7 +367,7 @@ static int asepcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = sc_pkcs15init_authenticate(profile, p15card, tfile, SC_AC_OP_CREATE);
sc_file_free(tfile);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to create PIN file, insufficient rights");
sc_log(card->ctx, "unable to create PIN file, insufficient rights");
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
}
@ -384,7 +384,7 @@ static int asepcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
if (r == SC_SUCCESS)
pid += 2;
else if (r != SC_ERROR_FILE_NOT_FOUND) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error selecting PIN file");
sc_log(card->ctx, "error selecting PIN file");
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
}
} while (r != SC_ERROR_FILE_NOT_FOUND);
@ -422,7 +422,7 @@ static int asepcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
* first USER PIN has been set we can tighten the ACLs of
* the application DF.
*/
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "finalizing application DF");
sc_log(card->ctx, "finalizing application DF");
r = sc_select_file(card, &df->path, NULL);
if (r != SC_SUCCESS)
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
@ -432,7 +432,7 @@ static int asepcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
r = sc_card_ctl(card, SC_CARDCTL_ASEPCOS_SET_SATTR, df);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to change the security attributes");
sc_log(card->ctx, "unable to change the security attributes");
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
}
/* finally activate the application DF (fix ACLs) */
@ -445,7 +445,7 @@ static int asepcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
st.is_ef = 0;
r = sc_card_ctl(card, SC_CARDCTL_ASEPCOS_ACTIVATE_FILE, &st);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to activate DF");
sc_log(card->ctx, "unable to activate DF");
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
}
}
@ -477,14 +477,14 @@ static int asepcos_do_authenticate(sc_profile_t *profile, sc_pkcs15_card_t *p15c
sc_file_t *prkey = NULL;
r = sc_profile_get_file_by_path(profile, path, &prkey);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to find file in profile");
sc_log(p15card->card->ctx, "unable to find file in profile");
return r;
}
r = sc_pkcs15init_authenticate(profile, p15card, prkey, op);
sc_file_free(prkey);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to authenticate");
sc_log(p15card->card->ctx, "unable to authenticate");
return r;
}
return SC_SUCCESS;
@ -545,7 +545,7 @@ static int asepcos_do_create_key(sc_card_t *card, size_t ksize, int fileid,
nfile->id = fileid & 0xffff;
r = sc_file_set_prop_attr(nfile, buf, p - buf);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to set key prop. attributes");
sc_log(card->ctx, "unable to set key prop. attributes");
sc_file_free(nfile);
return r;
}
@ -553,7 +553,7 @@ static int asepcos_do_create_key(sc_card_t *card, size_t ksize, int fileid,
r = sc_create_file(card, nfile);
sc_file_free(nfile);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to create key file");
sc_log(card->ctx, "unable to create key file");
return r;
}
return r;
@ -580,7 +580,7 @@ static int asepcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = sc_pkcs15_find_pin_by_auth_id(p15card, &obj->auth_id, &pin);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to determine reference for the PIN");
sc_log(p15card->card->ctx, "unable to determine reference for the PIN");
return r;
}
@ -589,7 +589,7 @@ static int asepcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
st.akn = auth_info->attrs.pin.reference;
r = sc_card_ctl(p15card->card, SC_CARDCTL_ASEPCOS_AKN2FILEID, &st);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to determine file id of the PIN");
sc_log(p15card->card->ctx, "unable to determine file id of the PIN");
return r;
}
afileid = st.fileid;
@ -640,7 +640,7 @@ static int asepcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = asepcos_do_create_key(p15card->card, kinfo->modulus_length, fileid, buf, p - buf);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to create private key file");
sc_log(p15card->card->ctx, "unable to create private key file");
return r;
}
@ -674,7 +674,7 @@ static int asepcos_do_store_rsa_key(sc_pkcs15_card_t *p15card, sc_profile_t *pro
tpath.value[1] = kinfo->path.value[kinfo->path.len-1];
r = sc_select_file(p15card->card, &tpath, NULL);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to select rsa key file");
sc_log(p15card->card->ctx, "unable to select rsa key file");
return r;
}
@ -705,7 +705,7 @@ static int asepcos_do_store_rsa_key(sc_pkcs15_card_t *p15card, sc_profile_t *pro
r = sc_card_ctl(p15card->card, SC_CARDCTL_ASEPCOS_CHANGE_KEY, &ckdata);
if (r != SC_SUCCESS) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "unable to change key data");
sc_log(p15card->card->ctx, "unable to change key data");
return r;
}
@ -725,7 +725,7 @@ static int asepcos_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *) obj->data;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "only RSA is currently supported");
sc_log(p15card->card->ctx, "only RSA is currently supported");
return SC_ERROR_NOT_SUPPORTED;
}
@ -763,7 +763,7 @@ static int asepcos_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card
tpath.value[1] = kinfo->path.value[kinfo->path.len-1];
r = sc_select_file(card, &tpath, NULL);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "unable to select rsa key file");
sc_log(card->ctx, "unable to select rsa key file");
return r;
}
@ -782,7 +782,7 @@ static int asepcos_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card
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) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "error creating key");
sc_log(card->ctx, "error creating key");
return SC_ERROR_INTERNAL;
}

View File

@ -263,26 +263,26 @@ cardos_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int algorithm = 0, r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "CardOS supports RSA keys only.");
sc_log(ctx, "CardOS supports RSA keys only.");
return SC_ERROR_NOT_SUPPORTED;
}
if (cardos_key_algorithm(key_info->usage, key_info->modulus_length, &algorithm) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "CardOS does not support keys "
sc_log(ctx, "CardOS does not support keys "
"that can both sign _and_ decrypt.");
return SC_ERROR_NOT_SUPPORTED;
}
r = sc_select_file(p15card->card, &key_info->path, &file);
if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to store key: cannot select parent DF");
sc_log(ctx, "Failed to store key: cannot select parent DF");
return r;
}
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
sc_file_free(file);
if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to store key: 'UPDATE' authentication failed");
sc_log(ctx, "Failed to store key: 'UPDATE' authentication failed");
return r;
}
@ -337,7 +337,7 @@ cardos_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
rsa_max_size = (sc_card_find_rsa_alg(p15card->card, 2048) != NULL) ? 2048 : 1024;
keybits = key_info->modulus_length & ~7UL;
if (keybits > rsa_max_size) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to generate key, max size is %lu",
sc_log(ctx, "Unable to generate key, max size is %lu",
(unsigned long) rsa_max_size);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -346,13 +346,13 @@ cardos_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
use_ext_rsa = 1;
if (cardos_key_algorithm(key_info->usage, keybits, &algorithm) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "CardOS does not support keys "
sc_log(ctx, "CardOS does not support keys "
"that can both sign _and_ decrypt.");
return SC_ERROR_NOT_SUPPORTED;
}
if (sc_profile_get_file(profile, "tempfile", &temp) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define temporary file "
sc_log(ctx, "Profile doesn't define temporary file "
"for key generation.");
return SC_ERROR_NOT_SUPPORTED;
}
@ -481,7 +481,7 @@ cardos_store_pin(sc_profile_t *profile, sc_card_t *card,
* "no padding required". */
maxlen = MIN(profile->pin_maxlen, sizeof(pinpadded));
if (pin_len > maxlen) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"invalid pin length: %"SC_FORMAT_LEN_SIZE_T"u (max %u)\n",
pin_len, maxlen);
return SC_ERROR_INVALID_ARGUMENTS;
@ -761,13 +761,13 @@ static int parse_ext_pubkey_file(sc_card_t *card, const u8 *data, size_t len,
return SC_ERROR_INVALID_ARGUMENTS;
data = sc_asn1_find_tag(card->ctx, data, len, 0x7f49, &ilen);
if (data == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid public key data: missing tag");
sc_log(card->ctx, "invalid public key data: missing tag");
return SC_ERROR_INTERNAL;
}
p = sc_asn1_find_tag(card->ctx, data, ilen, 0x81, &tlen);
if (p == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid public key data: missing modulus");
sc_log(card->ctx, "invalid public key data: missing modulus");
return SC_ERROR_INTERNAL;
}
pubkey->u.rsa.modulus.len = tlen;
@ -778,7 +778,7 @@ static int parse_ext_pubkey_file(sc_card_t *card, const u8 *data, size_t len,
p = sc_asn1_find_tag(card->ctx, data, ilen, 0x82, &tlen);
if (p == NULL) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid public key data: missing exponent");
sc_log(card->ctx, "invalid public key data: missing exponent");
return SC_ERROR_INTERNAL;
}
pubkey->u.rsa.exponent.len = tlen;

View File

@ -273,7 +273,7 @@ cflex_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_pkcs15_obj
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Cryptoflex supports only RSA keys.");
sc_log(p15card->card->ctx, "Cryptoflex supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
@ -289,7 +289,7 @@ cflex_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_pkcs15_obj
case 1024: size = 326; break;
case 2048: size = 646; break;
default:
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
key_info->modulus_length);
r = SC_ERROR_INVALID_ARGUMENTS;
@ -331,7 +331,7 @@ cflex_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Cryptoflex supports only RSA keys.");
sc_log(card->ctx, "Cryptoflex supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
/* Get the public and private key file */
@ -391,7 +391,7 @@ cflex_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Cryptoflex supports only RSA keys.");
sc_log(card->ctx, "Cryptoflex supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
/* Get the public and private key file */
@ -654,7 +654,7 @@ static int cflex_get_keyfiles(sc_profile_t *profile, sc_card_t *card,
if (r != SC_SUCCESS)
pbuf[0] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Cannot find private key file info "
sc_log(card->ctx, "Cannot find private key file info "
"in profile (path=%s).", pbuf);
return r;
}
@ -664,7 +664,7 @@ static int cflex_get_keyfiles(sc_profile_t *profile, sc_card_t *card,
sc_append_file_id(&path, 0x1012);
r = sc_profile_get_file_by_path(profile, &path, pukf);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Cannot find public key file info in profile.");
sc_log(card->ctx, "Cannot find public key file info in profile.");
sc_file_free(*prkf);
return r;
}

View File

@ -214,7 +214,7 @@ static int entersafe_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card
for(i = 0; create_efs[i]; ++i) {
if (sc_profile_get_file(profile, create_efs[i], &file)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Inconsistent profile: cannot find %s", create_efs[i]);
sc_log(card->ctx, "Inconsistent profile: cannot find %s", create_efs[i]);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_INCONSISTENT_PROFILE);
}
@ -476,7 +476,7 @@ static int entersafe_sanity_check(sc_profile_t *profile, sc_pkcs15_card_t *p15ca
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Check and if needed update PinFlags");
sc_log(ctx, "Check and if needed update PinFlags");
rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to get PINs");
nn = rv;
@ -493,7 +493,7 @@ static int entersafe_sanity_check(sc_profile_t *profile, sc_pkcs15_card_t *p15ca
if (pin_attrs->reference == profile_auth.attrs.pin.reference
&& pin_attrs->flags != profile_auth.attrs.pin.flags) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Set flags of '%s'(flags:%X,ref:%i,id:%s) to %X", objs[ii]->label,
sc_log(ctx, "Set flags of '%s'(flags:%X,ref:%i,id:%s) to %X", objs[ii]->label,
pin_attrs->flags, pin_attrs->reference, sc_pkcs15_print_id(&ainfo->auth_id),
profile_auth.attrs.pin.flags);
pin_attrs->flags = profile_auth.attrs.pin.flags;

View File

@ -172,7 +172,7 @@ static int epass2003_pkcs15_create_dir(struct sc_profile *profile,
for (i = 0; create_efs[i]; ++i) {
if (sc_profile_get_file(profile, create_efs[i], &file)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Inconsistent profile: cannot find %s",
create_efs[i]);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,
@ -312,7 +312,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
unsigned int structure = 0xFFFFFFFF;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "type %X; num %i\n", type,
sc_log(card->ctx, "type %X; num %i\n", type,
num);
while (1) {
switch (type) {
@ -360,7 +360,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
* the generic class (SC_PKCS15_TYPE_CERT)
*/
if (!(type & ~SC_PKCS15_TYPE_CLASS_MASK)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"File type %X not supported by card driver",
type);
return SC_ERROR_INVALID_ARGUMENTS;
@ -368,10 +368,10 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
type &= SC_PKCS15_TYPE_CLASS_MASK;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "template %s; num %i\n",
sc_log(card->ctx, "template %s; num %i\n",
_template, num);
if (sc_profile_get_file(profile, _template, &file) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Profile doesn't define %s template '%s'\n", desc,
_template);
return SC_ERROR_NOT_SUPPORTED;
@ -384,11 +384,11 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
file->type = SC_FILE_TYPE_INTERNAL_EF;
file->ef_structure = structure;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"file size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X, path_len %"SC_FORMAT_LEN_SIZE_T"u\n",
file->size, file->type, file->ef_structure, file->id,
file->path.len);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "file path: %s",
sc_log(card->ctx, "file path: %s",
sc_print_path(&(file->path)));
*out = file;
@ -424,7 +424,7 @@ static int epass2003_pkcs15_store_key(struct sc_profile *profile,
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"index %"SC_FORMAT_LEN_SIZE_T"u; id %s\n", idx,
sc_pkcs15_print_id(&key_info->id));
if (key->algorithm != SC_ALGORITHM_RSA
@ -433,7 +433,7 @@ static int epass2003_pkcs15_store_key(struct sc_profile *profile,
SC_ERROR_NOT_SUPPORTED,
"store key: only support RSA");
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"store key: with ID:%s and path:%s",
sc_pkcs15_print_id(&key_info->id),
sc_print_path(&key_info->path));
@ -444,9 +444,9 @@ static int epass2003_pkcs15_store_key(struct sc_profile *profile,
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r,
"create key: failed to allocate new key object");
file->size = keybits;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "private key path: %s",
sc_log(card->ctx, "private key path: %s",
sc_print_path(&(file->path)));
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "private key_info path: %s",
sc_log(card->ctx, "private key_info path: %s",
sc_print_path(&(key_info->path)));
sc_delete_file(p15card->card, &file->path);
/* create */
@ -454,7 +454,7 @@ static int epass2003_pkcs15_store_key(struct sc_profile *profile,
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r,
"create key: failed to create key file");
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"index %"SC_FORMAT_LEN_SIZE_T"u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n",
idx, keybits);
if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
@ -522,9 +522,9 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
"create key: failed to allocate new key object");
file->size = keybits;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "private key path: %s",
sc_log(card->ctx, "private key path: %s",
sc_print_path(&file->path));
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "private key_info path: %s",
sc_log(card->ctx, "private key_info path: %s",
sc_print_path(&(key_info->path)));
r = sc_pkcs15init_authenticate(profile, p15card, file,
@ -538,7 +538,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
"create key: failed to create key file");
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"index %"SC_FORMAT_LEN_SIZE_T"u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n",
idx, keybits);
if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
@ -585,7 +585,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
}
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"generate key: create temporary pukf failed\n");
goto err;
}
@ -594,7 +594,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
pukf->id = pukf->path.value[pukf->path.len - 2] * 0x100
+ pukf->path.value[pukf->path.len - 1];
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"public key size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X; path: %s",
pukf->size, pukf->type, pukf->ef_structure, pukf->id,
sc_print_path(&pukf->path));
@ -609,7 +609,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
r = sc_pkcs15init_delete_by_path(profile, p15card, &pukf->path);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"generate key: failed to delete existing key file\n");
goto err;
}
@ -617,7 +617,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
/* create */
r = sc_pkcs15init_create_file(profile, p15card, pukf);
if (r != SC_SUCCESS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"generate key: pukf create file failed\n");
goto err;
}
@ -690,7 +690,7 @@ static int epass2003_pkcs15_sanity_check(sc_profile_t * profile,
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Check and if needed update PinFlags");
rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to get PINs");
@ -709,7 +709,7 @@ static int epass2003_pkcs15_sanity_check(sc_profile_t * profile,
if (pin_attrs->reference == profile_auth.attrs.pin.reference
&& pin_attrs->flags != profile_auth.attrs.pin.flags) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Set flags of '%s'(flags:%X,ref:%i,id:%s) to %X",
objs[ii]->label, pin_attrs->flags,
pin_attrs->reference,

View File

@ -103,7 +103,7 @@ gpk_erase_card(struct sc_profile *pro, sc_pkcs15_card_t *p15card)
if (sc_card_ctl(p15card->card, SC_CARDCTL_GPK_IS_LOCKED, &locked) == 0
&& locked) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"This card is already personalized, unable to "
"create PKCS#15 structure.");
return SC_ERROR_NOT_SUPPORTED;
@ -124,7 +124,7 @@ gpk_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df)
SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
if (sc_card_ctl(p15card->card, SC_CARDCTL_GPK_IS_LOCKED, &locked) == 0
&& locked) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"This card is already personalized, unable to "
"create PKCS#15 structure.");
return SC_ERROR_NOT_SUPPORTED;
@ -240,7 +240,7 @@ gpk_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df,
}
r = sc_select_file(p15card->card, &df->path, NULL);
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "select df path: %i", r);
sc_log(p15card->card->ctx, "select df path: %i", r);
if (r < 0)
return r;
@ -250,7 +250,7 @@ gpk_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df,
pin_attrs->reference,
nulpin, sizeof(nulpin),
pin, pin_len, NULL);
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "change CHV %i", r);
sc_log(p15card->card->ctx, "change CHV %i", r);
if (r < 0)
return r;
@ -259,7 +259,7 @@ gpk_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df,
pin_attrs->reference + 1,
nulpin, sizeof(nulpin),
puk, puk_len, NULL);
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "change CHV+1 %i", r);
sc_log(p15card->card->ctx, "change CHV+1 %i", r);
if (r < 0)
return r;
@ -338,7 +338,7 @@ gpk_init_pinfile(struct sc_profile *profile, sc_pkcs15_card_t *p15card,
/* Create the PIN file. */
acl = sc_file_get_acl_entry(pinfile, SC_AC_OP_WRITE);
if (acl->method != SC_AC_NEVER) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"PIN file most be protected by WRITE=NEVER");
sc_file_free(pinfile);
return SC_ERROR_INVALID_ARGUMENTS;
@ -348,7 +348,7 @@ gpk_init_pinfile(struct sc_profile *profile, sc_pkcs15_card_t *p15card,
if (pinfile->size == 0)
pinfile->size = GPK_MAX_PINS * 8;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Now create file");
sc_log(p15card->card->ctx, "Now create file");
/* Now create the file */
if ((r = sc_pkcs15init_create_file(profile, p15card, pinfile)) < 0
|| (r = sc_select_file(p15card->card, &pinfile->path, NULL)) < 0) {
@ -436,7 +436,7 @@ gpk_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_pkcs15_objec
case SC_PKCS15_TYPE_PRKEY_DSA:
algo = SC_ALGORITHM_DSA; break;
default:
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported public key algorithm");
sc_log(p15card->card->ctx, "Unsupported public key algorithm");
return SC_ERROR_NOT_SUPPORTED;
}
@ -518,13 +518,13 @@ gpk_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
sc_file_t *keyfile;
int r, n;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(p15card->card->ctx,
"path=%s, %"SC_FORMAT_LEN_SIZE_T"u bits\n",
sc_print_path(&key_info->path),
key_info->modulus_length);
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "GPK supports generating only RSA keys.");
sc_log(p15card->card->ctx, "GPK supports generating only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
@ -660,7 +660,7 @@ gpk_pkfile_init_public(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file
if (usage & (SC_PKCS15_PRKEY_USAGE_SIGN|SC_PKCS15_PRKEY_USAGE_NONREPUDIATION))
sysrec[2] &= ~0x20;
if (sysrec[2] == 0x30) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Key usage should specify at least one of sign or decipher");
sc_log(ctx, "Key usage should specify at least one of sign or decipher");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -685,13 +685,13 @@ gpk_pkfile_init_public(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file
|| acl->method == SC_AC_NEVER)
continue;
if (acl->method != SC_AC_CHV) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Authentication method not "
sc_log(ctx, "Authentication method not "
"supported for private key files.\n");
r = SC_ERROR_NOT_SUPPORTED;
goto out;
}
if (++npins >= 2) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Too many pins for PrKEY file!\n");
sc_log(ctx, "Too many pins for PrKEY file!\n");
r = SC_ERROR_NOT_SUPPORTED;
goto out;
}
@ -716,7 +716,7 @@ gpk_pkfile_init_public(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file
SC_RECORD_BY_REC_NR);
if (r >= 0) {
if (r != 7 || buffer[0] != 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "first record of public key file is not Lsys0");
sc_log(ctx, "first record of public key file is not Lsys0");
r = SC_ERROR_OBJECT_NOT_VALID;
goto out;
}
@ -741,7 +741,7 @@ gpk_pkfile_update_public(struct sc_profile *profile,
unsigned int m, n, tag;
int r = 0, found;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Updating public key elements\n");
sc_log(ctx, "Updating public key elements\n");
/* If we've been given a key with public parts, write them now */
for (n = 2; n < 256; n++) {
@ -754,7 +754,7 @@ gpk_pkfile_update_public(struct sc_profile *profile,
/* Check for bad record */
if (r < 2) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key file format error: "
sc_log(ctx, "key file format error: "
"record %u too small (%u bytes)\n",
n, r);
return SC_ERROR_OBJECT_NOT_VALID;
@ -777,7 +777,7 @@ gpk_pkfile_update_public(struct sc_profile *profile,
}
if (!found)
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "GPK unknown PK tag %u\n", tag);
sc_log(ctx, "GPK unknown PK tag %u\n", tag);
}
/* Write all remaining elements */
@ -824,7 +824,7 @@ gpk_pkfile_update_private(struct sc_profile *profile,
u8 data[256];
int r = 0;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Updating private key elements\n");
sc_log(p15card->card->ctx, "Updating private key elements\n");
for (m = 0; m < part->count; m++) {
pe = part->components + m;
@ -934,7 +934,7 @@ static int gpk_encode_rsa_key(sc_profile_t *profile, sc_card_t *card,
sc_pkcs15_prkey_info_t *info)
{
if (!rsa->modulus.len || !rsa->exponent.len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"incomplete RSA public key");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -943,7 +943,7 @@ static int gpk_encode_rsa_key(sc_profile_t *profile, sc_card_t *card,
* the only exponent supported by GPK4000 and GPK8000 */
if (rsa->exponent.len != 3
|| memcmp(rsa->exponent.data, "\001\000\001", 3)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"unsupported RSA exponent");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -962,7 +962,7 @@ static int gpk_encode_rsa_key(sc_profile_t *profile, sc_card_t *card,
if (!rsa->p.len || !rsa->q.len || !rsa->dmp1.len || !rsa->dmq1.len || !rsa->iqmp.len) {
/* No or incomplete CRT information */
if (!rsa->d.len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"incomplete RSA private key");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -1012,7 +1012,7 @@ static int gpk_encode_dsa_key(sc_profile_t *profile, sc_card_t *card,
{
if (!dsa->p.len || !dsa->q.len || !dsa->g.len
|| !dsa->pub.len || !dsa->priv.len) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"incomplete DSA public key");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -1031,7 +1031,7 @@ static int gpk_encode_dsa_key(sc_profile_t *profile, sc_card_t *card,
p->bits = 1024;
p->bytes = 128;
} else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"incompatible DSA key size (%u bits)", p->bits);
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -1060,7 +1060,7 @@ gpk_store_pk(struct sc_profile *profile, sc_pkcs15_card_t *p15card,
gpk_compute_publen(&p->_public);
gpk_compute_privlen(&p->_private);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Storing pk: %u bits, pub %u bytes, priv %u bytes\n",
sc_log(ctx, "Storing pk: %u bits, pub %u bytes, priv %u bytes\n",
p->bits, p->_public.size, p->_private.size);
fsize = p->_public.size + p->_private.size;

View File

@ -281,12 +281,12 @@ incrypto34_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int algorithm, r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Incrypto34 supports RSA keys only.");
sc_log(card->ctx, "Incrypto34 supports RSA keys only.");
return SC_ERROR_NOT_SUPPORTED;
}
if (incrypto34_key_algorithm(key_info->usage, &algorithm) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Incrypto34 does not support keys "
sc_log(card->ctx, "Incrypto34 does not support keys "
"that can both sign _and_ decrypt.");
return SC_ERROR_NOT_SUPPORTED;
}
@ -314,25 +314,25 @@ incrypto34_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int algorithm, r, delete_it = 0;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Incrypto34 supports only RSA keys.");
sc_log(card->ctx, "Incrypto34 supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
if (incrypto34_key_algorithm(key_info->usage, &algorithm) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Incrypto34 does not support keys "
sc_log(card->ctx, "Incrypto34 does not support keys "
"that can both sign _and_ decrypt.");
return SC_ERROR_NOT_SUPPORTED;
}
keybits = key_info->modulus_length & ~7UL;
if (keybits > RSAKEY_MAX_BITS) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to generate key, max size is %d",
sc_log(card->ctx, "Unable to generate key, max size is %d",
RSAKEY_MAX_BITS);
return SC_ERROR_INVALID_ARGUMENTS;
}
if (sc_profile_get_file(profile, "tempfile", &temp) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define temporary file "
sc_log(card->ctx, "Profile doesn't define temporary file "
"for key generation.");
return SC_ERROR_NOT_SUPPORTED;
}

View File

@ -141,7 +141,7 @@ jcop_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_pkcs15_obje
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "JCOP supports only RSA keys.");
sc_log(p15card->card->ctx, "JCOP supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
/* The caller is supposed to have chosen a key file path for us */
@ -215,7 +215,7 @@ jcop_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "JCOP supports only RSA keys.");
sc_log(p15card->card->ctx, "JCOP supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}
r = sc_profile_get_file_by_path(profile, &key_info->path, &keyfile);
@ -252,7 +252,7 @@ jcop_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int r,delete_ok=0;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "JCOP supports only RSA keys.");
sc_log(p15card->card->ctx, "JCOP supports only RSA keys.");
return SC_ERROR_NOT_SUPPORTED;
}

View File

@ -75,7 +75,7 @@ miocos_new_file(struct sc_profile *profile, sc_card_t *card,
* the generic class (SC_PKCS15_TYPE_CERT)
*/
if (!(type & ~SC_PKCS15_TYPE_CLASS_MASK)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"File type not supported by card driver");
return SC_ERROR_INVALID_ARGUMENTS;
}
@ -84,7 +84,7 @@ miocos_new_file(struct sc_profile *profile, sc_card_t *card,
snprintf(name, sizeof(name), "template-%s", tag);
if (sc_profile_get_file(profile, name, &file) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define %s template (%s)",
sc_log(card->ctx, "Profile doesn't define %s template (%s)",
desc, name);
return SC_ERROR_NOT_SUPPORTED;
}
@ -210,7 +210,7 @@ miocos_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (key_info->modulus_length != 1024)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "MioCOS supports only 1024-bit RSA keys.");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create private key ID:%s\n", sc_pkcs15_print_id(&key_info->id));
sc_log(ctx, "create private key ID:%s\n", sc_pkcs15_print_id(&key_info->id));
r = miocos_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Cannot create key: failed to allocate new key object");
@ -218,7 +218,7 @@ miocos_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
file->id = file->path.value[file->path.len - 2] * 0x100
+ file->path.value[file->path.len - 1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Path of private key file to create %s\n", sc_print_path(&file->path));
sc_log(ctx, "Path of private key file to create %s\n", sc_print_path(&file->path));
r = sc_pkcs15init_create_file(profile, p15card, file);
sc_file_free(file);
@ -250,7 +250,7 @@ miocos_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (rsa->modulus.len != 128)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "MioCOS supports only 1024-bit RSA keys.");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "store key with ID:%s and path:%s\n", sc_pkcs15_print_id(&key_info->id),
sc_log(ctx, "store key with ID:%s and path:%s\n", sc_pkcs15_print_id(&key_info->id),
sc_print_path(&key_info->path));
r = sc_select_file(p15card->card, &key_info->path, &file);

View File

@ -171,7 +171,7 @@ muscle_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Muscle supports RSA keys only.");
sc_log(ctx, "Muscle supports RSA keys only.");
return SC_ERROR_NOT_SUPPORTED;
}
/* Verification stuff */
@ -210,7 +210,7 @@ muscle_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = sc_card_ctl(p15card->card, SC_CARDCTL_MUSCLE_IMPORT_KEY, &info);
if (r < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to import key");
sc_log(ctx, "Unable to import key");
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE,r);
}
return r;
@ -230,12 +230,12 @@ muscle_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
int r;
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Muscle supports only RSA keys (for now).");
sc_log(card->ctx, "Muscle supports only RSA keys (for now).");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_NOT_SUPPORTED);
}
keybits = key_info->modulus_length & ~7UL;
if (keybits > 2048) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to generate key, max size is %d",
sc_log(card->ctx, "Unable to generate key, max size is %d",
2048);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_INVALID_ARGUMENTS);
}
@ -264,7 +264,7 @@ muscle_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = sc_card_ctl(card, SC_CARDCTL_MUSCLE_GENERATE_KEY, &args);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to generate key");
sc_log(card->ctx, "Unable to generate key");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,r);
}
@ -275,7 +275,7 @@ muscle_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
extArgs.keyLocation = args.publicKeyLocation;
r = sc_card_ctl(card, SC_CARDCTL_MUSCLE_EXTRACT_KEY, &extArgs);
if (r < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to extract the public key");
sc_log(card->ctx, "Unable to extract the public key");
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,r);
}

View File

@ -95,7 +95,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
const char *itag=NULL, *otag=NULL;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type 0x%X; num %i; info %p; obj %p", type, num, info_out, obj_out);
sc_log(ctx, "type 0x%X; num %i; info %p; obj %p", type, num, info_out, obj_out);
switch (type) {
case SC_PKCS15_TYPE_CERT_X509:
itag = "certificate-info";
@ -142,18 +142,18 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
if (itag) {
snprintf(name, sizeof(name),"%s-%s", COSM_TITLE, itag);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info template %s",name);
sc_log(ctx, "info template %s",name);
if (sc_profile_get_file(profile, name, &ifile) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'", name);
sc_log(ctx, "profile does not defines template '%s'", name);
return SC_ERROR_INCONSISTENT_PROFILE;
}
}
if (otag) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj template %s",otag);
sc_log(ctx, "obj template %s",otag);
if (sc_profile_get_file(profile, otag, &ofile) < 0) {
sc_file_free(ifile);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'", name);
sc_log(ctx, "profile does not defines template '%s'", name);
return SC_ERROR_INCONSISTENT_PROFILE;
}
@ -170,7 +170,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
ifile->path.value[ifile->path.len-2] |= 0x01;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"info_file(id:%04X,size:%"SC_FORMAT_LEN_SIZE_T"u,rlen:%i)",
ifile->id, ifile->size, ifile->record_length);
*info_out = ifile;
@ -181,7 +181,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
}
if (ofile) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"obj file %04X; size %"SC_FORMAT_LEN_SIZE_T"u; ",
ofile->id, ofile->size);
if (obj_out)
@ -225,7 +225,7 @@ awp_update_blob(struct sc_context *ctx,
*blob_size += lv->len;
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Invalid tlv type %i",type);
sc_log(ctx, "Invalid tlv type %i",type);
return SC_ERROR_INCORRECT_PARAMETERS;
}
@ -274,7 +274,7 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile *
unsigned char *buff = NULL;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container file(file-id:%X,rlen:%i,rcount:%i)",
sc_log(ctx, "container file(file-id:%X,rlen:%i,rcount:%i)",
list_file->id, list_file->record_length, list_file->record_count);
buff = malloc(list_file->record_length);
@ -318,18 +318,18 @@ awp_create_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
int rv = 0;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create container(%X:%X:%X)", acc->prkey_id, acc->cert_id, acc->pubkey_id);
sc_log(ctx, "create container(%X:%X:%X)", acc->prkey_id, acc->cert_id, acc->pubkey_id);
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Create container failed");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner cfile(rcount:%i,rlength:%i)", clist->record_count, clist->record_length);
sc_log(ctx, "contaner cfile(rcount:%i,rlength:%i)", clist->record_count, clist->record_length);
rv = sc_select_file(p15card->card, &clist->path, &file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Create container failed: cannot select container's list");
file->record_length = clist->record_length;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner file(rcount:%i,rlength:%i)", file->record_count, file->record_length);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Append new record %i for private key", file->record_count + 1);
sc_log(ctx, "contaner file(rcount:%i,rlength:%i)", file->record_count, file->record_length);
sc_log(ctx, "Append new record %i for private key", file->record_count + 1);
rv = awp_create_container_record(p15card, profile, file, acc);
@ -350,10 +350,10 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
unsigned char *buff = NULL;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"update container entry(type:%X,id %i,rec %i,offs %i",
type, file_id, rec, offs);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container file(file-id:%X,rlen:%i,rcount:%i)",
sc_log(ctx, "container file(file-id:%X,rlen:%i,rcount:%i)",
list_file->id, list_file->record_length, list_file->record_count);
buff = malloc(list_file->record_length);
@ -379,7 +379,7 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
case SC_PKCS15_TYPE_PUBKEY_RSA:
case COSM_TYPE_PUBKEY_RSA:
if (*(buff + offs + 4))
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Insert public key to container that contains certificate %02X%02X",
sc_log(ctx, "Insert public key to container that contains certificate %02X%02X",
*(buff + offs + 4), *(buff + offs + 5));
*(buff + offs + 0) = (file_id >> 8) & 0xFF;
*(buff + offs + 1) = file_id & 0xFF;
@ -431,7 +431,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
unsigned char *list = NULL;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container(type:%X,obj_id:%X)", type, obj_id);
sc_log(ctx, "update container(type:%X,obj_id:%X)", type, obj_id);
if (prkey_id)
*prkey_id = 0;
@ -484,7 +484,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
for (rec_offs=0; !rv && rec_offs<12; rec_offs+=6) {
int offs;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rec %i; rec_offs %i", rec, rec_offs);
sc_log(ctx, "rec %i; rec_offs %i", rec, rec_offs);
offs = rec*AWP_CONTAINER_RECORD_LEN + rec_offs;
if (*(list + offs + 2)) {
unsigned char *buff = NULL;
@ -516,7 +516,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
if (key_id->len == *(buff + id_offs) &&
!memcmp(key_id->value, buff + id_offs + 1, key_id->len)) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found key file friend");
sc_log(ctx, "found key file friend");
if (!rv)
rv = awp_update_container_entry(p15card, profile, file, type, obj_id, rec + 1, rec_offs);
@ -641,7 +641,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
unsigned ii;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %i, num %i", type, num);
sc_log(ctx, "type %i, num %i", type, num);
switch (type) {
case SC_PKCS15_TYPE_CERT_X509:
snprintf(obj_name, NAME_MAX_LEN, "template-certificate");
@ -666,19 +666,19 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
snprintf(lst_name, NAME_MAX_LEN,"%s-private-list", COSM_TITLE);
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Not supported file type %X", type);
sc_log(ctx, "Not supported file type %X", type);
return SC_ERROR_INVALID_ARGUMENTS;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj_name %s; num 0x%X",obj_name, num);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lst_name %s",lst_name);
sc_log(ctx, "obj_name %s; num 0x%X",obj_name, num);
sc_log(ctx, "lst_name %s",lst_name);
if (sc_profile_get_file(profile, obj_name, &obj_file) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No profile template '%s'", obj_name);
sc_log(ctx, "No profile template '%s'", obj_name);
rv = SC_ERROR_NOT_SUPPORTED;
goto done;
}
else if (sc_profile_get_file(profile, lst_name, &lst_file) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No profile template '%s'", lst_name);
sc_log(ctx, "No profile template '%s'", lst_name);
rv = SC_ERROR_NOT_SUPPORTED;
goto done;
}
@ -730,7 +730,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
goto done;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"ii %i, rv %i; %X; %"SC_FORMAT_LEN_SIZE_T"u",
ii, rv, file->id, file->size);
*(buff + ii) = COSM_LIST_TAG;
@ -740,7 +740,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
*(buff + ii + 4) = file->size & 0xFF;
rv = sc_update_binary(p15card->card, ii, buff + ii, 5, 0);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i",rv);
sc_log(ctx, "rv %i",rv);
if (rv < 0)
goto done;
@ -770,7 +770,7 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
key_info = (struct sc_pkcs15_prkey_info *)obj->data;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "object(%s,type:%X)", obj->label, obj->type);
sc_log(ctx, "object(%s,type:%X)", obj->label, obj->type);
if (obj->type == SC_PKCS15_TYPE_PUBKEY_RSA || obj->type == COSM_TYPE_PUBKEY_RSA )
ki->flags = COSM_TAG_PUBKEY_RSA;
else if (obj->type == SC_PKCS15_TYPE_PRKEY_RSA || obj->type == COSM_TYPE_PRKEY_RSA)
@ -783,14 +783,14 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
ki->label.value = (unsigned char *)strdup(obj->label);
ki->label.len = strlen(obj->label);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"cosm_encode_key_info() label(%u):%s",
ki->label.len, ki->label.value);
/*
* Oberthur saves modulus value without tag and length.
*/
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"pubkey->modulus.len %"SC_FORMAT_LEN_SIZE_T"u",
pubkey->modulus.len);
ki->modulus.value = malloc(pubkey->modulus.len);
@ -821,7 +821,7 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
memcpy(ki->id.value, key_info->id.value, key_info->id.len);
ki->id.len = key_info->id.len;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_encode_key_info() label:%s",ki->label.value);
sc_log(ctx, "cosm_encode_key_info() label:%s",ki->label.value);
done:
ERR_load_ERR_strings();
ERR_load_crypto_strings();
@ -847,13 +847,13 @@ awp_set_key_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile, st
unsigned char *blob;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file:%p, kinfo:%p, cinfo:%p", file, ki, ci);
sc_log(ctx, "file:%p, kinfo:%p, cinfo:%p", file, ki, ci);
blob_size = 2;
blob = malloc(blob_size);
if (!blob)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY, "AWP set key info failed: blob allocation error");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "label:%s",ki->label.value);
sc_log(ctx, "label:%s",ki->label.value);
*blob = (ki->flags >> 8) & 0xFF;
*(blob + 1) = ki->flags & 0xFF;
@ -937,7 +937,7 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
cert_info = (struct sc_pkcs15_cert_info *)obj->data;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Encode cert(%s,id:%s,der(%p,%"SC_FORMAT_LEN_SIZE_T"u))",
obj->label, sc_pkcs15_print_id(&cert_info->id),
obj->content.value, obj->content.len);
@ -1028,7 +1028,7 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
ci->serial.len = i2d_ASN1_INTEGER(X509_get_serialNumber(x), &ci->serial.value);
}
/* if len == 0, and value == NULL, then the cert did not have a serial number.*/
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cert. serial encoded length %i", ci->serial.len);
sc_log(ctx, "cert. serial encoded length %i", ci->serial.len);
#else
do {
@ -1048,7 +1048,7 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
*(ci->serial.value + 1) = encoded_len;
ci->serial.len = encoded_len + 2;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cert. serial encoded length %i", encoded_len);
sc_log(ctx, "cert. serial encoded length %i", encoded_len);
} while (0);
#endif
@ -1108,7 +1108,7 @@ awp_encode_data_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
data_info = (struct sc_pkcs15_data_info *)obj->data;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Encode data(%s,id:%s,der(%p,%"SC_FORMAT_LEN_SIZE_T"u))",
obj->label, sc_pkcs15_print_id(&data_info->id),
obj->content.value, obj->content.len);
@ -1169,7 +1169,7 @@ awp_set_data_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile,
unsigned char *blob;
LOG_FUNC_CALLED(ctx);
sc_debug (ctx, SC_LOG_DEBUG_NORMAL, "Set 'DATA' info %p", di);
sc_log(ctx, "Set 'DATA' info %p", di);
blob_size = 2;
if (!(blob = malloc(blob_size))) {
r = SC_ERROR_OUT_OF_MEMORY;
@ -1319,17 +1319,17 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = awp_new_file(p15card, profile, SC_PKCS15_TYPE_PRKEY_RSA, prvkey_id & 0xFF, &info_file, &key_file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update key info failed: instantiation error");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key id %X; info id%X", key_file->id, info_file->id);
sc_log(ctx, "key id %X; info id%X", key_file->id, info_file->id);
rv = sc_pkcs15init_authenticate(profile, p15card, info_file, SC_AC_OP_READ);
if (rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: 'READ' authentication error");
sc_log(ctx, "AWP update key info failed: 'READ' authentication error");
goto done;
}
rv = sc_select_file(p15card->card, &info_file->path, &file);
if (rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: cannot select info file");
sc_log(ctx, "AWP update key info failed: cannot select info file");
goto done;
}
@ -1339,7 +1339,7 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = sc_read_binary(p15card->card, 0, buf, file->size, 0);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: read info file error");
sc_log(ctx, "AWP update key info failed: read info file error");
goto done;
}
buf_len = rv;
@ -1347,7 +1347,7 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
memset(&ikey, 0, sizeof(ikey));
rv = awp_parse_key_info(ctx, buf, buf_len, &ikey);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: parse key info error");
sc_log(ctx, "AWP update key info failed: parse key info error");
goto done;
}
free(buf);
@ -1385,7 +1385,7 @@ awp_update_df_create_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "COSM new file error");
memset(&icert, 0, sizeof(icert));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Cert Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
rv = awp_encode_cert_info(p15card, obj, &icert);
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot encode info");
@ -1399,7 +1399,7 @@ awp_update_df_create_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
rv = awp_update_container(p15card, profile, SC_PKCS15_TYPE_CERT_X509, &icert.id, obj_id, &prvkey_id);
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot update container");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PrvKeyID:%04X", prvkey_id);
sc_log(ctx, "PrvKeyID:%04X", prvkey_id);
if (prvkey_id)
rv = awp_update_key_info(p15card, profile, prvkey_id, &icert);
@ -1474,7 +1474,7 @@ awp_update_df_create_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "New private key info file error");
pubkey.algorithm = SC_ALGORITHM_RSA;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"PrKey Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
rv = sc_pkcs15_decode_pubkey(ctx, &pubkey, der.value, der.len);
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: decode public key error");
@ -1529,7 +1529,7 @@ awp_update_df_create_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "New public key info file error");
pubkey.algorithm = SC_ALGORITHM_RSA;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"PrKey Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
rv = sc_pkcs15_decode_pubkey(ctx, &pubkey, der.value, der.len);
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update public key' DF failed: decode public key error");
@ -1575,7 +1575,7 @@ awp_update_df_create_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "COSM new file error");
memset(&idata, 0, sizeof(idata));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Data Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
rv = awp_encode_data_info(p15card, obj, &idata);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Data' update DF failed: cannot encode info");
@ -1641,7 +1641,7 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card,
unsigned char *buff=NULL;
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry (type:%X,file-id:%X)", type, file_id);
sc_log(ctx, "update container entry (type:%X,file-id:%X)", type, file_id);
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update contaner entry: cannot get allocate AWP file");
@ -1656,7 +1656,7 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card,
for (rec = 1; rec <= (unsigned)file->record_count; rec++) {
rv = sc_read_record(p15card->card, rec, buff, file->record_length, SC_RECORD_BY_REC_NR);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update contaner entry: read record error %i", rv);
sc_log(ctx, "AWP update contaner entry: read record error %i", rv);
break;
}
rec_len = rv;
@ -1675,26 +1675,26 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card,
if (!memcmp(buff,"\0\0\0\0\0\0\0\0\0\0\0\0",12)) {
rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_ERASE);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update contaner entry: 'erase' authentication error %i", rv);
sc_log(ctx, "AWP update contaner entry: 'erase' authentication error %i", rv);
break;
}
rv = sc_delete_record(p15card->card, rec);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update contaner entry: delete record error %i", rv);
sc_log(ctx, "AWP update contaner entry: delete record error %i", rv);
break;
}
}
else {
rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update contaner entry: 'update' authentication error %i", rv);
sc_log(ctx, "AWP update contaner entry: 'update' authentication error %i", rv);
break;
}
rv = sc_update_record(p15card->card, rec, buff, rec_len, SC_RECORD_BY_REC_NR);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update contaner entry: update record error %i", rv);
sc_log(ctx, "AWP update contaner entry: update record error %i", rv);
break;
}
}
@ -1724,7 +1724,7 @@ awp_remove_from_object_list( struct sc_pkcs15_card *p15card, struct sc_profile *
unsigned char id[2];
LOG_FUNC_CALLED(ctx);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %X; obj_id %X",type, obj_id);
sc_log(ctx, "type %X; obj_id %X",type, obj_id);
switch (type) {
case SC_PKCS15_TYPE_PRKEY_RSA:
@ -1741,7 +1741,7 @@ awp_remove_from_object_list( struct sc_pkcs15_card *p15card, struct sc_profile *
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS, "AWP update object list: invalid type");
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update object list: select '%s' file", lst_name);
sc_log(ctx, "AWP update object list: select '%s' file", lst_name);
rv = sc_profile_get_file(profile, lst_name, &lst_file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update object list: cannot instantiate list file");
@ -1800,11 +1800,11 @@ awp_update_df_delete_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
path = ((struct sc_pkcs15_cert_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
sc_log(ctx, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete cert' update DF failed: cannot get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
sc_log(ctx, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)
@ -1834,11 +1834,11 @@ awp_update_df_delete_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
path = ((struct sc_pkcs15_prkey_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
sc_log(ctx, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete prkey' update DF failed: cannot get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
sc_log(ctx, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)
@ -1868,11 +1868,11 @@ awp_update_df_delete_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
path = ((struct sc_pkcs15_pubkey_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
sc_log(ctx, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete pubkey' update DF failed: cannot get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
sc_log(ctx, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)
@ -1902,11 +1902,11 @@ awp_update_df_delete_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro
path = ((struct sc_pkcs15_data_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
sc_log(ctx, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete DATA' update DF failed: cannot get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
sc_log(ctx, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)

View File

@ -70,7 +70,7 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile
ctx = p15card->card->ctx;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_write_tokeninfo() label '%s'; flags 0x%X", label, flags);
sc_log(ctx, "cosm_write_tokeninfo() label '%s'; flags 0x%X", label, flags);
if (sc_profile_get_file(profile, COSM_TITLE"-token-info", &file)) {
rv = SC_ERROR_INCONSISTENT_PROFILE;
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot find "COSM_TITLE"-token-info");
@ -100,7 +100,7 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile
if (sz < file->size - 4)
memset(buffer + sz, ' ', file->size - sz);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_write_tokeninfo() token label '%s'; oberthur flags 0x%X", buffer, flags);
sc_log(ctx, "cosm_write_tokeninfo() token label '%s'; oberthur flags 0x%X", buffer, flags);
memset(buffer + file->size - 4, 0, 4);
*(buffer + file->size - 1) = flags & 0xFF;
@ -127,7 +127,7 @@ cosm_delete_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
int rv = 0;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "id %04X", df->id);
sc_log(ctx, "id %04X", df->id);
if (df->type==SC_FILE_TYPE_DF) {
rv = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot authenticate SC_AC_OP_DELETE");
@ -174,20 +174,20 @@ cosm_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card)
* it *after* the DF.
* */
if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X",dir->id);
sc_log(ctx, "erase file dir %04X",dir->id);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
goto done;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file ddf %04X",df->id);
sc_log(ctx, "erase file ddf %04X",df->id);
rv = cosm_delete_file(p15card, profile, df);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
goto done;
if (sc_profile_get_file(profile, "private-DF", &dir) >= 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X",dir->id);
sc_log(ctx, "erase file dir %04X",dir->id);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
@ -195,7 +195,7 @@ cosm_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card)
}
if (sc_profile_get_file(profile, "public-DF", &dir) >= 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X",dir->id);
sc_log(ctx, "erase file dir %04X",dir->id);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
@ -204,7 +204,7 @@ cosm_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card)
rv = sc_profile_get_file(profile, COSM_TITLE"-AppDF", &dir);
if (!rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "delete %s; r %i", COSM_TITLE"-AppDF", rv);
sc_log(ctx, "delete %s; r %i", COSM_TITLE"-AppDF", rv);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
}
@ -244,7 +244,7 @@ cosm_create_dir(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
/* Create private objects DF */
for (ii = 0; create_dfs[ii]; ii++) {
if (sc_profile_get_file(profile, create_dfs[ii], &file)) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Inconsistent profile: cannot find %s", create_dfs[ii]);
sc_log(ctx, "Inconsistent profile: cannot find %s", create_dfs[ii]);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCONSISTENT_PROFILE, "Profile do not contains Oberthur AWP file");
}
@ -278,7 +278,7 @@ cosm_create_reference_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
};
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"pin lens %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u",
pin_len, puk_len);
if (!pin || pin_len>0x40)
@ -347,12 +347,12 @@ cosm_update_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (ainfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
return SC_ERROR_OBJECT_NOT_VALID;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ref %i; flags 0x%X", ainfo->attrs.pin.reference, ainfo->attrs.pin.flags);
sc_log(ctx, "ref %i; flags 0x%X", ainfo->attrs.pin.reference, ainfo->attrs.pin.flags);
if (ainfo->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
if (ainfo->attrs.pin.reference != 4)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_PIN_REFERENCE, "cosm_update_pin() invalid SOPIN reference");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update SOPIN ignored");
sc_log(ctx, "Update SOPIN ignored");
rv = SC_SUCCESS;
}
else {
@ -385,9 +385,9 @@ cosm_select_pin_reference(struct sc_profile *profile, struct sc_pkcs15_card *p15
pin_attrs = &auth_info->attrs.pin;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ref %i; flags %X", pin_attrs->reference, pin_attrs->flags);
sc_log(ctx, "ref %i; flags %X", pin_attrs->reference, pin_attrs->flags);
if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pinfile) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
sc_log(ctx, "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
return SC_ERROR_INCONSISTENT_PROFILE;
}
@ -433,7 +433,7 @@ cosm_create_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
pin_attrs = &auth_info->attrs.pin;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create '%.*s'; ref 0x%X; flags %X", (int) sizeof pin_obj->label, pin_obj->label, pin_attrs->reference, pin_attrs->flags);
sc_log(ctx, "create '%.*s'; ref 0x%X; flags %X", (int) sizeof pin_obj->label, pin_obj->label, pin_attrs->reference, pin_attrs->flags);
if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pin_file) < 0)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCONSISTENT_PROFILE, "\""COSM_TITLE"-AppDF\" not defined");
@ -483,7 +483,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
unsigned int structure = 0xFFFFFFFF;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() type %X; num %i",type, num);
sc_log(card->ctx, "cosm_new_file() type %X; num %i",type, num);
while (1) {
switch (type) {
case SC_PKCS15_TYPE_PRKEY_RSA:
@ -518,16 +518,16 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
* the generic class (SC_PKCS15_TYPE_CERT)
*/
if (!(type & ~SC_PKCS15_TYPE_CLASS_MASK)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type %X not supported by card driver",
sc_log(card->ctx, "File type %X not supported by card driver",
type);
return SC_ERROR_INVALID_ARGUMENTS;
}
type &= SC_PKCS15_TYPE_CLASS_MASK;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() template %s; num %i",_template, num);
sc_log(card->ctx, "cosm_new_file() template %s; num %i",_template, num);
if (sc_profile_get_file(profile, _template, &file) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define %s template '%s'",
sc_log(card->ctx, "Profile doesn't define %s template '%s'",
desc, _template);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED);
}
@ -538,7 +538,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
file->ef_structure = structure;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"cosm_new_file() file size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X",
file->size, file->type, file->ef_structure, file->id);
*out = file;
@ -663,7 +663,7 @@ cosm_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
key_info->key_reference = prkf->path.value[prkf->path.len - 1] & 0xFF;
key_info->path = prkf->path;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_generate_key() now delete temporary public key");
sc_log(ctx, "cosm_generate_key() now delete temporary public key");
rv = cosm_delete_file(p15card, profile, tmpf);
sc_file_free(tmpf);
@ -689,7 +689,7 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Create key failed: RSA only supported");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create private key ID:%s", sc_pkcs15_print_id(&key_info->id));
sc_log(ctx, "create private key ID:%s", sc_pkcs15_print_id(&key_info->id));
/* Here, the path of private key file should be defined.
* Nevertheless, we need to instantiate private key to get the ACLs. */
rv = cosm_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
@ -700,7 +700,7 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
file->id = file->path.value[file->path.len - 2] * 0x100
+ file->path.value[file->path.len - 1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Path of private key file to create %s", sc_print_path(&file->path));
sc_log(ctx, "Path of private key file to create %s", sc_print_path(&file->path));
rv = sc_select_file(p15card->card, &file->path, NULL);
if (rv == 0) {
@ -741,7 +741,7 @@ cosm_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (object->type != SC_PKCS15_TYPE_PRKEY_RSA || prkey->algorithm != SC_ALGORITHM_RSA)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Store key failed: RSA only supported");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "store key with ID:%s and path:%s", sc_pkcs15_print_id(&key_info->id),
sc_log(ctx, "store key with ID:%s and path:%s", sc_pkcs15_print_id(&key_info->id),
sc_print_path(&key_info->path));
rv = sc_select_file(p15card->card, &key_info->path, &file);
@ -790,11 +790,11 @@ cosm_emu_update_any_df(struct sc_profile *profile, struct sc_pkcs15_card *p15car
SC_FUNC_CALLED(ctx, 1);
switch(op) {
case SC_AC_OP_ERASE:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update DF; erase object('%.*s',type:%X)", (int) sizeof object->label, object->label, object->type);
sc_log(ctx, "Update DF; erase object('%.*s',type:%X)", (int) sizeof object->label, object->label, object->type);
rv = awp_update_df_delete(p15card, profile, object);
break;
case SC_AC_OP_CREATE:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update DF; create object('%.*s',type:%X)", (int) sizeof object->label, object->label, object->type);
sc_log(ctx, "Update DF; create object('%.*s',type:%X)", (int) sizeof object->label, object->label, object->type);
rv = awp_update_df_create(p15card, profile, object);
break;
}
@ -838,7 +838,7 @@ cosm_emu_update_tokeninfo(struct sc_profile *profile, struct sc_pkcs15_card *p15
*(buf + file->size - 1) = flags % 0x100;
*(buf + file->size - 2) = (flags % 0x10000) / 0x100;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update token info (label:'%s',flags:%X,p15card->flags:%X)", buf, flags, p15card->flags);
sc_log(ctx, "Update token info (label:'%s',flags:%X,p15card->flags:%X)", buf, flags, p15card->flags);
rv = sc_pkcs15init_update_file(profile, p15card, file, buf, file->size);
free(buf);
sc_file_free(file);

View File

@ -123,7 +123,7 @@ static int openpgp_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
LOG_FUNC_CALLED(card->ctx);
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "only RSA is currently supported");
sc_log(card->ctx, "only RSA is currently supported");
return SC_ERROR_NOT_SUPPORTED;
}
@ -181,7 +181,7 @@ static int openpgp_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card
key_info.key_id = kid->value[0];
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "only RSA is currently supported");
sc_log(card->ctx, "only RSA is currently supported");
return SC_ERROR_NOT_SUPPORTED;
}

View File

@ -75,7 +75,7 @@ static int create_sysdf(sc_profile_t *profile, sc_card_t *card, const char *name
r = sc_create_file(card, file);
sc_file_free(file);
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Create %s failed: %s\n", name, sc_strerror(r));
return r;
}
@ -186,7 +186,7 @@ static int rtecp_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
if (puk_len != 0)
{
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Do not enter User unblocking PIN (PUK): %s\n",
sc_log(ctx, "Do not enter User unblocking PIN (PUK): %s\n",
sc_strerror(SC_ERROR_NOT_SUPPORTED));
return SC_ERROR_NOT_SUPPORTED;
}
@ -198,7 +198,7 @@ static int rtecp_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
if (auth_info->attrs.pin.reference != RTECP_SO_PIN_REF
&& auth_info->attrs.pin.reference != RTECP_USER_PIN_REF)
{
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PIN reference %i not found in standard"
sc_log(ctx, "PIN reference %i not found in standard"
" (Rutoken ECP) PINs\n", auth_info->attrs.pin.reference);
return SC_ERROR_NOT_SUPPORTED;
}
@ -216,7 +216,7 @@ static int rtecp_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
acl = sc_file_get_acl_entry(file, SC_AC_OP_PIN_RESET);
if (acl && acl->method == SC_AC_CHV && acl->key_ref == RTECP_SO_PIN_REF) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Allow reset of User PIN with SoPIN\n");
sc_log(ctx, "Allow reset of User PIN with SoPIN\n");
reset_by_sopin = 1;
}
sc_file_free(file);
@ -321,7 +321,7 @@ static int rtecp_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
&& key_info->modulus_length
!= SC_PKCS15_GOSTR3410_KEYSIZE))
{
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
key_info->modulus_length);
return SC_ERROR_INVALID_ARGUMENTS;
@ -522,7 +522,7 @@ static int rtecp_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
sc_file_free(pukey_df);
}
else if (card->ctx->debug >= 2)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n", "Get PuKey-DF info failed");
sc_log(card->ctx, "%s\n", "Get PuKey-DF info failed");
}
if (r == SC_SUCCESS)
{
@ -531,7 +531,7 @@ static int rtecp_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = sc_change_reference_data(card, 0, 0, NULL, 0,
buf, key_len, NULL);
if (r && card->ctx->debug >= 2)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n", "Store public key failed");
sc_log(card->ctx, "%s\n", "Store public key failed");
}
end:
assert(buf);

View File

@ -99,7 +99,7 @@ rutoken_select_pin_reference(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
pin_ref = auth_info->attrs.pin.reference;
so_pin_flag = auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "PIN reference %i%s\n",
sc_log(p15card->card->ctx, "PIN reference %i%s\n",
pin_ref, so_pin_flag ? " SO PIN flag" : "");
if ((pin_ref == SC_RUTOKEN_DEF_ID_GCHV_ADMIN && so_pin_flag)
@ -133,7 +133,7 @@ rutoken_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
if (puk_len != 0)
{
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"Do not enter User unblocking PIN (PUK): %s\n",
sc_strerror(SC_ERROR_NOT_SUPPORTED));
return SC_ERROR_NOT_SUPPORTED;
@ -152,11 +152,11 @@ rutoken_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
return SC_SUCCESS;
else
{
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Incorrect PIN\n");
sc_log(ctx, "Incorrect PIN\n");
break;
}
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"PIN reference %i not found in standard (Rutoken) PINs\n",
auth_info->attrs.pin.reference);
return SC_ERROR_NOT_SUPPORTED;
@ -292,7 +292,7 @@ rutoken_erase(struct sc_profile *profile, sc_pkcs15_card_t *p15card)
{
ret = create_typical_fs(card);
if (ret != SC_SUCCESS)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Failed to create typical fs: %s\n",
sc_strerror(ret));
ret_end = sc_card_ctl(card, SC_CARDCTL_RUTOKEN_FORMAT_END, NULL);
@ -300,7 +300,7 @@ rutoken_erase(struct sc_profile *profile, sc_pkcs15_card_t *p15card)
ret = ret_end;
}
if (ret != SC_SUCCESS)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
sc_log(card->ctx,
"Failed to erase: %s\n", sc_strerror(ret));
else
sc_free_apps(card);

View File

@ -565,7 +565,7 @@ static int sc_hsm_emu_update_any_df(struct sc_profile *profile, struct sc_pkcs15
SC_FUNC_CALLED(ctx, 1);
switch(op) {
case SC_AC_OP_ERASE:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update DF; erase object('%s',type:%X)", object->label, object->type);
sc_log(ctx, "Update DF; erase object('%s',type:%X)", object->label, object->type);
switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
case SC_PKCS15_TYPE_PRKEY:
rv = sc_hsm_delete_ef(p15card, PRKD_PREFIX, ((struct sc_pkcs15_prkey_info *)object->data)->key_reference);
@ -583,7 +583,7 @@ static int sc_hsm_emu_update_any_df(struct sc_profile *profile, struct sc_pkcs15
break;
case SC_AC_OP_UPDATE:
case SC_AC_OP_CREATE:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update DF; create object('%s',type:%X)", object->label, object->type);
sc_log(ctx, "Update DF; create object('%s',type:%X)", object->label, object->type);
switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
case SC_PKCS15_TYPE_PUBKEY:
rv = SC_SUCCESS;

View File

@ -101,7 +101,7 @@ setcos_init_card(sc_profile_t *profile, sc_pkcs15_card_t *p15card)
/* Create the MF if it doesn't exist yet */
r = sc_select_file(p15card->card, &mf->path, NULL);
if (r == SC_ERROR_FILE_NOT_FOUND) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "MF doesn't exist, creating now");
sc_log(ctx, "MF doesn't exist, creating now");
/* Fix up the file's ACLs */
r = sc_pkcs15init_fixup_file(profile, p15card, mf);
@ -119,7 +119,7 @@ setcos_init_card(sc_profile_t *profile, sc_pkcs15_card_t *p15card)
r = sc_select_file(p15card->card, &pinfile->path, NULL);
if (r == SC_ERROR_FILE_NOT_FOUND) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Global pin file doesn't exist, creating now");
sc_log(ctx, "Global pin file doesn't exist, creating now");
/* Fix up the file's ACLs */
r = sc_pkcs15init_fixup_file(profile, p15card, pinfile);
@ -214,8 +214,8 @@ setcos_create_pin(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
r = sc_select_file(p15card->card, &pinfile->path, &pinfile);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Cannot select 'pinfile'");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "pinfile->status:%X", pinfile->status);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create PIN with reference:%X, flags:%X, path:%s",
sc_log(ctx, "pinfile->status:%X", pinfile->status);
sc_log(ctx, "create PIN with reference:%X, flags:%X, path:%s",
auth_info->attrs.pin.reference, auth_info->attrs.pin.flags, sc_print_path(&auth_info->path));
if (pinfile->status == SC_FILE_STATUS_CREATION)
@ -269,14 +269,14 @@ setcos_new_file(sc_profile_t *profile, sc_card_t *card,
else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_DATA_OBJECT)
tag = "data";
else {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported file type");
sc_log(card->ctx, "Unsupported file type");
return SC_ERROR_INVALID_ARGUMENTS;
}
/* Get template from profile */
snprintf(name, sizeof(name), "template-%s", tag);
if (sc_profile_get_file(profile, name, &file) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define %s", name);
sc_log(card->ctx, "Profile doesn't define %s", name);
return SC_ERROR_NOT_SUPPORTED;
}
@ -334,7 +334,7 @@ setcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
if ( (keybits < 512) || (keybits > 1024) || (keybits & 0x7))
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid key length");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create private key ID:%s\n", sc_pkcs15_print_id(&key_info->id));
sc_log(ctx, "create private key ID:%s\n", sc_pkcs15_print_id(&key_info->id));
/* Get the private key file */
r = setcos_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
@ -351,7 +351,7 @@ setcos_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
key_info->key_reference = file->path.value[file->path.len - 1] & 0xFF;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Path of private key file to create %s\n", sc_print_path(&file->path));
sc_log(ctx, "Path of private key file to create %s\n", sc_print_path(&file->path));
r = sc_select_file(p15card->card, &file->path, NULL);
if (!r) {
@ -393,7 +393,7 @@ setcos_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if ( (keybits < 512) || (keybits > 1024) || (keybits & 0x7))
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS, "Invalid key length");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "store key with ID:%s and path:%s\n", sc_pkcs15_print_id(&key_info->id),
sc_log(ctx, "store key with ID:%s and path:%s\n", sc_pkcs15_print_id(&key_info->id),
sc_print_path(&key_info->path));
r = sc_select_file(p15card->card, &key_info->path, &file);
@ -486,7 +486,7 @@ setcos_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
keybits = ((raw_pubkey[0] * 256) + raw_pubkey[1]); /* modulus bit length */
if (keybits != key_info->modulus_length) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
sc_log(ctx,
"key-size from card[%"SC_FORMAT_LEN_SIZE_T"u] does not match[%"SC_FORMAT_LEN_SIZE_T"u]\n",
keybits, key_info->modulus_length);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PKCS15INIT, "Failed to generate key");

View File

@ -911,7 +911,7 @@ static int starcos_finalize_card(sc_card_t *card)
tfile.id = 0x3f00;
r = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_END, &tfile);
if (r < 0)
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "failed to call CREATE END for the MF\n");
sc_log(card->ctx, "failed to call CREATE END for the MF\n");
/* call CREATE END for the apps (pkcs15) DF */
tfile.type = SC_FILE_TYPE_DF;
tfile.id = 0x5015;

View File

@ -618,7 +618,7 @@ static int sm_decrypt(const struct iso_sm_ctx *ctx, sc_card_t *card,
goto err;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Decrypted APDU sw1=%02x sw2=%02x",
sc_log(card->ctx, "Decrypted APDU sw1=%02x sw2=%02x",
apdu->sw1, apdu->sw2);
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "Decrypted APDU response data",
apdu->resp, apdu->resplen);

View File

@ -103,7 +103,7 @@ static int initialize(int reader_id, int verbose,
reader_count = sc_ctx_get_reader_count(*ctx);
if (reader_count == 0) {
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "No reader not found.\n");
sc_log(*ctx, "No reader not found.\n");
return SC_ERROR_NO_READERS_FOUND;
}
@ -113,19 +113,19 @@ static int initialize(int reader_id, int verbose,
*reader = sc_ctx_get_reader(*ctx, i);
if (sc_detect_card_presence(*reader) & SC_READER_CARD_PRESENT) {
reader_id = i;
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "Using the first reader"
sc_log(*ctx, "Using the first reader"
" with a card: %s", (*reader)->name);
break;
}
}
if ((unsigned int) reader_id >= reader_count) {
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "No card found, using the first reader.");
sc_log(*ctx, "No card found, using the first reader.");
reader_id = 0;
}
}
if ((unsigned int) reader_id >= reader_count) {
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "Invalid reader number "
sc_log(*ctx, "Invalid reader number "
"(%d), only %d available.\n", reader_id, reader_count);
return SC_ERROR_NO_READERS_FOUND;
}

View File

@ -132,7 +132,7 @@ static int initialize(int reader_id, int verbose,
reader_count = sc_ctx_get_reader_count(*ctx);
if (reader_count == 0) {
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "No reader not found.\n");
sc_log(*ctx, "No reader not found.\n");
return SC_ERROR_NO_READERS_FOUND;
}
@ -142,19 +142,19 @@ static int initialize(int reader_id, int verbose,
*reader = sc_ctx_get_reader(*ctx, i);
if (sc_detect_card_presence(*reader) & SC_READER_CARD_PRESENT) {
reader_id = i;
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "Using the first reader"
sc_log(*ctx, "Using the first reader"
" with a card: %s", (*reader)->name);
break;
}
}
if ((unsigned int) reader_id >= reader_count) {
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "No card found, using the first reader.");
sc_log(*ctx, "No card found, using the first reader.");
reader_id = 0;
}
}
if ((unsigned int) reader_id >= reader_count) {
sc_debug(*ctx, SC_LOG_DEBUG_NORMAL, "Invalid reader number "
sc_log(*ctx, "Invalid reader number "
"(%d), only %d available.\n", reader_id, reader_count);
return SC_ERROR_NO_READERS_FOUND;
}