diff --git a/src/libopensc/apdu.c b/src/libopensc/apdu.c index 89f1c996..50469c06 100644 --- a/src/libopensc/apdu.c +++ b/src/libopensc/apdu.c @@ -372,8 +372,10 @@ sc_single_transmit(struct sc_card *card, struct sc_apdu *apdu) if (card->reader->ops->transmit == NULL) LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "cannot transmit APDU"); - sc_log(ctx, "CLA:%X, INS:%X, P1:%X, P2:%X, data(%i) %p", - apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data); + sc_log(ctx, + "CLA:%X, INS:%X, P1:%X, P2:%X, data(%"SC_FORMAT_LEN_SIZE_T"u) %p", + apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, + apdu->data); #ifdef ENABLE_SM if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT) return sc_sm_single_transmit(card, apdu); @@ -659,8 +661,9 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu) if (!len) { apdu->cse = SC_APDU_CASE_1; - sc_log(ctx, "CASE_1 APDU: %lu bytes:\tins=%02x p1=%02x p2=%02x lc=%04x le=%04x", - (unsigned long) len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le); + sc_log(ctx, + "CASE_1 APDU: %"SC_FORMAT_LEN_SIZE_T"u bytes:\tins=%02x p1=%02x p2=%02x lc=%04"SC_FORMAT_LEN_SIZE_T"x le=%04"SC_FORMAT_LEN_SIZE_T"x", + len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le); return SC_SUCCESS; } @@ -681,7 +684,9 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu) apdu->lc += *p++; len -= 3; if (len < apdu->lc) { - sc_log(ctx, "APDU too short (need %lu more bytes)", (unsigned long) apdu->lc - len); + sc_log(ctx, + "APDU too short (need %"SC_FORMAT_LEN_SIZE_T"u more bytes)", + apdu->lc - len); return SC_ERROR_INVALID_DATA; } apdu->data = p; @@ -719,7 +724,9 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu) apdu->lc = *p++; len--; if (len < apdu->lc) { - sc_log(ctx, "APDU too short (need %lu more bytes)", (unsigned long) apdu->lc - len); + sc_log(ctx, + "APDU too short (need %"SC_FORMAT_LEN_SIZE_T"u more bytes)", + apdu->lc - len); return SC_ERROR_INVALID_DATA; } apdu->data = p; @@ -743,10 +750,12 @@ sc_bytes2apdu(sc_context_t *ctx, const u8 *buf, size_t len, sc_apdu_t *apdu) return SC_ERROR_INVALID_DATA; } - sc_log(ctx, "Case %d %s APDU, %lu bytes:\tins=%02x p1=%02x p2=%02x lc=%04x le=%04x", - apdu->cse & SC_APDU_SHORT_MASK, - (apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short", - (unsigned long) len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le); + sc_log(ctx, + "Case %d %s APDU, %"SC_FORMAT_LEN_SIZE_T"u bytes:\tins=%02x p1=%02x p2=%02x lc=%04"SC_FORMAT_LEN_SIZE_T"x le=%04"SC_FORMAT_LEN_SIZE_T"x", + apdu->cse & SC_APDU_SHORT_MASK, + (apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short", + len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, + apdu->le); return SC_SUCCESS; } diff --git a/src/libopensc/asn1.c b/src/libopensc/asn1.c index 9b931433..88d35db9 100644 --- a/src/libopensc/asn1.c +++ b/src/libopensc/asn1.c @@ -415,8 +415,9 @@ const u8 *sc_asn1_skip_tag(sc_context_t *ctx, const u8 ** buf, size_t *buflen, return NULL; len -= (p - *buf); /* header size */ if (taglen > len) { - sc_debug(ctx, SC_LOG_DEBUG_ASN1, "too long ASN.1 object (size %d while only %d available)\n", - taglen, len); + sc_debug(ctx, SC_LOG_DEBUG_ASN1, + "too long ASN.1 object (size %"SC_FORMAT_LEN_SIZE_T"u while only %"SC_FORMAT_LEN_SIZE_T"u available)\n", + taglen, len); return NULL; } *buflen -= (p - *buf) + taglen; @@ -1276,7 +1277,9 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry, case SC_ASN1_BOOLEAN: if (parm != NULL) { if (objlen != 1) { - sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 object length: %d\n", objlen); + sc_debug(ctx, SC_LOG_DEBUG_ASN1, + "invalid ASN.1 object length: %"SC_FORMAT_LEN_SIZE_T"u\n", + objlen); r = SC_ERROR_INVALID_ASN1_OBJECT; } else *((int *) parm) = obj[0] ? 1 : 0; @@ -1444,10 +1447,9 @@ static int asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1, struct sc_asn1_entry *entry = asn1; size_t left = len, objlen; - sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*scalled, left=%u, depth %d%s\n", - depth, depth, "", - left, depth, - choice ? ", choice" : ""); + sc_debug(ctx, SC_LOG_DEBUG_ASN1, + "%*.*scalled, left=%"SC_FORMAT_LEN_SIZE_T"u, depth %d%s\n", + depth, depth, "", left, depth, choice ? ", choice" : ""); if (!p) return SC_ERROR_ASN1_OBJECT_NOT_FOUND; @@ -1553,9 +1555,10 @@ static int asn1_encode_entry(sc_context_t *ctx, const struct sc_asn1_entry *entr (entry->flags & SC_ASN1_PRESENT)? "" : " (not present)"); if (!(entry->flags & SC_ASN1_PRESENT)) goto no_object; - sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*stype=%d, tag=0x%02x, parm=%p, len=%u\n", - depth, depth, "", - entry->type, entry->tag, parm, len? *len : 0); + sc_debug(ctx, SC_LOG_DEBUG_ASN1, + "%*.*stype=%d, tag=0x%02x, parm=%p, len=%"SC_FORMAT_LEN_SIZE_T"u\n", + depth, depth, "", entry->type, entry->tag, parm, + len ? *len : 0); if (entry->type == SC_ASN1_CHOICE) { const struct sc_asn1_entry *list, *choice = NULL; @@ -1733,7 +1736,9 @@ no_object: if (buf) free(buf); if (r >= 0) - sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*slength of encoded item=%u\n", depth, depth, "", *objlen); + sc_debug(ctx, SC_LOG_DEBUG_ASN1, + "%*.*slength of encoded item=%"SC_FORMAT_LEN_SIZE_T"u\n", + depth, depth, "", *objlen); return r; } @@ -1916,8 +1921,10 @@ sc_asn1_sig_value_sequence_to_rs(struct sc_context *ctx, unsigned char *in, size memcpy(buf + (halflen - r_len), r, r_len); memcpy(buf + (buflen - s_len), s, s_len); - sc_log(ctx, "r(%i): %s", halflen, sc_dump_hex(buf, halflen)); - sc_log(ctx, "s(%i): %s", halflen, sc_dump_hex(buf + halflen, halflen)); + sc_log(ctx, "r(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen, + sc_dump_hex(buf, halflen)); + sc_log(ctx, "s(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen, + sc_dump_hex(buf + halflen, halflen)); rv = SC_SUCCESS; done: diff --git a/src/libopensc/aux-data.c b/src/libopensc/aux-data.c index 3b7c4744..84d539b2 100644 --- a/src/libopensc/aux-data.c +++ b/src/libopensc/aux-data.c @@ -157,7 +157,9 @@ sc_aux_data_get_md_guid(struct sc_context *ctx, struct sc_auxiliary_data *aux_da strlcat(guid, "}", sizeof(guid)); if (*out_size < strlen(guid)) { - sc_log(ctx, "aux-data: buffer too small: out_size:%i < guid-length:%i", *out_size, strlen(guid)); + sc_log(ctx, + "aux-data: buffer too small: out_size:%"SC_FORMAT_LEN_SIZE_T"u < guid-length:%"SC_FORMAT_LEN_SIZE_T"u", + *out_size, strlen(guid)); LOG_FUNC_RETURN(ctx, SC_ERROR_BUFFER_TOO_SMALL); } diff --git a/src/libopensc/card-atrust-acos.c b/src/libopensc/card-atrust-acos.c index 9d3c41fd..33496b73 100644 --- a/src/libopensc/card-atrust-acos.c +++ b/src/libopensc/card-atrust-acos.c @@ -393,11 +393,12 @@ static int atrust_acos_select_file(struct sc_card *card, pbuf[0] = '\0'; sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "current path (%s, %s): %s (len: %u)\n", - (card->cache.current_path.type==SC_PATH_TYPE_DF_NAME?"aid":"path"), - (card->cache.valid?"valid":"invalid"), pbuf, - card->cache.current_path.len); - + "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", + card->cache.valid ? "valid" : "invalid", pbuf, + card->cache.current_path.len); + memcpy(path, in_path->value, in_path->len); pathlen = in_path->len; diff --git a/src/libopensc/card-authentic.c b/src/libopensc/card-authentic.c index 5cc5062d..4da59335 100644 --- a/src/libopensc/card-authentic.c +++ b/src/libopensc/card-authentic.c @@ -300,7 +300,7 @@ authentic_parse_credential_data(struct sc_context *ctx, struct sc_pin_cmd_data * rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_DOCP_ACLS, &data, &data_len); LOG_TEST_RET(ctx, rv, "failed to get ACLs"); - sc_log(ctx, "data_len:%i", data_len); + sc_log(ctx, "data_len:%"SC_FORMAT_LEN_SIZE_T"u", data_len); if (data_len == 10) { for (ii=0; ii<5; ii++) { unsigned char acl = *(data + ii*2); @@ -857,14 +857,16 @@ authentic_read_binary(struct sc_card *card, unsigned int idx, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "offs:%i,count:%i,max_recv_size:%i", idx, count, card->max_recv_size); + sc_log(ctx, + "offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_recv_size:%"SC_FORMAT_LEN_SIZE_T"u", + idx, count, card->max_recv_size); /* Data size more then 256 bytes can happen when card reader is * configurated with max_send/recv_size more then 255/256 bytes * (for ex. 'remote-access' reader) . * In this case create chained 'read-binary' APDUs. */ - sc_log(ctx, "reader flags 0x%X", card->reader->flags); + sc_log(ctx, "reader flags 0x%lX", card->reader->flags); if (count > 256 && !(card->reader->flags & SC_READER_HAS_WAITING_AREA)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid size of the data to read"); @@ -911,10 +913,12 @@ authentic_write_binary(struct sc_card *card, unsigned int idx, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "offs:%i,count:%i,max_send_size:%i", idx, count, card->max_send_size); + sc_log(ctx, + "offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_send_size:%"SC_FORMAT_LEN_SIZE_T"u", + idx, count, card->max_send_size); /* see comments for authentic_read_binary() */ - sc_log(ctx, "reader flags 0x%X", card->reader->flags); + sc_log(ctx, "reader flags 0x%lX", card->reader->flags); if (count > 255 && !(card->reader->flags & SC_READER_HAS_WAITING_AREA)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid size of the data to read"); @@ -960,10 +964,12 @@ authentic_update_binary(struct sc_card *card, unsigned int idx, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "offs:%i,count:%i,max_send_size:%i", idx, count, card->max_send_size); + sc_log(ctx, + "offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_send_size:%"SC_FORMAT_LEN_SIZE_T"u", + idx, count, card->max_send_size); /* see comments for authentic_read_binary() */ - sc_log(ctx, "reader flags 0x%X", card->reader->flags); + sc_log(ctx, "reader flags 0x%lX", card->reader->flags); if (count > 255 && !(card->reader->flags & SC_READER_HAS_WAITING_AREA)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid size of the data to read"); @@ -1019,14 +1025,14 @@ authentic_process_fci(struct sc_card *card, struct sc_file *file, tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x6F, &taglen); if (tag != NULL) { - sc_log(ctx, " FCP length %i", taglen); + sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen); buf = tag; buflen = taglen; } tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x62, &taglen); if (tag != NULL) { - sc_log(ctx, " FCP length %i", taglen); + sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen); buf = tag; buflen = taglen; } @@ -1035,7 +1041,9 @@ authentic_process_fci(struct sc_card *card, struct sc_file *file, LOG_TEST_RET(ctx, rv, "ISO parse FCI failed"); if (!file->sec_attr_len) { - sc_log(ctx, "ACLs not found in data(%i) %s", buflen, sc_dump_hex(buf, buflen)); + sc_log(ctx, + "ACLs not found in data(%"SC_FORMAT_LEN_SIZE_T"u) %s", + buflen, sc_dump_hex(buf, buflen)); sc_log(ctx, "Path:%s; Type:%X; PathType:%X", sc_print_path(&file->path), file->type, file->path.type); if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF) { file->type = SC_FILE_TYPE_DF; @@ -1045,7 +1053,8 @@ authentic_process_fci(struct sc_card *card, struct sc_file *file, } } - sc_log(ctx, "ACL data(%i):%s", file->sec_attr_len, sc_dump_hex(file->sec_attr, file->sec_attr_len)); + sc_log(ctx, "ACL data(%"SC_FORMAT_LEN_SIZE_T"u):%s", file->sec_attr_len, + sc_dump_hex(file->sec_attr, file->sec_attr_len)); for (ii = 0; ii < file->sec_attr_len / 2; ii++) { unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii]; unsigned char acl = *(file->sec_attr + ii*2); @@ -1418,10 +1427,14 @@ authentic_pin_change_pinpad(struct sc_card *card, unsigned reference, int *tries memset(pin2_data, pin_cmd.pin2.pad_char, sizeof(pin2_data)); pin_cmd.pin2.data = pin2_data; - sc_log(ctx, "PIN1 lengths max/min/pad: %i/%i/%i", pin_cmd.pin1.max_length, pin_cmd.pin1.min_length, - pin_cmd.pin1.pad_length); - sc_log(ctx, "PIN2 lengths max/min/pad: %i/%i/%i", pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, - pin_cmd.pin2.pad_length); + sc_log(ctx, + "PIN1 lengths max/min/pad: %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + pin_cmd.pin1.max_length, pin_cmd.pin1.min_length, + pin_cmd.pin1.pad_length); + sc_log(ctx, + "PIN2 lengths max/min/pad: %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, + pin_cmd.pin2.pad_length); rv = iso_ops->pin_cmd(card, &pin_cmd, tries_left); @@ -1511,8 +1524,10 @@ authentic_chv_set_pinpad(struct sc_card *card, unsigned char reference) memcpy(&pin_cmd.pin2, &pin_cmd.pin1, sizeof(pin_cmd.pin1)); memset(&pin_cmd.pin1, 0, sizeof(pin_cmd.pin1)); - sc_log(ctx, "PIN2 max/min/pad %i/%i/%i", - pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, pin_cmd.pin2.pad_length); + sc_log(ctx, + "PIN2 max/min/pad %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, + pin_cmd.pin2.pad_length); rv = iso_ops->pin_cmd(card, &pin_cmd, NULL); LOG_FUNC_RETURN(ctx, rv); @@ -1560,9 +1575,11 @@ authentic_pin_get_policy (struct sc_card *card, struct sc_pin_cmd_data *data) data->flags |= SC_PIN_CMD_NEED_PADDING; - sc_log(ctx, "PIN policy: size max/min/pad %i/%i/%i, tries max/left %i/%i", - data->pin1.max_length, data->pin1.min_length, data->pin1.pad_length, - data->pin1.max_tries, data->pin1.tries_left); + sc_log(ctx, + "PIN policy: size max/min/pad %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u, tries max/left %i/%i", + data->pin1.max_length, data->pin1.min_length, + data->pin1.pad_length, data->pin1.max_tries, + data->pin1.tries_left); LOG_FUNC_RETURN(ctx, rv); } @@ -1791,11 +1808,15 @@ authentic_manage_sdo_encode_prvkey(struct sc_card *card, struct sc_pkcs15_prkey blob_len = 0; /* Encode public RSA key part */ - sc_log(ctx, "modulus.len:%i blob_len:%i", rsa.modulus.len, blob_len); + sc_log(ctx, + "modulus.len:%"SC_FORMAT_LEN_SIZE_T"u blob_len:%"SC_FORMAT_LEN_SIZE_T"u", + rsa.modulus.len, blob_len); rv = authentic_update_blob(ctx, AUTHENTIC_TAG_RSA_PUBLIC_MODULUS, rsa.modulus.data, rsa.modulus.len, &blob, &blob_len); LOG_TEST_RET(ctx, rv, "SDO RSA Modulus encode error"); - sc_log(ctx, "exponent.len:%i blob_len:%i", rsa.exponent.len, blob_len); + sc_log(ctx, + "exponent.len:%"SC_FORMAT_LEN_SIZE_T"u blob_len:%"SC_FORMAT_LEN_SIZE_T"u", + rsa.exponent.len, blob_len); rv = authentic_update_blob(ctx, AUTHENTIC_TAG_RSA_PUBLIC_EXPONENT, rsa.exponent.data, rsa.exponent.len, &blob, &blob_len); LOG_TEST_RET(ctx, rv, "SDO RSA Exponent encode error"); @@ -1907,7 +1928,7 @@ authentic_manage_sdo_generate(struct sc_card *card, struct sc_authentic_sdo *sdo rv = authentic_manage_sdo_encode(card, sdo, SC_CARDCTL_AUTHENTIC_SDO_GENERATE, &data, &data_len); LOG_TEST_RET(ctx, rv, "Cannot encode SDO data"); - sc_log(ctx, "encoded SDO length %i", data_len); + sc_log(ctx, "encoded SDO length %"SC_FORMAT_LEN_SIZE_T"u", data_len); sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x47, 0x00, 0x00); apdu.data = data; @@ -1944,7 +1965,7 @@ authentic_manage_sdo(struct sc_card *card, struct sc_authentic_sdo *sdo, unsigne rv = authentic_manage_sdo_encode(card, sdo, cmd, &data, &data_len); LOG_TEST_RET(ctx, rv, "Cannot encode SDO data"); - sc_log(ctx, "encoded SDO length %i", data_len); + sc_log(ctx, "encoded SDO length %"SC_FORMAT_LEN_SIZE_T"u", data_len); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDB, 0x3F, 0xFF); apdu.data = data; @@ -2048,7 +2069,9 @@ authentic_decipher(struct sc_card *card, const unsigned char *in, size_t in_len, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "crgram_len %i; outlen %i", in_len, out_len); + sc_log(ctx, + "crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u", + in_len, out_len); if (!out || !out_len || in_len > SC_MAX_APDU_BUFFER_SIZE) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); @@ -2257,8 +2280,10 @@ authentic_sm_get_wrapped_apdu(struct sc_card *card, struct sc_apdu *plain, struc if (!plain || !sm_apdu) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "called; CLA:%X, INS:%X, P1:%X, P2:%X, data(%i) %p", - plain->cla, plain->ins, plain->p1, plain->p2, plain->datalen, plain->data); + sc_log(ctx, + "called; CLA:%X, INS:%X, P1:%X, P2:%X, data(%"SC_FORMAT_LEN_SIZE_T"u) %p", + plain->cla, plain->ins, plain->p1, plain->p2, plain->datalen, + plain->data); *sm_apdu = NULL; if ((plain->cla & 0x04) diff --git a/src/libopensc/card-belpic.c b/src/libopensc/card-belpic.c index bbfb0582..c2231892 100644 --- a/src/libopensc/card-belpic.c +++ b/src/libopensc/card-belpic.c @@ -642,7 +642,9 @@ static int get_carddata(sc_card_t *card, u8* carddata_loc, unsigned int carddata return r; } if(apdu.resplen < carddataloc_len) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "GetCardData: card returned %d bytes rather than expected %d\n", apdu.resplen, carddataloc_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "GetCardData: card returned %"SC_FORMAT_LEN_SIZE_T"u bytes rather than expected %d\n", + apdu.resplen, carddataloc_len); return SC_ERROR_WRONG_LENGTH; } diff --git a/src/libopensc/card-cac.c b/src/libopensc/card-cac.c index 51f5ceed..7801d075 100644 --- a/src/libopensc/card-cac.c +++ b/src/libopensc/card-cac.c @@ -333,8 +333,10 @@ 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, "%02x %02x %02x %d : %d %d\n", - ins, p1, p2, sendbuflen, card->max_send_size, card->max_recv_size); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "%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); rbuf = rbufinitbuf; rbuflen = sizeof(rbufinitbuf); @@ -363,14 +365,16 @@ 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,"calling sc_transmit_apdu flags=%x le=%d, resplen=%d, resp=%p", - apdu.flags, apdu.le, apdu.resplen, apdu.resp); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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,"result r=%d apdu.resplen=%d sw1=%02x sw2=%02x", - r, apdu.resplen, apdu.sw1, apdu.sw2); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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"); goto err; @@ -431,7 +435,7 @@ static int cac_read_file(sc_card_t *card, int file_type, u8 **out_buf, size_t *o left = size = lebytes2ushort(count); sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, - "got %d bytes out_ptr=%p count&=%p count[0]=0x%02x count[1]=0x%02x, len=0x%04x (%d)", + "got %"SC_FORMAT_LEN_SIZE_T"u bytes out_ptr=%p count&=%p count[0]=0x%02x count[1]=0x%02x, len=0x%04"SC_FORMAT_LEN_SIZE_T"x (%"SC_FORMAT_LEN_SIZE_T"u)", len, out_ptr, &count, count[0], count[1], size, size); out = out_ptr = malloc(size); if (out == NULL) { @@ -564,7 +568,9 @@ 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,"returning cached value idx=%d count=%d",idx, count); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "returning cached value idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u", + idx, count); if (idx > priv->cache_buf_len) { SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_END_REACHED); } @@ -573,7 +579,9 @@ 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,"clearing cache idx=%d count=%d",idx, count); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "clearing cache idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u", + idx, count); if (priv->cache_buf) { free(priv->cache_buf); priv->cache_buf = NULL; @@ -641,7 +649,9 @@ 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," obj= cert_file, val_len=%d (0x%04x)", val_len, val_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + " 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; cert_ptr = NULL; cert_type = 0; @@ -805,7 +815,8 @@ static int cac_get_challenge(sc_card_t *card, u8 *rnd, size_t len) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"challenge len=%d",len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "challenge len=%"SC_FORMAT_LEN_SIZE_T"u", len); r = sc_lock(card); if (r != SC_SUCCESS) @@ -841,9 +852,11 @@ 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,"flags=%08x op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%d\n", - env->flags, env->operation, env->algorithm, env->algorithm_flags, - env->algorithm_ref, env->key_ref[0], env->key_ref_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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], + env->key_ref_len); if (env->algorithm != SC_ALGORITHM_RSA) { r = SC_ERROR_NO_CARD_SUPPORT; @@ -871,7 +884,9 @@ 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,"datalen=%d outlen=%d\n", datalen, outlen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "datalen=%"SC_FORMAT_LEN_SIZE_T"u outlen=%"SC_FORMAT_LEN_SIZE_T"u\n", + datalen, outlen); outp = out; outplen = outlen; @@ -979,11 +994,14 @@ static int cac_select_file_by_type(sc_card_t *card, const sc_path_t *in_path, sc pathlen = in_path->len; pathtype = in_path->type; - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"path->aid=%x %x %x %x %x %x %x len=%d, path->value = %x %x %x %x len=%d path->type=%d (%x)", - in_path->aid.value[0], in_path->aid.value[1], in_path->aid.value[2], in_path->aid.value[3], - in_path->aid.value[4], in_path->aid.value[5], in_path->aid.value[6], in_path->aid.len, - in_path->value[0], in_path->value[1], in_path->value[2], in_path->value[3], in_path->len, - in_path->type, in_path->type); + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, + "path->aid=%x %x %x %x %x %x %x len=%"SC_FORMAT_LEN_SIZE_T"u, path->value = %x %x %x %x len=%"SC_FORMAT_LEN_SIZE_T"u path->type=%d (%x)", + in_path->aid.value[0], in_path->aid.value[1], + in_path->aid.value[2], in_path->aid.value[3], + in_path->aid.value[4], in_path->aid.value[5], + in_path->aid.value[6], in_path->aid.len, in_path->value[0], + in_path->value[1], in_path->value[2], in_path->value[3], + in_path->len, in_path->type, in_path->type); sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "file_out=%p index=%d count=%d\n", file_out, in_path->index, in_path->count); @@ -1135,14 +1153,18 @@ static int cac_path_from_cardurl(sc_card_t *card, sc_path_t *path, cac_card_url_ memcpy(path->value, &val->objectID, sizeof(val->objectID)); path->len = sizeof(val->objectID); path->type = SC_PATH_TYPE_FILE_ID; - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"path->aid=%x %x %x %x %x %x %x len=%d, path->value = %x %x len=%d path->type=%d (%x)", - path->aid.value[0], path->aid.value[1], path->aid.value[2], path->aid.value[3], - path->aid.value[4], path->aid.value[5], path->aid.value[6], - path->aid.len, path->value[0], path->value[1], path->len, path->type, path->type); - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"rid=%x %x %x %x %x len=%d appid= %x %x len=%d objid= %x %x len=%d", - val->rid[0], val->rid[1], val->rid[2], val->rid[3], val->rid[4], sizeof(val->rid), - val->applicationID[0], val->applicationID[1], sizeof(val->applicationID), - val->objectID[0], val->objectID[1], sizeof(val->objectID)); + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, + "path->aid=%x %x %x %x %x %x %x len=%"SC_FORMAT_LEN_SIZE_T"u, path->value = %x %x len=%"SC_FORMAT_LEN_SIZE_T"u path->type=%d (%x)", + path->aid.value[0], path->aid.value[1], path->aid.value[2], + path->aid.value[3], path->aid.value[4], path->aid.value[5], + path->aid.value[6], path->aid.len, path->value[0], + path->value[1], path->len, path->type, path->type); + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, + "rid=%x %x %x %x %x len=%"SC_FORMAT_LEN_SIZE_T"u appid= %x %x len=%"SC_FORMAT_LEN_SIZE_T"u objid= %x %x len=%"SC_FORMAT_LEN_SIZE_T"u", + val->rid[0], val->rid[1], val->rid[2], val->rid[3], + val->rid[4], sizeof(val->rid), val->applicationID[0], + val->applicationID[1], sizeof(val->applicationID), + val->objectID[0], val->objectID[1], sizeof(val->objectID)); return SC_SUCCESS; } @@ -1205,7 +1227,10 @@ static int cac_parse_cuid(sc_card_t *card, cac_private_data_t *priv, cac_cuid_t sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "manufacture id=%x", val->manufacturer_id); sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "cac_type=%d", val->card_type); card_id_len = len - (&val->card_id - (u8 *)val); - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "card_id=%s (%d)",sc_dump_hex(&val->card_id, card_id_len),card_id_len); + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, + "card_id=%s (%"SC_FORMAT_LEN_SIZE_T"u)", + sc_dump_hex(&val->card_id, card_id_len), + card_id_len); priv->cuid = *val; priv->cac_id = malloc(card_id_len); if (priv->cac_id == NULL) { diff --git a/src/libopensc/card-cardos.c b/src/libopensc/card-cardos.c index 0c14b32e..e3ac1bfc 100644 --- a/src/libopensc/card-cardos.c +++ b/src/libopensc/card-cardos.c @@ -1211,8 +1211,12 @@ cardos_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data, data->pin_reference |= 0x80; sc_log(ctx, "PIN_CMD(cmd:%i, ref:%i)", data->cmd, data->pin_reference); - sc_log(ctx, "PIN1(max:%i, min:%i)", data->pin1.max_length, data->pin1.min_length); - sc_log(ctx, "PIN2(max:%i, min:%i)", data->pin2.max_length, data->pin2.min_length); + sc_log(ctx, + "PIN1(max:%"SC_FORMAT_LEN_SIZE_T"u, min:%"SC_FORMAT_LEN_SIZE_T"u)", + data->pin1.max_length, data->pin1.min_length); + sc_log(ctx, + "PIN2(max:%"SC_FORMAT_LEN_SIZE_T"u, min:%"SC_FORMAT_LEN_SIZE_T"u)", + data->pin2.max_length, data->pin2.min_length); /* FIXME: the following values depend on what pin length was * used when creating the BS objects */ diff --git a/src/libopensc/card-coolkey.c b/src/libopensc/card-coolkey.c index c44febe6..816c86e2 100644 --- a/src/libopensc/card-coolkey.c +++ b/src/libopensc/card-coolkey.c @@ -931,8 +931,10 @@ 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, "%02x %02x %02x %d : %d %d\n", - ins, p1, p2, sendbuflen , card->max_send_size, card->max_recv_size); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "%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); rbuf = rbufinitbuf; rbuflen = sizeof(rbufinitbuf); @@ -994,14 +996,16 @@ 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,"calling sc_transmit_apdu flags=%x le=%d, resplen=%d, resp=%p", - apdu.flags, apdu.le, apdu.resplen, apdu.resp); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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,"result r=%d apdu.resplen=%d sw1=%02x sw2=%02x", - r, apdu.resplen, apdu.sw1, apdu.sw2); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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"); @@ -1198,13 +1202,17 @@ 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,"returning cached value idx=%d count=%d",idx, count); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "returning cached value idx=%u count=%"SC_FORMAT_LEN_SIZE_T"u", + idx, count); len = MIN(count, priv->obj->length-idx); memcpy(buf, &priv->obj->data[idx], len); SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, len); } - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"clearing cache idx=%d count=%d",idx, count); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "clearing cache idx=%u count=%"SC_FORMAT_LEN_SIZE_T"u", + idx, count); data = malloc(priv->obj->length); if (data == NULL) { @@ -1603,7 +1611,8 @@ static int coolkey_get_challenge(sc_card_t *card, u8 *rnd, size_t len) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"challenge len=%d",len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "challenge len=%"SC_FORMAT_LEN_SIZE_T"u", len); r = sc_lock(card); if (r != SC_SUCCESS) @@ -1640,9 +1649,11 @@ 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,"flags=%08x op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%d\n", - env->flags, env->operation, env->algorithm, env->algorithm_flags, - env->algorithm_ref, env->key_ref[0], env->key_ref_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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], + env->key_ref_len); if ((env->algorithm != SC_ALGORITHM_RSA) && (env->algorithm != SC_ALGORITHM_EC)) { r = SC_ERROR_NO_CARD_SUPPORT; @@ -1697,7 +1708,9 @@ 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,"datalen=%d outlen=%d\n", datalen, max_out_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "datalen=%"SC_FORMAT_LEN_SIZE_T"u outlen=%"SC_FORMAT_LEN_SIZE_T"u\n", + datalen, max_out_len); crypt_in = data; crypt_in_len = datalen; @@ -1798,7 +1811,9 @@ 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,"datalen=%d outlen=%d\n", datalen, outlen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "datalen=%"SC_FORMAT_LEN_SIZE_T"u outlen=%"SC_FORMAT_LEN_SIZE_T"u\n", + datalen, outlen); crypt_in = data; crypt_in_len = datalen; diff --git a/src/libopensc/card-dnie.c b/src/libopensc/card-dnie.c index dbbefaba..6e790ef9 100644 --- a/src/libopensc/card-dnie.c +++ b/src/libopensc/card-dnie.c @@ -964,7 +964,8 @@ static u8 *dnie_uncompress(sc_card_t * card, u8 * from, size_t *len) *len = uncompressed; sc_log(card->ctx, "Compressed data:\n%s\n", sc_dump_hex(from + 8, compressed)); - sc_log(card->ctx, "Uncompress() done. Before:'%lu' After: '%lu'", + sc_log(card->ctx, + "Uncompress() done. Before:'%"SC_FORMAT_LEN_SIZE_T"u' After: '%"SC_FORMAT_LEN_SIZE_T"u'", compressed, uncompressed); sc_log(card->ctx, "Uncompressed data:\n%s\n", sc_dump_hex(upt, uncompressed)); @@ -1091,7 +1092,9 @@ static int dnie_fill_cache(sc_card_t * card) /* ok: as final step, set correct cache data into dnie_priv structures */ GET_DNIE_PRIV_DATA(card)->cache = pt; GET_DNIE_PRIV_DATA(card)->cachelen = len; - sc_log(ctx, "fill_cache() done. length '%d' bytes", len); + sc_log(ctx, + "fill_cache() done. length '%"SC_FORMAT_LEN_SIZE_T"u' bytes", + len); LOG_FUNC_RETURN(ctx,len); } @@ -1684,7 +1687,7 @@ static int dnie_compute_signature(struct sc_card *card, data and feed them into sign() command */ sc_log(card->ctx, - "Compute signature len: '%d' bytes:\n%s\n============================================================", + "Compute signature len: '%"SC_FORMAT_LEN_SIZE_T"u' bytes:\n%s\n============================================================", datalen, sc_dump_hex(data, datalen)); /*INS: 0x2A PERFORM SECURITY OPERATION diff --git a/src/libopensc/card-entersafe.c b/src/libopensc/card-entersafe.c index 7aecf1a7..53501296 100644 --- a/src/libopensc/card-entersafe.c +++ b/src/libopensc/card-entersafe.c @@ -685,13 +685,14 @@ static int entersafe_select_file(sc_card_t *card, r = sc_path_print(pbuf, sizeof(pbuf), &card->cache.current_path); if (r != SC_SUCCESS) pbuf[0] = '\0'; - + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "current path (%s, %s): %s (len: %u)\n", - (card->cache.current_path.type==SC_PATH_TYPE_DF_NAME?"aid":"path"), - (card->cache.valid?"valid":"invalid"), pbuf, + "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", + card->cache.valid ? "valid" : "invalid", pbuf, card->cache.current_path.len); - + switch(in_path->type) { case SC_PATH_TYPE_FILE_ID: diff --git a/src/libopensc/card-epass2003.c b/src/libopensc/card-epass2003.c index 2a0a7ffb..84ab6456 100644 --- a/src/libopensc/card-epass2003.c +++ b/src/libopensc/card-epass2003.c @@ -978,7 +978,9 @@ epass2003_sm_unwrap_apdu(struct sc_card *card, struct sc_apdu *sm, struct sc_apd plain->sw1 = sm->sw1; plain->sw2 = sm->sw2; - sc_log(card->ctx, "unwrapped APDU: resplen %i, SW %02X%02X", plain->resplen, plain->sw1, plain->sw2); + sc_log(card->ctx, + "unwrapped APDU: resplen %"SC_FORMAT_LEN_SIZE_T"u, SW %02X%02X", + plain->resplen, plain->sw1, plain->sw2); LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } @@ -1529,9 +1531,12 @@ epass2003_select_file(struct sc_card *card, const sc_path_t * in_path, if (r != SC_SUCCESS) pbuf[0] = '\0'; - sc_log(card->ctx, "current path (%s, %s): %s (len: %u)\n", - (card->cache.current_path.type == SC_PATH_TYPE_DF_NAME ? "aid" : "path"), - (card->cache.valid ? "valid" : "invalid"), pbuf, card->cache.current_path.len); + 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", + card->cache.valid ? "valid" : "invalid", pbuf, + card->cache.current_path.len); switch (in_path->type) { case SC_PATH_TYPE_FILE_ID: @@ -1697,7 +1702,8 @@ epass2003_process_fci(struct sc_card *card, sc_file_t * file, const u8 * buf, si file->size = tag[0]; if (taglen == 2) file->size = (file->size << 8) + tag[1]; - sc_log(ctx, " bytes in file: %d", file->size); + sc_log(ctx, " bytes in file: %"SC_FORMAT_LEN_SIZE_T"u", + file->size); } if (tag == NULL) { diff --git a/src/libopensc/card-flex.c b/src/libopensc/card-flex.c index 864cc24d..1dd27694 100644 --- a/src/libopensc/card-flex.c +++ b/src/libopensc/card-flex.c @@ -641,7 +641,9 @@ 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, "expected 4 bytes, got %d.\n", apdu.resplen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "expected 4 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n", + apdu.resplen); return SC_ERROR_UNKNOWN_DATA_RECEIVED; } memcpy(buf, rbuf + 2, 2); @@ -676,7 +678,9 @@ 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, "expected 6 bytes, got %d.\n", apdu.resplen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "expected 6 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n", + apdu.resplen); return SC_ERROR_UNKNOWN_DATA_RECEIVED; } memcpy(buf, rbuf + 4, 2); @@ -845,7 +849,8 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file, break; } - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Creating %02x:%02x, size %d %02x:%02x\n", + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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, size, @@ -983,7 +988,9 @@ 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, "Illegal input length: %d\n", data_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "Illegal input length: %"SC_FORMAT_LEN_SIZE_T"u\n", + data_len); return SC_ERROR_INVALID_ARGUMENTS; } if (outlen < data_len) { @@ -1042,7 +1049,9 @@ 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, "Illegal input length: %d\n", data_len); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "Illegal input length: %"SC_FORMAT_LEN_SIZE_T"u\n", + data_len); return SC_ERROR_INVALID_ARGUMENTS; } key_id = prv->rsa_key_ref + 1; /* Why? */ diff --git a/src/libopensc/card-gemsafeV1.c b/src/libopensc/card-gemsafeV1.c index 4792e96b..3ce7a5ea 100644 --- a/src/libopensc/card-gemsafeV1.c +++ b/src/libopensc/card-gemsafeV1.c @@ -462,7 +462,9 @@ 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, "error: input data too long: %lu bytes\n", data_len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "error: input data too long: %"SC_FORMAT_LEN_SIZE_T"u bytes\n", + data_len); return SC_ERROR_INVALID_ARGUMENTS; } diff --git a/src/libopensc/card-gids.c b/src/libopensc/card-gids.c index 51db9afb..2cf15182 100644 --- a/src/libopensc/card-gids.c +++ b/src/libopensc/card-gids.c @@ -214,8 +214,9 @@ static int gids_get_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdenti SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%x, responselen=%d\n", - fileIdentifier, dataObjectIdentifier, response, responselen ? *responselen : 0); + "Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n", + fileIdentifier, dataObjectIdentifier, response, + responselen ? *responselen : 0); sc_format_apdu(card, &apdu, response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_GET_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF)); @@ -250,8 +251,8 @@ static int gids_put_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdenti u8* p = buffer; SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Got args: fileIdentifier=%x, dataObjectIdentifier=%x, data=%x, datalen=%d\n", - fileIdentifier, dataObjectIdentifier, data, datalen); + "Got args: fileIdentifier=%x, dataObjectIdentifier=%x, data=%p, datalen=%"SC_FORMAT_LEN_SIZE_T"u\n", + fileIdentifier, dataObjectIdentifier, data, datalen); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, INS_PUT_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF)); @@ -278,8 +279,8 @@ static int gids_select_aid(sc_card_t* card, u8* aid, size_t aidlen, u8* response SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Got args: aid=%x, aidlen=%d, response=%x, responselen=%d\n", - aid, aidlen, response, responselen ? *responselen : 0); + "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); sc_format_apdu(card, &apdu, response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_SELECT, P1_SELECT_DF_BY_NAME, P2_SELECT_FIRST_OR_ONLY_OCCURENCE); @@ -851,8 +852,8 @@ static int gids_read_public_key (struct sc_card *card , unsigned int algorithm, SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Got args: key_reference=%x, response=%x, responselen=%d\n", - key_reference, response, responselen ? *responselen : 0); + "Got args: key_reference=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n", + key_reference, response, responselen ? *responselen : 0); sc_format_apdu(card, &apdu, response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_GET_DATA, 0x3F, 0xFF); @@ -998,7 +999,9 @@ static int gids_read_binary(sc_card_t *card, unsigned int offset, SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r); } if (data->buffersize != expectedsize) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "expected size: %d real size: %d", expectedsize, data->buffersize); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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 { @@ -1115,7 +1118,9 @@ gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t* key_info) { SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); } if (i > recordsnum) { - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "container num is not allowed %d %d", i, recordsnum); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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); } } @@ -1254,7 +1259,9 @@ static int gids_create_keyfile(sc_card_t *card, sc_pkcs15_object_t *object) { 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 , "keymaprecordnum = %u recordnum = %u", (unsigned long) keymaprecordnum, (unsigned long) recordnum); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL , + "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); } } diff --git a/src/libopensc/card-gpk.c b/src/libopensc/card-gpk.c index 1e6dcea2..86bfebd8 100644 --- a/src/libopensc/card-gpk.c +++ b/src/libopensc/card-gpk.c @@ -1235,8 +1235,8 @@ gpk_compute_signature(sc_card_t *card, const u8 *data, if (data_len > priv->sec_mod_len) { sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Data length (%u) does not match key modulus %u.\n", - data_len, priv->sec_mod_len); + "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; } if (sizeof(cardsig) < priv->sec_mod_len) @@ -1289,8 +1289,8 @@ gpk_decipher(sc_card_t *card, const u8 *in, size_t inlen, if (inlen != priv->sec_mod_len) { sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Data length (%u) does not match key modulus %u.\n", - inlen, priv->sec_mod_len); + "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; } diff --git a/src/libopensc/card-iasecc.c b/src/libopensc/card-iasecc.c index 579c7b24..9b97c18f 100644 --- a/src/libopensc/card-iasecc.c +++ b/src/libopensc/card-iasecc.c @@ -394,7 +394,9 @@ static int iasecc_parse_ef_atr(struct sc_card *card) if (card->max_send_size > 0xFF) card->max_send_size -= 5; - sc_log(ctx, "EF.ATR: max send/recv sizes %X/%X", card->max_send_size, card->max_recv_size); + sc_log(ctx, + "EF.ATR: max send/recv sizes %"SC_FORMAT_LEN_SIZE_T"X/%"SC_FORMAT_LEN_SIZE_T"X", + card->max_send_size, card->max_recv_size); LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -686,7 +688,9 @@ iasecc_read_binary(struct sc_card *card, unsigned int offs, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "iasecc_read_binary(card:%p) offs %i; count %i", card, offs, count); + sc_log(ctx, + "iasecc_read_binary(card:%p) offs %i; count %"SC_FORMAT_LEN_SIZE_T"u", + card, offs, count); if (offs > 0x7fff) { sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", offs); return SC_ERROR_OFFSET_TOO_LARGE; @@ -701,7 +705,9 @@ iasecc_read_binary(struct sc_card *card, unsigned int offs, LOG_TEST_RET(ctx, rv, "APDU transmit failed"); rv = sc_check_sw(card, apdu.sw1, apdu.sw2); LOG_TEST_RET(ctx, rv, "iasecc_read_binary() failed"); - sc_log(ctx, "iasecc_read_binary() apdu.resplen %i", apdu.resplen); + sc_log(ctx, + "iasecc_read_binary() apdu.resplen %"SC_FORMAT_LEN_SIZE_T"u", + apdu.resplen); if (apdu.resplen == IASECC_READ_BINARY_LENGTH_MAX && apdu.resplen < count) { rv = iasecc_read_binary(card, offs + apdu.resplen, buf + apdu.resplen, count - apdu.resplen, flags); @@ -723,7 +729,9 @@ iasecc_erase_binary(struct sc_card *card, unsigned int offs, size_t count, unsig int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "iasecc_erase_binary(card:%p) count %i", card, count); + sc_log(ctx, + "iasecc_erase_binary(card:%p) count %"SC_FORMAT_LEN_SIZE_T"u", + card, count); if (!count) LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "'ERASE BINARY' failed: invalid size to erase"); @@ -749,7 +757,9 @@ _iasecc_sm_read_binary(struct sc_card *card, unsigned int offs, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "iasecc_sm_read_binary() card:%p offs:%i count:%i ", card, offs, count); + sc_log(ctx, + "iasecc_sm_read_binary() card:%p offs:%i count:%"SC_FORMAT_LEN_SIZE_T"u ", + card, offs, count); if (offs > 0x7fff) LOG_TEST_RET(ctx, SC_ERROR_OFFSET_TOO_LARGE, "Invalid arguments"); @@ -788,7 +798,9 @@ _iasecc_sm_update_binary(struct sc_card *card, unsigned int offs, return SC_SUCCESS; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "iasecc_sm_read_binary() card:%p offs:%i count:%i ", card, offs, count); + sc_log(ctx, + "iasecc_sm_read_binary() card:%p offs:%i count:%"SC_FORMAT_LEN_SIZE_T"u ", + card, offs, count); sc_print_cache(card); if (card->cache.valid && card->cache.current_ef) { @@ -857,8 +869,9 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path, if (file_out) *file_out = NULL; - sc_log(ctx, "iasecc_select_file(card:%p) path.len %i; path.type %i; aid_len %i", - card, path->len, path->type, path->aid.len); + sc_log(ctx, + "iasecc_select_file(card:%p) path.len %"SC_FORMAT_LEN_SIZE_T"u; path.type %i; aid_len %"SC_FORMAT_LEN_SIZE_T"u", + card, path->len, path->type, path->aid.len); sc_log(ctx, "iasecc_select_file() path:%s", sc_print_path(path)); sc_print_cache(card); @@ -878,7 +891,9 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path, struct sc_file *file = NULL; struct sc_path ppath; - sc_log(ctx, "iasecc_select_file() select parent AID:%p/%i", lpath.aid.value, lpath.aid.len); + sc_log(ctx, + "iasecc_select_file() select parent AID:%p/%"SC_FORMAT_LEN_SIZE_T"u", + lpath.aid.value, lpath.aid.len); sc_log(ctx, "iasecc_select_file() select parent AID:%s", sc_dump_hex(lpath.aid.value, lpath.aid.len)); memset(&ppath, 0, sizeof(ppath)); memcpy(ppath.value, lpath.aid.value, lpath.aid.len); @@ -1019,7 +1034,9 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path, LOG_TEST_RET(ctx, rv, "iasecc_select_file() check SW failed"); - sc_log(ctx, "iasecc_select_file() apdu.resp %i", apdu.resplen); + sc_log(ctx, + "iasecc_select_file() apdu.resp %"SC_FORMAT_LEN_SIZE_T"u", + apdu.resplen); if (apdu.resplen) { sc_log(ctx, "apdu.resp %02X:%02X:%02X...", apdu.resp[0], apdu.resp[1], apdu.resp[2]); @@ -1107,7 +1124,7 @@ iasecc_process_fci(struct sc_card *card, struct sc_file *file, tag = sc_asn1_find_tag(ctx, buf, buflen, 0x6F, &taglen); sc_log(ctx, "processing FCI: 0x6F tag %p", tag); if (tag != NULL) { - sc_log(ctx, " FCP length %i", taglen); + sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen); buf = tag; buflen = taglen; } @@ -1115,7 +1132,7 @@ iasecc_process_fci(struct sc_card *card, struct sc_file *file, tag = sc_asn1_find_tag(ctx, buf, buflen, 0x62, &taglen); sc_log(ctx, "processing FCI: 0x62 tag %p", tag); if (tag != NULL) { - sc_log(ctx, " FCP length %i", taglen); + sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen); buf = tag; buflen = taglen; } @@ -1136,11 +1153,14 @@ iasecc_process_fci(struct sc_card *card, struct sc_file *file, acls = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen); if (!acls) { - sc_log(ctx, "ACLs not found in data(%i) %s", buflen, sc_dump_hex(buf, buflen)); + sc_log(ctx, + "ACLs not found in data(%"SC_FORMAT_LEN_SIZE_T"u) %s", + buflen, sc_dump_hex(buf, buflen)); LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing"); } - sc_log(ctx, "ACLs(%i) '%s'", taglen, sc_dump_hex(acls, taglen)); + sc_log(ctx, "ACLs(%"SC_FORMAT_LEN_SIZE_T"u) '%s'", taglen, + sc_dump_hex(acls, taglen)); mask = 0x40, offs = 1; for (ii = 0; ii < 7; ii++, mask /= 2) { unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii]; @@ -1239,7 +1259,9 @@ iasecc_fcp_encode(struct sc_card *card, struct sc_file *file, unsigned char *out LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported AC method"); amb |= mask; - sc_log(ctx, "%i: AMB %X; nn_smb %i", ii, amb, nn_smb); + sc_log(ctx, + "%"SC_FORMAT_LEN_SIZE_T"u: AMB %"SC_FORMAT_LEN_SIZE_T"X; nn_smb %"SC_FORMAT_LEN_SIZE_T"u", + ii, amb, nn_smb); } /* TODO: Encode contactless ACLs and life cycle status for all IAS/ECC cards */ @@ -1650,7 +1672,7 @@ iasecc_set_security_env(struct sc_card *card, /* To made by iasecc_sdo_convert_to_file() */ prv->key_size = *(sdo.docp.size.value + 0) * 0x100 + *(sdo.docp.size.value + 1); - sc_log(ctx, "prv->key_size 0x%X", prv->key_size); + sc_log(ctx, "prv->key_size 0x%"SC_FORMAT_LEN_SIZE_T"X", prv->key_size); rv = iasecc_sdo_convert_acl(card, &sdo, SC_AC_OP_PSO_COMPUTE_SIGNATURE, &sign_meth, &sign_ref); LOG_TEST_RET(ctx, rv, "Cannot convert SC_AC_OP_SIGN acl"); @@ -1686,8 +1708,10 @@ iasecc_set_security_env(struct sc_card *card, } sc_log(ctx, "senv.algorithm 0x%X, senv.algorithm_ref 0x%X", env->algorithm, env->algorithm_ref); - sc_log(ctx, "se_num %i, operation 0x%X, algorithm 0x%X, algorithm_ref 0x%X, flags 0x%X; key size %i", - se_num, operation, env->algorithm, env->algorithm_ref, env->algorithm_flags, prv->key_size); + sc_log(ctx, + "se_num %i, operation 0x%X, algorithm 0x%X, algorithm_ref 0x%X, flags 0x%X; key size %"SC_FORMAT_LEN_SIZE_T"u", + se_num, operation, env->algorithm, env->algorithm_ref, + env->algorithm_flags, prv->key_size); switch (operation) { case SC_SEC_OPERATION_SIGN: if (!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1)) @@ -1955,7 +1979,9 @@ iasecc_pin_verify(struct sc_card *card, unsigned type, unsigned reference, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "Verify PIN(type:%X,ref:%i,data(len:%i,%p)", type, reference, data_len, data); + sc_log(ctx, + "Verify PIN(type:%X,ref:%i,data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p)", + type, reference, data_len, data); if (type == SC_AC_AUT) { rv = iasecc_sm_external_authentication(card, reference, tries_left); @@ -2053,8 +2079,14 @@ iasecc_chv_change_pinpad(struct sc_card *card, unsigned reference, int *tries_le memcpy(&pin_cmd.pin2, &pin_cmd.pin1, sizeof(pin_cmd.pin1)); pin_cmd.pin2.data = pin2_data; - sc_log(ctx, "PIN1 max/min/stored: %i/%i/%i", pin_cmd.pin1.max_length, pin_cmd.pin1.min_length, pin_cmd.pin1.stored_length); - sc_log(ctx, "PIN2 max/min/stored: %i/%i/%i", pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, pin_cmd.pin2.stored_length); + sc_log(ctx, + "PIN1 max/min/stored: %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + pin_cmd.pin1.max_length, pin_cmd.pin1.min_length, + pin_cmd.pin1.stored_length); + sc_log(ctx, + "PIN2 max/min/stored: %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, + pin_cmd.pin2.stored_length); rv = iso_ops->pin_cmd(card, &pin_cmd, tries_left); LOG_FUNC_RETURN(ctx, rv); @@ -2160,7 +2192,9 @@ iasecc_pin_get_policy (struct sc_card *card, struct sc_pin_cmd_data *data) if (sdo.docp.acls_contact.size == 0) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Extremely strange ... there is no ACLs"); - sc_log(ctx, "iasecc_pin_get_policy() sdo.docp.size.size %i", sdo.docp.size.size); + sc_log(ctx, + "iasecc_pin_get_policy() sdo.docp.size.size %"SC_FORMAT_LEN_SIZE_T"u", + sdo.docp.size.size); for (ii=0; iipin1.offset = 5; data->pin1.logged_in = SC_PIN_STATE_UNKNOWN; - sc_log(ctx, "PIN policy: size max/min %i/%i, tries max/left %i/%i", - data->pin1.max_length, data->pin1.min_length, - data->pin1.max_tries, data->pin1.tries_left); + sc_log(ctx, + "PIN policy: size max/min %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u, tries max/left %i/%i", + data->pin1.max_length, data->pin1.min_length, + data->pin1.max_tries, data->pin1.tries_left); iasecc_sdo_free_fields(card, &sdo); if (save_current_df) { @@ -3029,7 +3064,9 @@ iasecc_decipher(struct sc_card *card, int rv; LOG_FUNC_CALLED(ctx); - sc_log(card->ctx, "crgram_len %i; outlen %i", in_len, out_len); + sc_log(card->ctx, + "crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u", + in_len, out_len); if (!out || !out_len || in_len > SC_MAX_APDU_BUFFER_SIZE) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); @@ -3078,7 +3115,9 @@ iasecc_qsign_data_sha1(struct sc_context *ctx, const unsigned char *in, size_t i if (!in || !in_len || !out) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "sc_pkcs15_get_qsign_data() input data length %i", in_len); + sc_log(ctx, + "sc_pkcs15_get_qsign_data() input data length %"SC_FORMAT_LEN_SIZE_T"u", + in_len); memset(out, 0, sizeof(struct iasecc_qsign_data)); SHA1_Init(&sha); @@ -3102,7 +3141,9 @@ iasecc_qsign_data_sha1(struct sc_context *ctx, const unsigned char *in, size_t i if (sha.num) { memcpy(out->last_block, in + in_len - sha.num, sha.num); out->last_block_size = sha.num; - sc_log(ctx, "Last block(%i):%s", out->last_block_size, sc_dump_hex(out->last_block, out->last_block_size)); + sc_log(ctx, "Last block(%"SC_FORMAT_LEN_SIZE_T"u):%s", + out->last_block_size, + sc_dump_hex(out->last_block, out->last_block_size)); } SHA1_Final(out->hash, &sha); @@ -3127,7 +3168,9 @@ iasecc_qsign_data_sha256(struct sc_context *ctx, const unsigned char *in, size_t if (!in || !in_len || !out) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "sc_pkcs15_get_qsign_data() input data length %i", in_len); + sc_log(ctx, + "sc_pkcs15_get_qsign_data() input data length %"SC_FORMAT_LEN_SIZE_T"u", + in_len); memset(out, 0, sizeof(struct iasecc_qsign_data)); SHA256_Init(&sha256); @@ -3151,7 +3194,9 @@ iasecc_qsign_data_sha256(struct sc_context *ctx, const unsigned char *in, size_t if (sha256.num) { memcpy(out->last_block, in + in_len - sha256.num, sha256.num); out->last_block_size = sha256.num; - sc_log(ctx, "Last block(%i):%s", out->last_block_size, sc_dump_hex(out->last_block, out->last_block_size)); + sc_log(ctx, "Last block(%"SC_FORMAT_LEN_SIZE_T"u):%s", + out->last_block_size, + sc_dump_hex(out->last_block, out->last_block_size)); } SHA256_Final(out->hash, &sha256); @@ -3178,7 +3223,9 @@ iasecc_compute_signature_dst(struct sc_card *card, int rv = SC_SUCCESS; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "iasecc_compute_signature_dst() input length %i", in_len); + sc_log(ctx, + "iasecc_compute_signature_dst() input length %"SC_FORMAT_LEN_SIZE_T"u", + in_len); if (env->operation != SC_SEC_OPERATION_SIGN) LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "It's not SC_SEC_OPERATION_SIGN"); else if (!(prv->key_size & 0x1E0) || (prv->key_size & ~0x1E0)) @@ -3199,7 +3246,9 @@ iasecc_compute_signature_dst(struct sc_card *card, LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Need RSA_HASH_SHA1 or RSA_HASH_SHA256 algorithm"); LOG_TEST_RET(ctx, rv, "Cannot get QSign data"); - sc_log(ctx, "iasecc_compute_signature_dst() hash_len %i; key_size %i", hash_len, prv->key_size); + sc_log(ctx, + "iasecc_compute_signature_dst() hash_len %"SC_FORMAT_LEN_SIZE_T"u; key_size %"SC_FORMAT_LEN_SIZE_T"u", + hash_len, prv->key_size); memset(sbuf, 0, sizeof(sbuf)); sbuf[offs++] = 0x90; @@ -3219,7 +3268,9 @@ iasecc_compute_signature_dst(struct sc_card *card, memcpy(sbuf + offs, qsign_data.last_block, qsign_data.last_block_size); offs += qsign_data.last_block_size; - sc_log(ctx, "iasecc_compute_signature_dst() offs %i; OP(meth:%X,ref:%X)", offs, prv->op_method, prv->op_ref); + sc_log(ctx, + "iasecc_compute_signature_dst() offs %"SC_FORMAT_LEN_SIZE_T"u; OP(meth:%X,ref:%X)", + offs, prv->op_method, prv->op_ref); if (prv->op_method == SC_AC_SCB && (prv->op_ref & IASECC_SCB_METHOD_SM)) LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Not yet"); @@ -3245,7 +3296,9 @@ iasecc_compute_signature_dst(struct sc_card *card, rv = sc_check_sw(card, apdu.sw1, apdu.sw2); LOG_TEST_RET(ctx, rv, "Compute signature failed"); - sc_log(ctx, "iasecc_compute_signature_dst() DST resplen %i", apdu.resplen); + sc_log(ctx, + "iasecc_compute_signature_dst() DST resplen %"SC_FORMAT_LEN_SIZE_T"u", + apdu.resplen); if (apdu.resplen > out_len) LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Result buffer too small for the DST signature"); @@ -3327,7 +3380,9 @@ iasecc_compute_signature(struct sc_card *card, env = &prv->security_env; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "inlen %i, outlen %i", in_len, out_len); + sc_log(ctx, + "inlen %"SC_FORMAT_LEN_SIZE_T"u, outlen %"SC_FORMAT_LEN_SIZE_T"u", + in_len, out_len); if (env->operation == SC_SEC_OPERATION_SIGN) return iasecc_compute_signature_dst(card, in, in_len, out, out_len); @@ -3436,10 +3491,14 @@ iasecc_get_free_reference(struct sc_card *card, struct iasecc_ctl_get_free_refer LOG_TEST_RET(ctx, rv, "get new key reference failed"); sz = *(sdo->docp.size.value + 0) * 0x100 + *(sdo->docp.size.value + 1); - sc_log(ctx, "SDO(idx:%i) size %i; key_size %i", idx, sz, ctl_data->key_size); + sc_log(ctx, + "SDO(idx:%i) size %"SC_FORMAT_LEN_SIZE_T"u; key_size %"SC_FORMAT_LEN_SIZE_T"u", + idx, sz, ctl_data->key_size); if (sz != ctl_data->key_size / 8) { - sc_log(ctx, "key index %i ignored: different key sizes %i/%i", idx, sz, ctl_data->key_size / 8); + sc_log(ctx, + "key index %i ignored: different key sizes %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + idx, sz, ctl_data->key_size / 8); continue; } diff --git a/src/libopensc/card-jpki.c b/src/libopensc/card-jpki.c index 288c5fad..069470fa 100644 --- a/src/libopensc/card-jpki.c +++ b/src/libopensc/card-jpki.c @@ -145,8 +145,9 @@ jpki_select_file(struct sc_card *card, struct sc_file *file = NULL; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "jpki_select_file: path=%s, len=%d", - sc_print_path(path), path->len); + sc_log(card->ctx, + "jpki_select_file: path=%s, len=%"SC_FORMAT_LEN_SIZE_T"u", + sc_print_path(path), path->len); if (path->len == 2 && memcmp(path->value, "\x3F\x00", 2) == 0) { drvdata->selected = SELECT_MF; if (file_out) { @@ -301,10 +302,10 @@ jpki_set_security_env(sc_card_t * card, LOG_FUNC_CALLED(card->ctx); sc_log(card->ctx, - "flags=%08x op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%d", - env->flags, env->operation, env->algorithm, - env->algorithm_flags, env->algorithm_ref, env->key_ref[0], - env->key_ref_len); + "flags=%08lx op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%"SC_FORMAT_LEN_SIZE_T"u", + env->flags, env->operation, env->algorithm, + env->algorithm_flags, env->algorithm_ref, env->key_ref[0], + env->key_ref_len); switch (env->operation) { case SC_SEC_OPERATION_SIGN: diff --git a/src/libopensc/card-mcrd.c b/src/libopensc/card-mcrd.c index f245a105..4186cb04 100644 --- a/src/libopensc/card-mcrd.c +++ b/src/libopensc/card-mcrd.c @@ -1359,7 +1359,7 @@ static int mcrd_compute_signature(sc_card_t * card, SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Will compute signature (%d) for %d (0x%02x) bytes using key %d algorithm %d flags %d\n", + "Will compute signature (%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, datalen, datalen, env->key_ref[0], env->algorithm, env->algorithm_flags); diff --git a/src/libopensc/card-miocos.c b/src/libopensc/card-miocos.c index 16126499..a40451a0 100644 --- a/src/libopensc/card-miocos.c +++ b/src/libopensc/card-miocos.c @@ -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%X not supported\n", cmd); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "card_ctl command 0x%lX not supported\n", cmd); return SC_ERROR_NOT_SUPPORTED; } diff --git a/src/libopensc/card-oberthur.c b/src/libopensc/card-oberthur.c index b4946cf8..86c10e74 100644 --- a/src/libopensc/card-oberthur.c +++ b/src/libopensc/card-oberthur.c @@ -384,7 +384,9 @@ auth_process_fci(struct sc_card *card, struct sc_file *file, else if (file->size==2048) file->size = PUBKEY_2048_ASN1_SIZE; else { - sc_log(card->ctx, "Not supported public key size: %i", file->size); + sc_log(card->ctx, + "Not supported public key size: %"SC_FORMAT_LEN_SIZE_T"u", + file->size); LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); } break; @@ -540,11 +542,12 @@ auth_select_file(struct sc_card *card, const struct sc_path *in_path, path.value[offs + 1] != auth_current_df->path.value[offs + 1]) break; - sc_log(card->ctx, "offs %i", offs); + sc_log(card->ctx, "offs %"SC_FORMAT_LEN_SIZE_T"u", offs); if (offs && offs < auth_current_df->path.len) { size_t deep = auth_current_df->path.len - offs; - sc_log(card->ctx, "deep %i", deep); + sc_log(card->ctx, "deep %"SC_FORMAT_LEN_SIZE_T"u", + deep); for (ii=0; iictx); - sc_log(card->ctx, "id %04X; size %i; type 0x%X/0x%X", - file->id, file->size, file->type, file->ef_structure); + sc_log(card->ctx, + "id %04X; size %"SC_FORMAT_LEN_SIZE_T"u; type 0x%X/0x%X", + file->id, file->size, file->type, file->ef_structure); if (*buflen < 0x18) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS); @@ -825,7 +829,9 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file, else if (file->size == PUBKEY_2048_ASN1_SIZE || file->size == 2048) size = 2048; else { - sc_log(card->ctx, "incorrect RSA size %X", file->size); + sc_log(card->ctx, + "incorrect RSA size %"SC_FORMAT_LEN_SIZE_T"X", + file->size); LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS); } } @@ -838,7 +844,9 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file, else if (file->size == 24 || file->size == 192) size = 192; else { - sc_log(card->ctx, "incorrect DES size %i", file->size); + sc_log(card->ctx, + "incorrect DES size %"SC_FORMAT_LEN_SIZE_T"u", + file->size); LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS); } } @@ -937,8 +945,8 @@ auth_create_file(struct sc_card *card, struct sc_file *file) sc_log(card->ctx, " create path=%s", pbuf); sc_log(card->ctx, - "id %04X; size %i; type 0x%X; ef 0x%X", - file->id, file->size, file->type, file->ef_structure); + "id %04X; size %"SC_FORMAT_LEN_SIZE_T"u; type 0x%X; ef 0x%X", + file->id, file->size, file->type, file->ef_structure); if (file->id==0x0000 || file->id==0xFFFF || file->id==0x3FFF) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); @@ -1015,9 +1023,10 @@ auth_set_security_env(struct sc_card *card, }; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "op %i; path %s; key_ref 0x%X; algos 0x%X; flags 0x%X", - env->operation, sc_print_path(&env->file_ref), env->key_ref[0], - env->algorithm_flags, env->flags); + sc_log(card->ctx, + "op %i; path %s; key_ref 0x%X; algos 0x%X; flags 0x%lX", + env->operation, sc_print_path(&env->file_ref), env->key_ref[0], + env->algorithm_flags, env->flags); memset(auth_senv, 0, sizeof(struct auth_senv)); @@ -1027,8 +1036,9 @@ auth_set_security_env(struct sc_card *card, switch (env->algorithm) { case SC_ALGORITHM_DES: case SC_ALGORITHM_3DES: - sc_log(card->ctx, "algo SC_ALGORITHM_xDES: ref %X, flags %X", - env->algorithm_ref, env->flags); + sc_log(card->ctx, + "algo SC_ALGORITHM_xDES: ref %X, flags %lX", + env->algorithm_ref, env->flags); if (env->operation == SC_SEC_OPERATION_DECIPHER) { sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0xB8); @@ -1049,7 +1059,7 @@ auth_set_security_env(struct sc_card *card, } if (pads & (~supported_pads)) { - sc_log(card->ctx, "No support for PAD %X",pads); + sc_log(card->ctx, "No support for PAD %lX", pads); LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "No padding support."); } @@ -1109,12 +1119,16 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile return SC_ERROR_INVALID_ARGUMENTS; } else if (ilen > 96) { - sc_log(card->ctx, "Illegal input length %d", ilen); + sc_log(card->ctx, + "Illegal input length %"SC_FORMAT_LEN_SIZE_T"u", + ilen); LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Illegal input length"); } LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "inlen %i, outlen %i", ilen, olen); + sc_log(card->ctx, + "inlen %"SC_FORMAT_LEN_SIZE_T"u, outlen %"SC_FORMAT_LEN_SIZE_T"u", + ilen, olen); sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0x9A); apdu.datalen = ilen; @@ -1130,8 +1144,9 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile LOG_TEST_RET(card->ctx, rv, "Compute signature failed"); if (apdu.resplen > olen) { - sc_log(card->ctx, "Compute signature failed: invalide response length %i", - apdu.resplen); + sc_log(card->ctx, + "Compute signature failed: invalid response length %"SC_FORMAT_LEN_SIZE_T"u", + apdu.resplen); LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED); } @@ -1150,7 +1165,9 @@ auth_decipher(struct sc_card *card, const unsigned char *in, size_t inlen, int rv, _inlen = inlen; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx,"crgram_len %i; outlen %i", inlen, outlen); + sc_log(card->ctx, + "crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u", + inlen, outlen); if (!out || !outlen || inlen > SC_MAX_APDU_BUFFER_SIZE) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); @@ -1304,7 +1321,8 @@ auth_generate_key(struct sc_card *card, int use_sm, data->pubkey_len = apdu.resplen; free(apdu.resp); - sc_log(card->ctx, "resulted public key len %i", apdu.resplen); + sc_log(card->ctx, "resulted public key len %"SC_FORMAT_LEN_SIZE_T"u", + apdu.resplen); LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } @@ -1481,7 +1499,8 @@ auth_read_component(struct sc_card *card, enum SC_CARDCTL_OBERTHUR_KEY_TYPE type unsigned char resp[256]; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "num %i, outlen %i, type %i", num, outlen, type); + sc_log(card->ctx, "num %i, outlen %"SC_FORMAT_LEN_SIZE_T"u, type %i", + num, outlen, type); if (!outlen || type!=SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS); @@ -2012,7 +2031,8 @@ write_publickey (struct sc_card *card, unsigned int offset, sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL, buf, count, debug_buf, sizeof(debug_buf)); sc_log(card->ctx, - "write_publickey in %d bytes :\n%s", count, debug_buf); + "write_publickey in %"SC_FORMAT_LEN_SIZE_T"u bytes :\n%s", + count, debug_buf); if (1+offset > sizeof(rsa_der)) LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid offset value"); @@ -2030,7 +2050,7 @@ write_publickey (struct sc_card *card, unsigned int offset, der_size = rsa_der[1]; } - sc_log(card->ctx, "der_size %i",der_size); + sc_log(card->ctx, "der_size %"SC_FORMAT_LEN_SIZE_T"u", der_size); if (offset + len < der_size + 2) LOG_FUNC_RETURN(card->ctx, len); @@ -2066,7 +2086,8 @@ auth_update_binary(struct sc_card *card, unsigned int offset, int rv = 0; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "offset %i; count %i", offset, count); + sc_log(card->ctx, "offset %i; count %"SC_FORMAT_LEN_SIZE_T"u", offset, + count); sc_log(card->ctx, "last selected : magic %X; ef %X", auth_current_ef->magic, auth_current_ef->ef_structure); @@ -2103,7 +2124,9 @@ auth_read_binary(struct sc_card *card, unsigned int offset, char debug_buf[2048]; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx,"offset %i; size %i; flags 0x%lX", offset, count, flags); + sc_log(card->ctx, + "offset %i; size %"SC_FORMAT_LEN_SIZE_T"u; flags 0x%lX", + offset, count, flags); sc_log(card->ctx,"last selected : magic %X; ef %X", auth_current_ef->magic, auth_current_ef->ef_structure); @@ -2153,8 +2176,8 @@ auth_read_binary(struct sc_card *card, unsigned int offset, sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL, buf, rv, debug_buf, sizeof(debug_buf)); sc_log(card->ctx, - "write_publickey in %d bytes :\n%s", - count, debug_buf); + "write_publickey in %"SC_FORMAT_LEN_SIZE_T"u bytes :\n%s", + count, debug_buf); } if (bn[0].data) @@ -2180,7 +2203,9 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec, int rv = 0; unsigned char recvbuf[SC_MAX_APDU_BUFFER_SIZE]; - sc_log(card->ctx, "auth_read_record(): nr_rec %i; count %i", nr_rec, count); + sc_log(card->ctx, + "auth_read_record(): nr_rec %i; count %"SC_FORMAT_LEN_SIZE_T"u", + nr_rec, count); sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB2, nr_rec, 0); apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3; diff --git a/src/libopensc/card-openpgp.c b/src/libopensc/card-openpgp.c index fb10bde8..cf4de26f 100644 --- a/src/libopensc/card-openpgp.c +++ b/src/libopensc/card-openpgp.c @@ -962,7 +962,9 @@ pgp_get_blob(sc_card_t *card, pgp_blob_t *blob, unsigned int id, return SC_SUCCESS; } else - sc_log(card->ctx, "Not enough memory to create blob for DO %X"); + sc_log(card->ctx, + "Not enough memory to create blob for DO %X", + id); } return SC_ERROR_FILE_NOT_FOUND; @@ -1361,7 +1363,9 @@ gnuk_write_certificate(sc_card_t *card, const u8 *buf, size_t length) size_t plen = MIN(length - i*256, 256); u8 roundbuf[256]; /* space to build APDU data with even length for Gnuk */ - sc_log(card->ctx, "Write part %d from offset 0x%X, len %d", i+1, part, plen); + sc_log(card->ctx, + "Write part %"SC_FORMAT_LEN_SIZE_T"u from offset 0x%"SC_FORMAT_LEN_SIZE_T"X, len %"SC_FORMAT_LEN_SIZE_T"u", + i+1, i*256, plen); /* 1st chunk: P1 = 0x85, further chunks: P1 = chunk no */ sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, (i == 0) ? 0x85 : i, 0); @@ -1480,7 +1484,9 @@ pgp_put_data(sc_card_t *card, unsigned int tag, const u8 *buf, size_t buf_len) * If we check here, the driver may be stuck to a limit version number of card. * 7F21 size is soft-coded, so we can check it. */ if (tag == DO_CERT && buf_len > priv->max_cert_size) { - sc_log(card->ctx, "Data size %ld exceeds DO size limit %ld.", buf_len, priv->max_cert_size); + sc_log(card->ctx, + "Data size %"SC_FORMAT_LEN_SIZE_T"u exceeds DO size limit %"SC_FORMAT_LEN_SIZE_T"u.", + buf_len, priv->max_cert_size); LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH); } @@ -1791,9 +1797,13 @@ pgp_update_new_algo_attr(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *key_ r = pgp_seek_blob(card, priv->mf, (0x00C0 | key_info->keytype), &algo_blob); LOG_TEST_RET(card->ctx, r, "Cannot get old algorithm attributes"); old_modulus_len = bebytes2ushort(algo_blob->data + 1); /* modulus length is coded in byte 2 & 3 */ - sc_log(card->ctx, "Old modulus length %d, new %d.", old_modulus_len, key_info->modulus_len); + sc_log(card->ctx, + "Old modulus length %d, new %"SC_FORMAT_LEN_SIZE_T"u.", + old_modulus_len, key_info->modulus_len); old_exponent_len = bebytes2ushort(algo_blob->data + 3); /* exponent length is coded in byte 3 & 4 */ - sc_log(card->ctx, "Old exponent length %d, new %d.", old_exponent_len, key_info->exponent_len); + sc_log(card->ctx, + "Old exponent length %d, new %"SC_FORMAT_LEN_SIZE_T"u.", + old_exponent_len, key_info->exponent_len); /* Modulus */ /* If passed modulus_len is zero, it means using old key size */ @@ -2103,7 +2113,9 @@ pgp_update_card_algorithms(sc_card_t *card, sc_cardctl_openpgp_keygen_info_t *ke LOG_FUNC_CALLED(card->ctx); if (id > card->algorithm_count) { - sc_log(card->ctx, "This key ID %d is out of the card's algorithm list."); + sc_log(card->ctx, + "This key ID %u is out of the card's algorithm list.", + (unsigned int)id); LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS); } @@ -2486,7 +2498,9 @@ pgp_store_key(sc_card_t *card, sc_cardctl_openpgp_keystore_info_t *key_info) /* we only support exponent of maximum 32 bits */ if (key_info->e_len > 4) { - sc_log(card->ctx, "Exponent %bit (>32) is not supported.", key_info->e_len*8); + sc_log(card->ctx, + "Exponent %"SC_FORMAT_LEN_SIZE_T"u-bit (>32) is not supported.", + key_info->e_len * 8); LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); } diff --git a/src/libopensc/card-piv.c b/src/libopensc/card-piv.c index 6b69aebb..0f22d142 100644 --- a/src/libopensc/card-piv.c +++ b/src/libopensc/card-piv.c @@ -483,8 +483,10 @@ static int piv_general_io(sc_card_t *card, int ins, int p1, int p2, SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - sc_log(card->ctx, "%02x %02x %02x %d : %d %d", - ins, p1, p2, sendbuflen, card->max_send_size, card->max_recv_size); + 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", + ins, p1, p2, sendbuflen, card->max_send_size, + card->max_recv_size); rbuf = rbufinitbuf; rbuflen = sizeof(rbufinitbuf); @@ -523,14 +525,16 @@ static int piv_general_io(sc_card_t *card, int ins, int p1, int p2, apdu.resplen = 0; } - sc_log(card->ctx, "calling sc_transmit_apdu flags=%x le=%d, resplen=%d, resp=%p", - apdu.flags, apdu.le, apdu.resplen, apdu.resp); + 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_log(card->ctx, "DEE r=%d apdu.resplen=%d sw1=%02x sw2=%02x", - r, apdu.resplen, apdu.sw1, apdu.sw2); + sc_log(card->ctx, + "DEE 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_log(card->ctx, "Transmit failed"); goto err; @@ -575,7 +579,9 @@ static int piv_general_io(sc_card_t *card, int ins, int p1, int p2, /* if using internal buffer, alloc new one */ if (rbuf == rbufinitbuf) { *recvbuf = malloc(rbuflen); - sc_log(card->ctx, "DEE got buffer %p len %d",*recvbuf, rbuflen); + sc_log(card->ctx, + "DEE got buffer %p len %"SC_FORMAT_LEN_SIZE_T"u", + *recvbuf, rbuflen); if (*recvbuf == NULL) { r = SC_ERROR_OUT_OF_MEMORY; goto err; @@ -718,8 +724,9 @@ static int piv_select_aid(sc_card_t* card, u8* aid, size_t aidlen, u8* response, int r; LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "Got args: aid=%x, aidlen=%d, response=%x, responselen=%d", - aid, aidlen, response, responselen ? *responselen : 0); + sc_log(card->ctx, + "Got args: aid=%p, aidlen=%"SC_FORMAT_LEN_SIZE_T"u, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u", + aid, aidlen, response, responselen ? *responselen : 0); sc_format_apdu(card, &apdu, response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, 0xA4, 0x04, 0x00); @@ -945,7 +952,9 @@ piv_get_data(sc_card_t * card, int enumtag, u8 **buf, size_t *buf_len) } } - sc_log(card->ctx, "buffer for #%d *buf=0x%p len=%d", enumtag, *buf, *buf_len); + sc_log(card->ctx, + "buffer for #%d *buf=0x%p len=%"SC_FORMAT_LEN_SIZE_T"u", + enumtag, *buf, *buf_len); if (*buf == NULL && *buf_len > 0) { *buf = malloc(*buf_len); if (*buf == NULL ) { @@ -978,12 +987,13 @@ piv_get_cached_data(sc_card_t * card, int enumtag, u8 **buf, size_t *buf_len) /* see if we have it cached */ if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_VALID) { - sc_log(card->ctx, "found #%d %p:%d %p:%d", - enumtag, - priv->obj_cache[enumtag].obj_data, - priv->obj_cache[enumtag].obj_len, - priv->obj_cache[enumtag].internal_obj_data, - priv->obj_cache[enumtag].internal_obj_len); + sc_log(card->ctx, + "found #%d %p:%"SC_FORMAT_LEN_SIZE_T"u %p:%"SC_FORMAT_LEN_SIZE_T"u", + enumtag, + priv->obj_cache[enumtag].obj_data, + priv->obj_cache[enumtag].obj_len, + priv->obj_cache[enumtag].internal_obj_data, + priv->obj_cache[enumtag].internal_obj_len); if (priv->obj_cache[enumtag].obj_len == 0) { @@ -1020,12 +1030,13 @@ piv_get_cached_data(sc_card_t * card, int enumtag, u8 **buf, size_t *buf_len) *buf = rbuf; *buf_len = r; - sc_log(card->ctx, "added #%d %p:%d %p:%d", - enumtag, - priv->obj_cache[enumtag].obj_data, - priv->obj_cache[enumtag].obj_len, - priv->obj_cache[enumtag].internal_obj_data, - priv->obj_cache[enumtag].internal_obj_len); + sc_log(card->ctx, + "added #%d %p:%"SC_FORMAT_LEN_SIZE_T"u %p:%"SC_FORMAT_LEN_SIZE_T"u", + enumtag, + priv->obj_cache[enumtag].obj_data, + priv->obj_cache[enumtag].obj_len, + priv->obj_cache[enumtag].internal_obj_data, + priv->obj_cache[enumtag].internal_obj_len); } else if (r == 0 || r == SC_ERROR_FILE_NOT_FOUND) { r = SC_ERROR_FILE_NOT_FOUND; @@ -1053,9 +1064,11 @@ piv_cache_internal_data(sc_card_t *card, int enumtag) /* if already cached */ if (priv->obj_cache[enumtag].internal_obj_data && priv->obj_cache[enumtag].internal_obj_len) { - sc_log(card->ctx, "#%d found internal %p:%d", enumtag, - priv->obj_cache[enumtag].internal_obj_data, - priv->obj_cache[enumtag].internal_obj_len); + sc_log(card->ctx, + "#%d found internal %p:%"SC_FORMAT_LEN_SIZE_T"u", + enumtag, + priv->obj_cache[enumtag].internal_obj_data, + priv->obj_cache[enumtag].internal_obj_len); LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } @@ -1127,9 +1140,10 @@ piv_cache_internal_data(sc_card_t *card, int enumtag) LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL); } - sc_log(card->ctx, "added #%d internal %p:%d", enumtag, - priv->obj_cache[enumtag].internal_obj_data, - priv->obj_cache[enumtag].internal_obj_len); + sc_log(card->ctx, "added #%d internal %p:%"SC_FORMAT_LEN_SIZE_T"u", + enumtag, + priv->obj_cache[enumtag].internal_obj_data, + priv->obj_cache[enumtag].internal_obj_len); LOG_FUNC_RETURN(card->ctx, SC_SUCCESS); } @@ -1166,7 +1180,9 @@ piv_read_binary(sc_card_t *card, unsigned int idx, unsigned char *buf, size_t co r = SC_ERROR_FILE_NOT_FOUND; goto err; } - sc_log(card->ctx, "DEE rbuf=%p,rbuflen=%d,",rbuf, rbuflen); + sc_log(card->ctx, + "DEE rbuf=%p,rbuflen=%"SC_FORMAT_LEN_SIZE_T"u,", + rbuf, rbuflen); body = sc_asn1_find_tag(card->ctx, rbuf, rbuflen, rbuf[0], &bodylen); if (body == NULL) { /* if missing, assume its the body */ @@ -1176,8 +1192,9 @@ piv_read_binary(sc_card_t *card, unsigned int idx, unsigned char *buf, size_t co goto err; } if (bodylen > body - rbuf + rbuflen) { - sc_log(card->ctx, " ***** tag length > then data: %d>%d+%d", - bodylen , body - rbuf, rbuflen); + sc_log(card->ctx, + " ***** tag length > then data: %"SC_FORMAT_LEN_SIZE_T"u>%"SC_FORMAT_LEN_PTRDIFF_T"u+%"SC_FORMAT_LEN_SIZE_T"u", + bodylen, body - rbuf, rbuflen); r = SC_ERROR_INVALID_DATA; goto err; } @@ -1264,7 +1281,7 @@ piv_write_certificate(sc_card_t *card, const u8* buf, size_t count, unsigned lon size_t sbuflen; size_t taglen; - sc_log(card->ctx, "DEE cert len=%d",count); + sc_log(card->ctx, "DEE cert len=%"SC_FORMAT_LEN_SIZE_T"u", count); taglen = put_tag_and_len(0x70, count, NULL) + put_tag_and_len(0x71, 1, NULL) + put_tag_and_len(0xFE, 0, NULL); @@ -1285,7 +1302,8 @@ piv_write_certificate(sc_card_t *card, const u8* buf, size_t count, unsigned lon *p++ = (flags)? 0x01:0x00; /* certinfo, i.e. gziped? */ put_tag_and_len(0xFE,0,&p); /* LRC tag */ - sc_log(card->ctx, "DEE buf %p len %d %d", sbuf, p -sbuf, sbuflen); + sc_log(card->ctx, "DEE buf %p len %"SC_FORMAT_LEN_PTRDIFF_T"u %"SC_FORMAT_LEN_SIZE_T"u", + sbuf, p - sbuf, sbuflen); enumtag = piv_objects[priv->selected_obj].enumtag; r = piv_put_data(card, enumtag, sbuf, sbuflen); @@ -1691,8 +1709,9 @@ static int piv_general_mutual_authenticate(sc_card_t *card, */ nonce = malloc(witness_len); if(!nonce) { - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "OOM allocating nonce\n", - witness_len, plain_text_len); + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, + "OOM allocating nonce (%"SC_FORMAT_LEN_SIZE_T"u : %"SC_FORMAT_LEN_SIZE_T"u)\n", + witness_len, plain_text_len); r = SC_ERROR_INTERNAL; goto err; } @@ -1700,8 +1719,9 @@ static int piv_general_mutual_authenticate(sc_card_t *card, r = RAND_bytes(nonce, witness_len); if(!r) { - sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Generating random for nonce\n", - witness_len, plain_text_len); + sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, + "Generating random for nonce (%"SC_FORMAT_LEN_SIZE_T"u : %"SC_FORMAT_LEN_SIZE_T"u)\n", + witness_len, plain_text_len); r = SC_ERROR_INTERNAL; goto err; } @@ -2090,8 +2110,9 @@ piv_get_serial_nr_from_CHUI(sc_card_t* card, sc_serial_number_t* serial) gbits = gbits | guid[i]; /* if all are zero, gbits will be zero */ } } - sc_log(card->ctx, "fascn=%p,fascnlen=%d,guid=%p,guidlen=%d,gbits=%2.2x", - fascn, fascnlen, guid, guidlen, gbits); + sc_log(card->ctx, + "fascn=%p,fascnlen=%"SC_FORMAT_LEN_SIZE_T"u,guid=%p,guidlen=%"SC_FORMAT_LEN_SIZE_T"u,gbits=%2.2x", + fascn, fascnlen, guid, guidlen, gbits); if (fascn && fascnlen == 25) { /* test if guid and the fascn starts with ;9999 (in ISO 4bit + partiy code) */ @@ -2205,7 +2226,7 @@ static int piv_get_challenge(sc_card_t *card, u8 *rnd, size_t len) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - sc_log(card->ctx, "challenge len=%d",len); + sc_log(card->ctx, "challenge len=%"SC_FORMAT_LEN_SIZE_T"u", len); r = sc_lock(card); if (r != SC_SUCCESS) @@ -2258,9 +2279,10 @@ piv_set_security_env(sc_card_t *card, const sc_security_env_t *env, int se_num) SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); - sc_log(card->ctx, "flags=%08x op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%d", - env->flags, env->operation, env->algorithm, env->algorithm_flags, - env->algorithm_ref, env->key_ref[0], env->key_ref_len); + sc_log(card->ctx, + "flags=%08lx op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%"SC_FORMAT_LEN_SIZE_T"u", + env->flags, env->operation, env->algorithm, env->algorithm_flags, + env->algorithm_ref, env->key_ref[0], env->key_ref_len); priv->operation = env->operation; priv->algorithm = env->algorithm; @@ -2401,7 +2423,9 @@ piv_compute_signature(sc_card_t *card, const u8 * data, size_t datalen, if (priv->alg_id == 0x11 || priv->alg_id == 0x14 ) { nLen = (priv->key_size + 7) / 8; if (outlen < 2*nLen) { - sc_log(card->ctx, " output too small for EC signature %d < %d", outlen, 2*nLen); + sc_log(card->ctx, + " output too small for EC signature %"SC_FORMAT_LEN_SIZE_T"u < %"SC_FORMAT_LEN_SIZE_T"u", + outlen, 2 * nLen); r = SC_ERROR_INVALID_DATA; goto err; } @@ -2582,7 +2606,8 @@ static int piv_process_discovery(sc_card_t *card) goto err; } - sc_log(card->ctx, "Discovery = %p:%d",rbuf, rbuflen); + sc_log(card->ctx, "Discovery = %p:%"SC_FORMAT_LEN_SIZE_T"u", rbuf, + rbuflen); /* the object is now cached, see what we have */ if (rbuflen != 0) { body = rbuf; @@ -2592,11 +2617,14 @@ static int piv_process_discovery(sc_card_t *card) goto err; } - sc_log(card->ctx, "Discovery 0x%2.2x 0x%2.2x %p:%d", cla_out, tag_out, body, bodylen); + sc_log(card->ctx, + "Discovery 0x%2.2x 0x%2.2x %p:%"SC_FORMAT_LEN_SIZE_T"u", + cla_out, tag_out, body, bodylen); if ( cla_out+tag_out == 0x7E && body != NULL && bodylen != 0) { aidlen = 0; aid = sc_asn1_find_tag(card->ctx, body, bodylen, 0x4F, &aidlen); - sc_log(card->ctx, "Discovery aid=%p:%d",aid,aidlen); + sc_log(card->ctx, "Discovery aid=%p:%"SC_FORMAT_LEN_SIZE_T"u", + aid, aidlen); if (aid == NULL || aidlen < piv_aids[0].len_short || memcmp(aid,piv_aids[0].value,piv_aids[0].len_short) != 0) { /*TODO look at long */ sc_log(card->ctx, "Discovery object not PIV"); @@ -2604,7 +2632,9 @@ static int piv_process_discovery(sc_card_t *card) goto err; } pinp = sc_asn1_find_tag(card->ctx, body, bodylen, 0x5F2F, &pinplen); - sc_log(card->ctx, "Discovery pinp=%p:%d",pinp,pinplen); + sc_log(card->ctx, + "Discovery pinp=%p:%"SC_FORMAT_LEN_SIZE_T"u", + pinp, pinplen); if (pinp && pinplen == 2) { sc_log(card->ctx, "Discovery pinp flags=0x%2.2x 0x%2.2x",*pinp, *(pinp+1)); r = SC_SUCCESS; @@ -2831,10 +2861,11 @@ piv_process_history(sc_card_t *card) certobj = NULL; - sc_log(card->ctx, "Added from off card file #%d %p:%d 0x%02X", - enumtag, - priv->obj_cache[enumtag].obj_data, - priv->obj_cache[enumtag].obj_len, *keyref); + sc_log(card->ctx, + "Added from off card file #%d %p:%"SC_FORMAT_LEN_SIZE_T"u 0x%02X", + enumtag, + priv->obj_cache[enumtag].obj_data, + priv->obj_cache[enumtag].obj_len, *keyref); bodylen -= (seqlen + seq - seqtag); seq += seqlen; @@ -2861,10 +2892,13 @@ piv_finish(sc_card_t *card) if (priv->offCardCertURL) free(priv->offCardCertURL); for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) { - sc_log(card->ctx, "DEE freeing #%d, 0x%02x %p:%d %p:%d", i, - priv->obj_cache[i].flags, - priv->obj_cache[i].obj_data, priv->obj_cache[i].obj_len, - priv->obj_cache[i].internal_obj_data, priv->obj_cache[i].internal_obj_len); + sc_log(card->ctx, + "DEE freeing #%d, 0x%02x %p:%"SC_FORMAT_LEN_SIZE_T"u %p:%"SC_FORMAT_LEN_SIZE_T"u", + i, priv->obj_cache[i].flags, + priv->obj_cache[i].obj_data, + priv->obj_cache[i].obj_len, + priv->obj_cache[i].internal_obj_data, + priv->obj_cache[i].internal_obj_len); if (priv->obj_cache[i].obj_data) free(priv->obj_cache[i].obj_data); if (priv->obj_cache[i].internal_obj_data) @@ -2994,8 +3028,9 @@ static int piv_init(sc_card_t *card) if (!priv || card->type == -1) LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT); - sc_log(card->ctx, "Max send = %d recv = %d card->type = %d", - card->max_send_size, card->max_recv_size, card->type); + sc_log(card->ctx, + "Max send = %"SC_FORMAT_LEN_SIZE_T"u recv = %"SC_FORMAT_LEN_SIZE_T"u card->type = %d", + card->max_send_size, card->max_recv_size, card->type); card->cla = 0x00; if(card->name == NULL) card->name = "PIV-II card"; diff --git a/src/libopensc/card-rtecp.c b/src/libopensc/card-rtecp.c index 5f9d3e3b..a1efe22e 100644 --- a/src/libopensc/card-rtecp.c +++ b/src/libopensc/card-rtecp.c @@ -435,7 +435,8 @@ 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, "newlen = %u\n", newlen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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); if (type == SC_AC_CHV && old && oldlen != 0) diff --git a/src/libopensc/card-rutoken.c b/src/libopensc/card-rutoken.c index 295c23eb..6e2276a5 100644 --- a/src/libopensc/card-rutoken.c +++ b/src/libopensc/card-rutoken.c @@ -550,8 +550,9 @@ 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, "AccessMode.%u, attr[0]=0x%x", - conv_attr[i].sec_attr_pos, attr[0]); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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); if (entry->method == SC_AC_CHV) @@ -979,7 +980,9 @@ static int rutoken_cipher_p(sc_card_t *card, const u8 * crgram, size_t crgram_le sc_apdu_t apdu; SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL); - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, ": crgram_len %i; outlen %i", crgram_len, outlen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + ": crgram_len %"SC_FORMAT_LEN_SIZE_T"u; outlen %"SC_FORMAT_LEN_SIZE_T"u", + crgram_len, outlen); if (!out) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS); @@ -1022,7 +1025,9 @@ 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, "len out cipher %d\n", outlen - outlen_tail); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "len out cipher %"SC_FORMAT_LEN_SIZE_T"u\n", + outlen - outlen_tail); if (ret == SC_SUCCESS) ret = (outlen_tail == 0) ? (int)outlen : SC_ERROR_WRONG_LENGTH; SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, ret); @@ -1240,7 +1245,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 = %d", cmd); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cmd = %lu", cmd); ret = SC_ERROR_NOT_SUPPORTED; break; } diff --git a/src/libopensc/card-sc-hsm.c b/src/libopensc/card-sc-hsm.c index 3e19c90e..adaaff4d 100644 --- a/src/libopensc/card-sc-hsm.c +++ b/src/libopensc/card-sc-hsm.c @@ -486,7 +486,9 @@ static int sc_hsm_decode_ecdsa_signature(sc_card_t *card, fieldsizebytes = 64; } - sc_log(card->ctx, "Field size %d, signature buffer size %d", fieldsizebytes, outlen); + sc_log(card->ctx, + "Field size %"SC_FORMAT_LEN_SIZE_T"u, signature buffer size %"SC_FORMAT_LEN_SIZE_T"u", + fieldsizebytes, outlen); if (outlen < (fieldsizebytes * 2)) { LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "output too small for EC signature"); diff --git a/src/libopensc/card-starcos.c b/src/libopensc/card-starcos.c index 18eb4a0c..5a46f164 100644 --- a/src/libopensc/card-starcos.c +++ b/src/libopensc/card-starcos.c @@ -272,7 +272,8 @@ 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, "processing %d FCI bytes\n", buflen); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "processing %"SC_FORMAT_LEN_SIZE_T"u FCI bytes\n", buflen); if (buflen < 2) return SC_ERROR_INTERNAL; @@ -307,7 +308,8 @@ 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, "processing %d FCP bytes\n", buflen); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "processing %"SC_FORMAT_LEN_SIZE_T"u FCP bytes\n", buflen); if (buflen < 2) return SC_ERROR_INTERNAL; @@ -640,11 +642,12 @@ static int starcos_select_file(sc_card_t *card, pbuf[0] = '\0'; sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "current path (%s, %s): %s (len: %u)\n", - (card->cache.current_path.type==SC_PATH_TYPE_DF_NAME?"aid":"path"), - (card->cache.valid?"valid":"invalid"), pbuf, - card->cache.current_path.len); - + "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", + card->cache.valid ? "valid" : "invalid", pbuf, + card->cache.current_path.len); + memcpy(path, in_path->value, in_path->len); pathlen = in_path->len; diff --git a/src/libopensc/card-tcos.c b/src/libopensc/card-tcos.c index a1545232..c8048784 100644 --- a/src/libopensc/card-tcos.c +++ b/src/libopensc/card-tcos.c @@ -472,8 +472,8 @@ static int tcos_list_files(sc_card_t *card, u8 *buf, size_t buflen) 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, - "got %d %s-FileIDs\n", apdu.resplen/2, - p1==1 ? "DF" : "EF"); + "got %"SC_FORMAT_LEN_SIZE_T"u %s-FileIDs\n", + apdu.resplen / 2, p1 == 1 ? "DF" : "EF"); memcpy(buf, apdu.resp, apdu.resplen); buf += apdu.resplen; @@ -530,8 +530,8 @@ static int tcos_set_security_env(sc_card_t *card, const sc_security_env_t *env, "No Key-Reference in SecEnvironment\n"); else sc_debug(ctx, SC_LOG_DEBUG_NORMAL, - "Key-Reference %02X (len=%d)\n", - env->key_ref[0], env->key_ref_len); + "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, diff --git a/src/libopensc/card-westcos.c b/src/libopensc/card-westcos.c index f542d720..3290b682 100644 --- a/src/libopensc/card-westcos.c +++ b/src/libopensc/card-westcos.c @@ -600,7 +600,7 @@ static int westcos_create_file(sc_card_t *card, struct sc_file *file) p2 = (file->id) % 256; } sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "create file %s, id %X size %d\n", + "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); apdu.cla = 0x80; @@ -866,7 +866,7 @@ static int westcos_card_ctl(sc_card_t * card, unsigned long cmd, void *ptr) if (card == NULL) return SC_ERROR_INVALID_ARGUMENTS; sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "westcos_card_ctl cmd = %X\n", cmd); + "westcos_card_ctl cmd = %lX\n", cmd); priv_data = (priv_data_t *) card->drv_data; switch (cmd) { case SC_CARDCTL_GET_DEFAULT_KEY: @@ -1110,9 +1110,11 @@ 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, - "westcos_sign_decipher outlen=%d\n", outlen); - + "westcos_sign_decipher outlen=%"SC_FORMAT_LEN_SIZE_T"u\n", + outlen); + #ifndef ENABLE_OPENSSL r = SC_ERROR_NOT_SUPPORTED; #else @@ -1176,7 +1178,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card, BIO_set_mem_eof_return(mem, -1); if (!d2i_RSAPrivateKey_bio(mem, &rsa)) { sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "RSA key invalid, %d\n", ERR_get_error()); + "RSA key invalid, %lu\n", ERR_get_error()); r = SC_ERROR_UNKNOWN; goto out; } @@ -1199,7 +1201,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card, #endif sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Decipher error %d\n", ERR_get_error()); + "Decipher error %lu\n", ERR_get_error()); r = SC_ERROR_UNKNOWN; goto out; } @@ -1215,7 +1217,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card, #endif sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Signature error %d\n", ERR_get_error()); + "Signature error %lu\n", ERR_get_error()); r = SC_ERROR_UNKNOWN; goto out; } diff --git a/src/libopensc/card.c b/src/libopensc/card.c index a661a4c7..9ad32661 100644 --- a/src/libopensc/card.c +++ b/src/libopensc/card.c @@ -304,8 +304,10 @@ int sc_connect_card(sc_reader_t *reader, sc_card_t **card_out) card->max_recv_size = sc_get_max_recv_size(card); card->max_send_size = sc_get_max_send_size(card); - sc_log(ctx, "card info name:'%s', type:%i, flags:0x%X, max_send/recv_size:%i/%i", - card->name, card->type, card->flags, card->max_send_size, card->max_recv_size); + sc_log(ctx, + "card info name:'%s', type:%i, flags:0x%lX, max_send/recv_size:%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + card->name, card->type, card->flags, card->max_send_size, + card->max_recv_size); #ifdef ENABLE_SM /* Check, if secure messaging module present. */ @@ -500,7 +502,9 @@ int sc_create_file(sc_card_t *card, sc_file_t *file) if (r != SC_SUCCESS) pbuf[0] = '\0'; - sc_log(card->ctx, "called; type=%d, path=%s, id=%04i, size=%u", in_path->type, pbuf, file->id, file->size); + sc_log(card->ctx, + "called; type=%d, path=%s, id=%04i, size=%"SC_FORMAT_LEN_SIZE_T"u", + in_path->type, pbuf, file->id, file->size); /* ISO 7816-4: "Number of data bytes in the file, including structural information if any" * can not be bigger than two bytes */ if (file->size > 0xFFFF) @@ -539,7 +543,8 @@ int sc_read_binary(sc_card_t *card, unsigned int idx, int r; assert(card != NULL && card->ops != NULL && buf != NULL); - sc_log(card->ctx, "called; %d bytes at index %d", count, idx); + sc_log(card->ctx, "called; %"SC_FORMAT_LEN_SIZE_T"u bytes at index %d", + count, idx); if (count == 0) return 0; @@ -589,7 +594,8 @@ int sc_write_binary(sc_card_t *card, unsigned int idx, int r; assert(card != NULL && card->ops != NULL && buf != NULL); - sc_log(card->ctx, "called; %d bytes at index %d", count, idx); + sc_log(card->ctx, "called; %"SC_FORMAT_LEN_SIZE_T"u bytes at index %d", + count, idx); if (count == 0) LOG_FUNC_RETURN(card->ctx, 0); if (card->ops->write_binary == NULL) @@ -632,7 +638,8 @@ int sc_update_binary(sc_card_t *card, unsigned int idx, int r; assert(card != NULL && card->ops != NULL && buf != NULL); - sc_log(card->ctx, "called; %d bytes at index %d", count, idx); + sc_log(card->ctx, "called; %"SC_FORMAT_LEN_SIZE_T"u bytes at index %d", + count, idx); if (count == 0) return 0; @@ -683,7 +690,9 @@ int sc_erase_binary(struct sc_card *card, unsigned int offs, size_t count, unsi int r; assert(card != NULL && card->ops != NULL); - sc_log(card->ctx, "called; erase %d bytes from offset %d", count, offs); + sc_log(card->ctx, + "called; erase %"SC_FORMAT_LEN_SIZE_T"u bytes from offset %d", + count, offs); if (card->ops->erase_binary == NULL) LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED); @@ -1185,9 +1194,11 @@ void sc_print_cache(struct sc_card *card) { sc_print_path(&card->cache.current_ef->path)); if (card->cache.current_df) - sc_log(ctx, "current_df(type=%i, aid_len=%i) %s", card->cache.current_df->path.type, - card->cache.current_df->path.aid.len, - sc_print_path(&card->cache.current_df->path)); + sc_log(ctx, + "current_df(type=%i, aid_len=%"SC_FORMAT_LEN_SIZE_T"u) %s", + card->cache.current_df->path.type, + card->cache.current_df->path.aid.len, + sc_print_path(&card->cache.current_df->path)); } int sc_copy_ec_params(struct sc_ec_parameters *dst, struct sc_ec_parameters *src) diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index b93e4c2f..6b08bd0d 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -428,7 +428,7 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name const char *(**tmodv)(void) = &modversion; if (name == NULL) { /* should not occurr, but... */ - sc_log(ctx, "No module specified", name); + sc_log(ctx, "No module specified"); return NULL; } libname = find_library(ctx, name); diff --git a/src/libopensc/cwa-dnie.c b/src/libopensc/cwa-dnie.c index 9862eb59..69d26652 100644 --- a/src/libopensc/cwa-dnie.c +++ b/src/libopensc/cwa-dnie.c @@ -327,7 +327,8 @@ int dnie_read_file(sc_card_t * card, goto dnie_read_file_err; } /* call sc_read_binary() to retrieve data */ - sc_log(ctx, "read_binary(): expected '%d' bytes", fsize); + sc_log(ctx, "read_binary(): expected '%"SC_FORMAT_LEN_SIZE_T"u' bytes", + fsize); res = sc_read_binary(card, 0, data, fsize, 0L); if (res < 0) { /* read_binary returns number of bytes readed */ res = SC_ERROR_CARD_CMD_FAILED; diff --git a/src/libopensc/cwa14890.c b/src/libopensc/cwa14890.c index 6b978a5c..2d5045d5 100644 --- a/src/libopensc/cwa14890.c +++ b/src/libopensc/cwa14890.c @@ -120,19 +120,19 @@ static void cwa_trace_apdu(sc_card_t * card, sc_apdu_t * apdu, int flag) if (apdu->datalen > 0) { /* apdu data to show */ buf = cwa_hexdump(apdu->data, apdu->datalen); sc_log(card->ctx, - "\nAPDU before encode: ==================================================\nCLA: %02X INS: %02X P1: %02X P2: %02X Lc: %02X Le: %02X DATA: [%5u bytes]\n%s======================================================================\n", + "\nAPDU before encode: ==================================================\nCLA: %02X INS: %02X P1: %02X P2: %02X Lc: %02"SC_FORMAT_LEN_SIZE_T"X Le: %02"SC_FORMAT_LEN_SIZE_T"X DATA: [%5"SC_FORMAT_LEN_SIZE_T"u bytes]\n%s======================================================================\n", apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le, apdu->datalen, buf); } else { /* apdu data field is empty */ sc_log(card->ctx, - "\nAPDU before encode: ==================================================\nCLA: %02X INS: %02X P1: %02X P2: %02X Lc: %02X Le: %02X (NO DATA)\n======================================================================\n", + "\nAPDU before encode: ==================================================\nCLA: %02X INS: %02X P1: %02X P2: %02X Lc: %02"SC_FORMAT_LEN_SIZE_T"X Le: %02"SC_FORMAT_LEN_SIZE_T"X (NO DATA)\n======================================================================\n", apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le); } } else { /* apdu response */ buf = cwa_hexdump(apdu->resp, apdu->resplen); sc_log(card->ctx, - "\nAPDU response after decode: ==========================================\nSW1: %02X SW2: %02X RESP: [%5u bytes]\n%s======================================================================\n", + "\nAPDU response after decode: ==========================================\nSW1: %02X SW2: %02X RESP: [%5"SC_FORMAT_LEN_SIZE_T"u bytes]\n%s======================================================================\n", apdu->sw1, apdu->sw2, apdu->resplen, buf); } #endif @@ -338,7 +338,7 @@ static int cwa_parse_tlv(sc_card_t * card, } tlv->data = buffer + n + j; tlv->buflen = j + tlv->len;; - sc_log(ctx, "Found Tag: '0x%02X': Length: '%d 'Value:\n%s", + sc_log(ctx, "Found Tag: '0x%02X': Length: '%"SC_FORMAT_LEN_SIZE_T"u' Value:\n%s", tlv->tag, tlv->len, sc_dump_hex(tlv->data, tlv->len)); /* set index to next Tag to jump to */ next = tlv->buflen; @@ -1571,7 +1571,7 @@ int cwa_encode_apdu(sc_card_t * card, /* compose and add computed MAC TLV to result buffer */ tlv_len = (card->atr.value[15] >= DNIE_30_VERSION)? 8 : 4; - sc_log(ctx, "Using TLV lenght: %d", tlv_len); + sc_log(ctx, "Using TLV lenght: %"SC_FORMAT_LEN_SIZE_T"u", tlv_len); res = cwa_compose_tlv(card, 0x8E, tlv_len, macbuf, &apdubuf, &apdulen); if (res != SC_SUCCESS) { msg = "Encode APDU compose_tlv(0x87) failed"; diff --git a/src/libopensc/ef-atr.c b/src/libopensc/ef-atr.c index 89d08d3f..c03473d3 100644 --- a/src/libopensc/ef-atr.c +++ b/src/libopensc/ef-atr.c @@ -64,8 +64,10 @@ sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen) ef_atr.df_selection = *(tag + 0); ef_atr.unit_size = *(tag + 1); ef_atr.card_capabilities = *(tag + 2); - sc_log(ctx, "EF.ATR: DF selection %X, unit_size %X, card caps %X", - ef_atr.df_selection, ef_atr.unit_size, ef_atr.card_capabilities); + sc_log(ctx, + "EF.ATR: DF selection %X, unit_size %"SC_FORMAT_LEN_SIZE_T"X, card caps %X", + ef_atr.df_selection, ef_atr.unit_size, + ef_atr.card_capabilities); } if (ef_atr.card_capabilities & ISO7816_CAP_EXTENDED_LENGTH_INFO) { @@ -77,9 +79,10 @@ sc_parse_ef_atr_content(struct sc_card *card, unsigned char *buf, size_t buflen) * We skip parsing the nested DOs and jump directly to the numbers */ ef_atr.max_command_apdu = bebytes2ushort(tag + 2); ef_atr.max_response_apdu = bebytes2ushort(tag + 6); - sc_log(ctx, "EF.ATR: Biggest command APDU %u bytes, response APDU %u", - (unsigned long) ef_atr.max_command_apdu, - (unsigned long) ef_atr.max_response_apdu); + sc_log(ctx, + "EF.ATR: Biggest command APDU %"SC_FORMAT_LEN_SIZE_T"u bytes, response APDU %"SC_FORMAT_LEN_SIZE_T"u", + ef_atr.max_command_apdu, + ef_atr.max_response_apdu); } } diff --git a/src/libopensc/iasecc-sdo.c b/src/libopensc/iasecc-sdo.c index 0bab4462..6054259a 100644 --- a/src/libopensc/iasecc-sdo.c +++ b/src/libopensc/iasecc-sdo.c @@ -330,7 +330,9 @@ iasecc_se_parse(struct sc_card *card, unsigned char *data, size_t data_len, stru data += size_size + 1; data_len = size; - sc_log(ctx, "IASECC_SDO_TEMPLATE: size %i, size_size %i", size, size_size); + sc_log(ctx, + "IASECC_SDO_TEMPLATE: size %"SC_FORMAT_LEN_SIZE_T"u, size_size %"SC_FORMAT_LEN_SIZE_T"u", + size, size_size); if (*data != IASECC_SDO_TAG_HEADER) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA); @@ -346,11 +348,15 @@ iasecc_se_parse(struct sc_card *card, unsigned char *data, size_t data_len, stru data += 3 + size_size; data_len = size; - sc_log(ctx, "IASECC_SDO_TEMPLATE SE: size %i, size_size %i", size, size_size); + sc_log(ctx, + "IASECC_SDO_TEMPLATE SE: size %"SC_FORMAT_LEN_SIZE_T"u, size_size %"SC_FORMAT_LEN_SIZE_T"u", + size, size_size); } if (*data != IASECC_SDO_CLASS_SE) { - sc_log(ctx, "Invalid SE tag 0x%X; data length %i", *data, data_len); + sc_log(ctx, + "Invalid SE tag 0x%X; data length %"SC_FORMAT_LEN_SIZE_T"u", + *data, data_len); LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED); } @@ -423,7 +429,9 @@ iasecc_parse_get_tlv(struct sc_card *card, unsigned char *data, struct iasecc_ex tlv->on_card = 1; - sc_log(ctx, "iasecc_parse_get_tlv() parsed %i bytes", tag_len + size_len + tlv->size); + sc_log(ctx, + "iasecc_parse_get_tlv() parsed %"SC_FORMAT_LEN_SIZE_T"u bytes", + tag_len + size_len + tlv->size); return tag_len + size_len + tlv->size; } @@ -442,7 +450,9 @@ iasecc_parse_chv(struct sc_card *card, unsigned char *data, size_t data_len, str rv = iasecc_parse_get_tlv(card, data + offs, &tlv); LOG_TEST_RET(ctx, rv, "iasecc_parse_chv() get and parse TLV error"); - sc_log(ctx, "iasecc_parse_chv() get and parse TLV returned %i; tag %X; size %i", rv, tlv.tag, tlv.size); + sc_log(ctx, + "iasecc_parse_chv() get and parse TLV returned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u", + rv, tlv.tag, tlv.size); if (tlv.tag == IASECC_SDO_CHV_TAG_SIZE_MAX) chv->size_max = tlv; @@ -474,7 +484,9 @@ iasecc_parse_prvkey(struct sc_card *card, unsigned char *data, size_t data_len, rv = iasecc_parse_get_tlv(card, data + offs, &tlv); LOG_TEST_RET(ctx, rv, "iasecc_parse_prvkey() get and parse TLV error"); - sc_log(ctx, "iasecc_parse_prvkey() get and parse TLV returned %i; tag %X; size %i", rv, tlv.tag, tlv.size); + sc_log(ctx, + "iasecc_parse_prvkey() get and parse TLV returned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u", + rv, tlv.tag, tlv.size); if (tlv.tag == IASECC_SDO_PRVKEY_TAG_COMPULSORY) prvkey->compulsory = tlv; @@ -502,7 +514,9 @@ iasecc_parse_pubkey(struct sc_card *card, unsigned char *data, size_t data_len, rv = iasecc_parse_get_tlv(card, data + offs, &tlv); LOG_TEST_RET(ctx, rv, "iasecc_parse_pubkey() get and parse TLV error"); - sc_log(ctx, "iasecc_parse_pubkey() get and parse TLV returned %i; tag %X; size %i", rv, tlv.tag, tlv.size); + sc_log(ctx, + "iasecc_parse_pubkey() get and parse TLV returned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u", + rv, tlv.tag, tlv.size); if (tlv.tag == IASECC_SDO_PUBKEY_TAG_N) pubkey->n = tlv; @@ -538,7 +552,9 @@ iasecc_parse_keyset(struct sc_card *card, unsigned char *data, size_t data_len, rv = iasecc_parse_get_tlv(card, data + offs, &tlv); LOG_TEST_RET(ctx, rv, "iasecc_parse_keyset() get and parse TLV error"); - sc_log(ctx, "iasecc_parse_prvkey() get and parse TLV returned %i; tag %X; size %i", rv, tlv.tag, tlv.size); + sc_log(ctx, + "iasecc_parse_prvkey() get and parse TLV returned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u", + rv, tlv.tag, tlv.size); if (tlv.tag == IASECC_SDO_KEYSET_TAG_COMPULSORY) keyset->compulsory = tlv; @@ -566,7 +582,9 @@ iasecc_parse_docp(struct sc_card *card, unsigned char *data, size_t data_len, st rv = iasecc_parse_get_tlv(card, data + offs, &tlv); LOG_TEST_RET(ctx, rv, "iasecc_parse_get_tlv() get and parse TLV error"); - sc_log(ctx, "iasecc_parse_docp() parse_get_tlv retuned %i; tag %X; size %i", rv, tlv.tag, tlv.size); + sc_log(ctx, + "iasecc_parse_docp() parse_get_tlv retuned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u", + rv, tlv.tag, tlv.size); if (tlv.tag == IASECC_DOCP_TAG_ACLS) { int _rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo); @@ -629,7 +647,9 @@ iasecc_sdo_parse_data(struct sc_card *card, unsigned char *data, struct iasecc_s sc_log(ctx, "iasecc_sdo_parse_data() tlv.tag 0x%X", tlv.tag); if (tlv.tag == IASECC_DOCP_TAG) { - sc_log(ctx, "iasecc_sdo_parse_data() parse IASECC_DOCP_TAG: 0x%X; size %i", tlv.tag, tlv.size); + sc_log(ctx, + "iasecc_sdo_parse_data() parse IASECC_DOCP_TAG: 0x%X; size %"SC_FORMAT_LEN_SIZE_T"u", + tlv.tag, tlv.size); rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo); sc_log(ctx, "iasecc_sdo_parse_data() parsed IASECC_DOCP_TAG rv %i", rv); free(tlv.value); @@ -707,7 +727,9 @@ iasecc_sdo_parse(struct sc_card *card, unsigned char *data, size_t data_len, str data += size_size + 1; data_len = size; - sc_log(ctx, "IASECC_SDO_TEMPLATE: size %i, size_size %i", size, size_size); + sc_log(ctx, + "IASECC_SDO_TEMPLATE: size %"SC_FORMAT_LEN_SIZE_T"u, size_size %"SC_FORMAT_LEN_SIZE_T"u", + size, size_size); } if (*data != IASECC_SDO_TAG_HEADER) @@ -725,7 +747,9 @@ iasecc_sdo_parse(struct sc_card *card, unsigned char *data, size_t data_len, str if (data_len != size + size_size + 3) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalide SDO data size"); - sc_log(ctx, "sz %i, sz_size %i", size, size_size); + sc_log(ctx, + "sz %"SC_FORMAT_LEN_SIZE_T"u, sz_size %"SC_FORMAT_LEN_SIZE_T"u", + size, size_size); offs = 3 + size_size; for (; offs < data_len;) { @@ -738,7 +762,9 @@ iasecc_sdo_parse(struct sc_card *card, unsigned char *data, size_t data_len, str if (offs != data_len) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: not totaly parsed"); - sc_log(ctx, "docp.acls_contact.size %i, docp.size.size %i", sdo->docp.acls_contact.size, sdo->docp.size.size); + sc_log(ctx, + "docp.acls_contact.size %"SC_FORMAT_LEN_SIZE_T"u, docp.size.size %"SC_FORMAT_LEN_SIZE_T"u", + sdo->docp.acls_contact.size, sdo->docp.size.size); LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -779,7 +805,9 @@ iasecc_sdo_allocate_and_parse(struct sc_card *card, unsigned char *data, size_t if (data_len != size + size_size + 3) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalide SDO data size"); - sc_log(ctx, "sz %i, sz_size %i", size, size_size); + sc_log(ctx, + "sz %"SC_FORMAT_LEN_SIZE_T"u, sz_size %"SC_FORMAT_LEN_SIZE_T"u", + size, size_size); offs = 3 + size_size; for (; offs < data_len;) { @@ -792,7 +820,9 @@ iasecc_sdo_allocate_and_parse(struct sc_card *card, unsigned char *data, size_t if (offs != data_len) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: not totaly parsed"); - sc_log(ctx, "docp.acls_contact.size %i; docp.size.size %i", sdo->docp.acls_contact.size, sdo->docp.size.size); + sc_log(ctx, + "docp.acls_contact.size %"SC_FORMAT_LEN_SIZE_T"u; docp.size.size %"SC_FORMAT_LEN_SIZE_T"u", + sdo->docp.acls_contact.size, sdo->docp.size.size); LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -1095,7 +1125,9 @@ iasecc_sdo_encode_rsa_update(struct sc_context *ctx, struct iasecc_sdo *sdo, str sc_log(ctx, "prv_key.compulsory.on_card %i", sdo->data.prv_key.compulsory.on_card); if (!sdo->data.prv_key.compulsory.on_card) { if (sdo->data.prv_key.compulsory.value) { - sc_log(ctx, "sdo_prvkey->data.prv_key.compulsory.size %i", sdo->data.prv_key.compulsory.size); + sc_log(ctx, + "sdo_prvkey->data.prv_key.compulsory.size %"SC_FORMAT_LEN_SIZE_T"u", + sdo->data.prv_key.compulsory.size); sdo_update->fields[indx].parent_tag = IASECC_SDO_PRVKEY_TAG; sdo_update->fields[indx].tag = IASECC_SDO_PRVKEY_TAG_COMPULSORY; sdo_update->fields[indx].value = sdo->data.prv_key.compulsory.value; diff --git a/src/libopensc/iasecc-sm.c b/src/libopensc/iasecc-sm.c index d92d8f14..681a7677 100644 --- a/src/libopensc/iasecc-sm.c +++ b/src/libopensc/iasecc-sm.c @@ -97,7 +97,7 @@ iasecc_sm_transmit_apdus(struct sc_card *card, struct sc_remote_data *rdata, sc_log(ctx, "iasecc_sm_transmit_apdus() rdata-length %i", rdata->length); while (rapdu) { - sc_log(ctx, "iasecc_sm_transmit_apdus() rAPDU flags 0x%X", rapdu->apdu.flags); + sc_log(ctx, "iasecc_sm_transmit_apdus() rAPDU flags 0x%lX", rapdu->apdu.flags); rv = sc_transmit_apdu(card, &rapdu->apdu); LOG_TEST_RET(ctx, rv, "iasecc_sm_transmit_apdus() failed to execute r-APDU"); rv = sc_check_sw(card, rapdu->apdu.sw1, rapdu->apdu.sw2); @@ -270,7 +270,7 @@ iasecc_sm_get_challenge(struct sc_card *card, unsigned char *out, size_t len) unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE]; int rv; - sc_log(ctx, "SM get challenge: length %i",len); + sc_log(ctx, "SM get challenge: length %"SC_FORMAT_LEN_SIZE_T"u", len); sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x84, 0, 0); apdu.le = len; apdu.resplen = len; @@ -339,7 +339,9 @@ iasecc_sm_initialize(struct sc_card *card, unsigned se_num, unsigned cmd) rdata.free(&rdata); - sc_log(ctx, "MA data(len:%i) '%s'", cwa_session->mdata_len, sc_dump_hex(cwa_session->mdata, cwa_session->mdata_len)); + sc_log(ctx, "MA data(len:%"SC_FORMAT_LEN_SIZE_T"u) '%s'", + cwa_session->mdata_len, + sc_dump_hex(cwa_session->mdata, cwa_session->mdata_len)); if (cwa_session->mdata_len != 0x48) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "iasecc_sm_initialize() invalid MUTUAL AUTHENTICATE result data"); @@ -374,7 +376,9 @@ iasecc_sm_cmd(struct sc_card *card, struct sc_remote_data *rdata) for (rapdu = rdata->data; rapdu; rapdu = rapdu->next) { struct sc_apdu *apdu = &rapdu->apdu; - sc_log(ctx, "iasecc_sm_cmd() apdu->ins:0x%X, resplen %i", apdu->ins, apdu->resplen); + sc_log(ctx, + "iasecc_sm_cmd() apdu->ins:0x%X, resplen %"SC_FORMAT_LEN_SIZE_T"u", + apdu->ins, apdu->resplen); if (!apdu->ins) break; rv = sc_transmit_apdu(card, apdu); @@ -388,7 +392,9 @@ iasecc_sm_cmd(struct sc_card *card, struct sc_remote_data *rdata) sc_log(ctx, "iasecc_sm_cmd() APDU error rv:%i", rv); break; } - sc_log(ctx, "iasecc_sm_cmd() apdu->resplen %i", apdu->resplen); + sc_log(ctx, + "iasecc_sm_cmd() apdu->resplen %"SC_FORMAT_LEN_SIZE_T"u", + apdu->resplen); } LOG_FUNC_RETURN(ctx, rv); @@ -579,7 +585,9 @@ iasecc_sm_create_file(struct sc_card *card, unsigned se_num, unsigned char *fcp, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "iasecc_sm_create_file() SE#%i, fcp(%i) '%s'", se_num, fcp_len, sc_dump_hex(fcp, fcp_len)); + sc_log(ctx, + "iasecc_sm_create_file() SE#%i, fcp(%"SC_FORMAT_LEN_SIZE_T"u) '%s'", + se_num, fcp_len, sc_dump_hex(fcp, fcp_len)); rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_CREATE); LOG_TEST_RET(ctx, rv, "iasecc_sm_create_file() SM INITIALIZE failed"); @@ -614,7 +622,9 @@ iasecc_sm_read_binary(struct sc_card *card, unsigned se_num, size_t offs, unsign int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM read binary: acl:%X, offs:%i, count:%i", se_num, offs, count); + sc_log(ctx, + "SM read binary: acl:%X, offs:%"SC_FORMAT_LEN_SIZE_T"u, count:%"SC_FORMAT_LEN_SIZE_T"u", + se_num, offs, count); rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_READ); LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM INITIALIZE failed"); @@ -653,7 +663,9 @@ iasecc_sm_update_binary(struct sc_card *card, unsigned se_num, size_t offs, int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM update binary: acl:%X, offs:%i, count:%i", se_num, offs, count); + sc_log(ctx, + "SM update binary: acl:%X, offs:%"SC_FORMAT_LEN_SIZE_T"u, count:%"SC_FORMAT_LEN_SIZE_T"u", + se_num, offs, count); rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_UPDATE); LOG_TEST_RET(ctx, rv, "iasecc_sm_update_binary() SM INITIALIZE failed"); diff --git a/src/libopensc/iso7816.c b/src/libopensc/iso7816.c index 7de3c1ab..9c60583c 100644 --- a/src/libopensc/iso7816.c +++ b/src/libopensc/iso7816.c @@ -360,7 +360,8 @@ iso7816_process_fci(struct sc_card *card, struct sc_file *file, continue; file->size = size; - sc_log(ctx, " bytes in file: %d", file->size); + sc_log(ctx, " bytes in file: %"SC_FORMAT_LEN_SIZE_T"u", + file->size); break; } @@ -901,8 +902,9 @@ iso7816_compute_signature(struct sc_card *card, assert(card != NULL && data != NULL && out != NULL); LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "ISO7816 compute signature: in-len %i, out-len %i", - datalen, outlen); + sc_log(card->ctx, + "ISO7816 compute signature: in-len %"SC_FORMAT_LEN_SIZE_T"u, out-len %"SC_FORMAT_LEN_SIZE_T"u", + datalen, outlen); /* INS: 0x2A PERFORM SECURITY OPERATION * P1: 0x9E Resp: Digital Signature @@ -940,7 +942,9 @@ iso7816_decipher(struct sc_card *card, assert(card != NULL && crgram != NULL && out != NULL); LOG_FUNC_CALLED(card->ctx); - sc_log(card->ctx, "ISO7816 decipher: in-len %i, out-len %i", crgram_len, outlen); + sc_log(card->ctx, + "ISO7816 decipher: in-len %"SC_FORMAT_LEN_SIZE_T"u, out-len %"SC_FORMAT_LEN_SIZE_T"u", + crgram_len, outlen); sbuf = malloc(crgram_len + 1); if (sbuf == NULL) diff --git a/src/libopensc/muscle.c b/src/libopensc/muscle.c index 14d9459d..78f06fba 100644 --- a/src/libopensc/muscle.c +++ b/src/libopensc/muscle.c @@ -58,7 +58,9 @@ 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, "expected 14 bytes, got %d.\n", apdu.resplen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "expected 14 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n", + apdu.resplen); return SC_ERROR_UNKNOWN_DATA_RECEIVED; } memcpy(file->objectId.id, fileData, 4); @@ -79,7 +81,8 @@ 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, - "READ: Offset: %x\tLength: %i\n", offset, dataLength); + "READ: Offset: %x\tLength: %"SC_FORMAT_LEN_SIZE_T"u\n", offset, + dataLength); memcpy(buffer, objectId.id, 4); ulong2bebytes(buffer + 4, offset); buffer[8] = (u8)dataLength; @@ -183,7 +186,9 @@ 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, "WRITE: Offset: %x\tLength: %i\n", offset, dataLength); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "WRITE: Offset: %x\tLength: %"SC_FORMAT_LEN_SIZE_T"u\n", + offset, dataLength); memcpy(buffer, objectId.id, 4); ulong2bebytes(buffer + 4, offset); diff --git a/src/libopensc/padding.c b/src/libopensc/padding.c index 290e6160..25ee3006 100644 --- a/src/libopensc/padding.c +++ b/src/libopensc/padding.c @@ -173,7 +173,8 @@ sc_pkcs1_strip_02_padding(sc_context_t *ctx, const u8 *data, size_t len, u8 *out *out_len = len - n; memmove(out, data + n, *out_len); - sc_log(ctx, "stripped output(%i): %s", len - n, sc_dump_hex(out, len - n)); + sc_log(ctx, "stripped output(%"SC_FORMAT_LEN_SIZE_T"u): %s", len - n, + sc_dump_hex(out, len - n)); LOG_FUNC_RETURN(ctx, len - n); } @@ -284,7 +285,7 @@ int sc_get_encoding_flags(sc_context_t *ctx, if (pflags == NULL || sflags == NULL) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "iFlags 0x%X, card capabilities 0x%X", iflags, caps); + sc_log(ctx, "iFlags 0x%lX, card capabilities 0x%lX", iflags, caps); for (i = 0; digest_info_prefix[i].algorithm != 0; i++) { if (iflags & digest_info_prefix[i].algorithm) { if (digest_info_prefix[i].algorithm != SC_ALGORITHM_RSA_HASH_NONE && @@ -313,6 +314,6 @@ int sc_get_encoding_flags(sc_context_t *ctx, LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported algorithm"); } - sc_log(ctx, "pad flags 0x%X, secure algorithm flags 0x%X", *pflags, *sflags); + sc_log(ctx, "pad flags 0x%lX, secure algorithm flags 0x%lX", *pflags, *sflags); LOG_FUNC_RETURN(ctx, SC_SUCCESS); } diff --git a/src/libopensc/pkcs15-algo.c b/src/libopensc/pkcs15-algo.c index 537cd47c..c383f2d5 100644 --- a/src/libopensc/pkcs15-algo.c +++ b/src/libopensc/pkcs15-algo.c @@ -267,7 +267,9 @@ asn1_decode_ec_params(sc_context_t *ctx, void **paramp, struct sc_asn1_entry asn1_ec_params[4]; struct sc_ec_parameters *ecp; - sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DEE - asn1_decode_ec_params %p:%d %d", buf, buflen, depth); + sc_debug(ctx, SC_LOG_DEBUG_ASN1, + "DEE - asn1_decode_ec_params %p:%"SC_FORMAT_LEN_SIZE_T"u %d", + buf, buflen, depth); memset(&curve, 0, sizeof(curve)); diff --git a/src/libopensc/pkcs15-cac.c b/src/libopensc/pkcs15-cac.c index 4894fe41..194313d5 100644 --- a/src/libopensc/pkcs15-cac.c +++ b/src/libopensc/pkcs15-cac.c @@ -336,8 +336,9 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card) } cert_info.path.count = cert_der.len; - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cert len=%d, cert_info.path.count=%d r=%d\n", - cert_der.len, cert_info.path.count, r); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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); /* cache it using the PKCS15 emulation objects */ diff --git a/src/libopensc/pkcs15-cache.c b/src/libopensc/pkcs15-cache.c index 5cdd0cd3..824f1d12 100644 --- a/src/libopensc/pkcs15-cache.c +++ b/src/libopensc/pkcs15-cache.c @@ -209,7 +209,9 @@ 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, "fwrite() wrote only %d bytes", c); + sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, + "fwrite() wrote only %"SC_FORMAT_LEN_SIZE_T"u bytes", + c); unlink(fname); return SC_ERROR_INTERNAL; } diff --git a/src/libopensc/pkcs15-gemsafeGPK.c b/src/libopensc/pkcs15-gemsafeGPK.c index c4d96cb1..0b8185db 100644 --- a/src/libopensc/pkcs15-gemsafeGPK.c +++ b/src/libopensc/pkcs15-gemsafeGPK.c @@ -487,8 +487,8 @@ 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 %d", - kinfo[j].fileid, prkey_info.id); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "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; break; diff --git a/src/libopensc/pkcs15-gemsafeV1.c b/src/libopensc/pkcs15-gemsafeV1.c index 091720c6..ccc43c6b 100644 --- a/src/libopensc/pkcs15-gemsafeV1.c +++ b/src/libopensc/pkcs15-gemsafeV1.c @@ -185,9 +185,11 @@ static int gemsafe_get_cert_len(sc_card_t *card) * (allocated EF space is much greater!) */ objlen = (((size_t) ibuf[0]) << 8) | ibuf[1]; - sc_log(card->ctx, "Stored object is of size: %d", objlen); + sc_log(card->ctx, "Stored object is of size: %"SC_FORMAT_LEN_SIZE_T"u", + objlen); if (objlen < 1 || objlen > GEMSAFE_MAX_OBJLEN) { - sc_log(card->ctx, "Invalid object size: %d", objlen); + sc_log(card->ctx, "Invalid object size: %"SC_FORMAT_LEN_SIZE_T"u", + objlen); return SC_ERROR_INTERNAL; } @@ -259,7 +261,9 @@ static int gemsafe_get_cert_len(sc_card_t *card) if (ind+3 >= sizeof ibuf) return SC_ERROR_INVALID_DATA; certlen = ((((size_t) ibuf[ind+2]) << 8) | ibuf[ind+3]) + 4; - sc_log(card->ctx, "Found certificate of key container %d at offset %d, len %d", i+1, ind, certlen); + sc_log(card->ctx, + "Found certificate of key container %d at offset %d, len %"SC_FORMAT_LEN_SIZE_T"u", + i+1, ind, certlen); gemsafe_cert[i].index = ind; gemsafe_cert[i].count = certlen; ind += certlen; diff --git a/src/libopensc/pkcs15-gids.c b/src/libopensc/pkcs15-gids.c index 158d7e04..a01263c5 100644 --- a/src/libopensc/pkcs15-gids.c +++ b/src/libopensc/pkcs15-gids.c @@ -51,7 +51,8 @@ static int sc_pkcs15emu_gids_add_prkey(sc_pkcs15_card_t * p15card, sc_cardctl_gi int r; char ch_tmp[10]; sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "Got args: containerIndex=%x\n", container->containernum); + "Got args: containerIndex=%"SC_FORMAT_LEN_SIZE_T"x\n", + container->containernum); memset(&prkey_info, 0, sizeof(prkey_info)); memset(&prkey_obj, 0, sizeof(prkey_obj)); diff --git a/src/libopensc/pkcs15-oberthur.c b/src/libopensc/pkcs15-oberthur.c index 5073d361..1426ba80 100644 --- a/src/libopensc/pkcs15-oberthur.c +++ b/src/libopensc/pkcs15-oberthur.c @@ -389,7 +389,9 @@ sc_oberthur_parse_containers (struct sc_pkcs15_card *p15card, struct container *cont; unsigned char *ptr = buff + offs + 2; - sc_log(ctx, "parse contaniers offs:%i, len:%i", offs, len); + sc_log(ctx, + "parse contaniers offs:%"SC_FORMAT_LEN_SIZE_T"u, len:%"SC_FORMAT_LEN_SIZE_T"u", + offs, len); if (*(buff + offs) != 'R') return SC_ERROR_INVALID_DATA; @@ -1019,8 +1021,9 @@ sc_pkcs15emu_oberthur_init(struct sc_pkcs15_card * p15card) &oberthur_infos[ii].content, &oberthur_infos[ii].len, 1); LOG_TEST_RET(ctx, rv, "Oberthur init failed: read oberthur file error"); - sc_log(ctx, "Oberthur init: parse %s file, content length %i", - oberthur_infos[ii].name, oberthur_infos[ii].len); + sc_log(ctx, + "Oberthur init: parse %s file, content length %"SC_FORMAT_LEN_SIZE_T"u", + oberthur_infos[ii].name, oberthur_infos[ii].len); rv = oberthur_infos[ii].parser(p15card, oberthur_infos[ii].content, oberthur_infos[ii].len, oberthur_infos[ii].postpone_allowed); LOG_TEST_RET(ctx, rv, "Oberthur init failed: parse error"); diff --git a/src/libopensc/pkcs15-pin.c b/src/libopensc/pkcs15-pin.c index c4d56374..5e1255c1 100644 --- a/src/libopensc/pkcs15-pin.c +++ b/src/libopensc/pkcs15-pin.c @@ -318,8 +318,10 @@ _sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *p struct sc_pin_cmd_data data; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "PIN(type:%X; method:%X; value(%p:%i)", auth_info->auth_type, auth_info->auth_method, - pincode, pinlen); + sc_log(ctx, + "PIN(type:%X; method:%X; value(%p:%"SC_FORMAT_LEN_SIZE_T"u)", + auth_info->auth_type, auth_info->auth_method, + pincode, pinlen); if (pinlen > SC_MAX_PIN_SIZE) LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_LENGTH, "Invalid PIN size"); diff --git a/src/libopensc/pkcs15-prkey.c b/src/libopensc/pkcs15-prkey.c index f557bc16..2c775eb9 100644 --- a/src/libopensc/pkcs15-prkey.c +++ b/src/libopensc/pkcs15-prkey.c @@ -505,7 +505,8 @@ sc_pkcs15_prkey_attrs_from_cert(struct sc_pkcs15_card *p15card, struct sc_pkcs15 ERR_load_ERR_strings(); ERR_load_crypto_strings(); - sc_log(ctx, "CertValue(%i) %p", cert_object->content.len, cert_object->content.value); + sc_log(ctx, "CertValue(%"SC_FORMAT_LEN_SIZE_T"u) %p", + cert_object->content.len, cert_object->content.value); mem = BIO_new_mem_buf(cert_object->content.value, cert_object->content.len); if (!mem) LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "MEM buffer allocation error"); diff --git a/src/libopensc/pkcs15-pubkey.c b/src/libopensc/pkcs15-pubkey.c index abe00cd0..536b8b24 100644 --- a/src/libopensc/pkcs15-pubkey.c +++ b/src/libopensc/pkcs15-pubkey.c @@ -726,7 +726,8 @@ sc_pkcs15_decode_pubkey_ec(sc_context_t *ctx, if (*ecpoint_data != 0x04) LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Supported only uncompressed EC pointQ value"); - sc_log(ctx, "decode-EC key=%p, buf=%p, buflen=%d", key, buf, buflen); + sc_log(ctx, "decode-EC key=%p, buf=%p, buflen=%"SC_FORMAT_LEN_SIZE_T"u", + key, buf, buflen); key->ecpointQ.len = ecpoint_len; key->ecpointQ.value = ecpoint_data; @@ -755,7 +756,9 @@ sc_pkcs15_encode_pubkey_ec(sc_context_t *ctx, struct sc_pkcs15_pubkey_ec *key, r = sc_asn1_encode(ctx, asn1_ec_pointQ, buf, buflen); LOG_TEST_RET(ctx, r, "ASN.1 encoding failed"); - sc_log(ctx, "EC key->ecpointQ=%p:%d *buf=%p:%d", key->ecpointQ.value, key->ecpointQ.len, *buf, *buflen); + sc_log(ctx, + "EC key->ecpointQ=%p:%"SC_FORMAT_LEN_SIZE_T"u *buf=%p:%"SC_FORMAT_LEN_SIZE_T"u", + key->ecpointQ.value, key->ecpointQ.len, *buf, *buflen); LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -1304,7 +1307,9 @@ sc_pkcs15_pubkey_from_spki_fields(struct sc_context *ctx, struct sc_pkcs15_pubke unsigned char *tmp_buf = NULL; int r; - sc_log(ctx, "sc_pkcs15_pubkey_from_spki_fields() called: %p:%d\n%s", buf, buflen, sc_dump_hex(buf, buflen)); + sc_log(ctx, + "sc_pkcs15_pubkey_from_spki_fields() called: %p:%"SC_FORMAT_LEN_SIZE_T"u\n%s", + buf, buflen, sc_dump_hex(buf, buflen)); tmp_buf = malloc(buflen); if (!tmp_buf) { @@ -1515,7 +1520,8 @@ sc_pkcs15_fix_ec_parameters(struct sc_context *ctx, struct sc_ec_parameters *ecp sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str); ecparams->field_length = ec_curve_infos[ii].size; - sc_log(ctx, "Curve length %i", ecparams->field_length); + sc_log(ctx, "Curve length %"SC_FORMAT_LEN_SIZE_T"u", + ecparams->field_length); } else if (ecparams->named_curve) { /* it can be name of curve or OID in ASCII form */ for (ii=0; ec_curve_infos[ii].name; ii++) { diff --git a/src/libopensc/pkcs15-sec.c b/src/libopensc/pkcs15-sec.c index e8609eac..fbdd7cf0 100644 --- a/src/libopensc/pkcs15-sec.c +++ b/src/libopensc/pkcs15-sec.c @@ -149,7 +149,9 @@ static int format_senv(struct sc_pkcs15_card *p15card, case SC_PKCS15_TYPE_PRKEY_RSA: *alg_info_out = sc_card_find_rsa_alg(p15card->card, prkey->modulus_length); if (*alg_info_out == NULL) { - sc_log(ctx, "Card does not support RSA with key length %d", prkey->modulus_length); + sc_log(ctx, + "Card does not support RSA with key length %"SC_FORMAT_LEN_SIZE_T"u", + prkey->modulus_length); LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); } senv_out->algorithm = SC_ALGORITHM_RSA; @@ -158,7 +160,9 @@ static int format_senv(struct sc_pkcs15_card *p15card, case SC_PKCS15_TYPE_PRKEY_GOSTR3410: *alg_info_out = sc_card_find_gostr3410_alg(p15card->card, prkey->modulus_length); if (*alg_info_out == NULL) { - sc_log(ctx, "Card does not support GOSTR3410 with key length %d", prkey->modulus_length); + sc_log(ctx, + "Card does not support GOSTR3410 with key length %"SC_FORMAT_LEN_SIZE_T"u", + prkey->modulus_length); LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); } senv_out->algorithm = SC_ALGORITHM_GOSTR3410; @@ -167,7 +171,9 @@ static int format_senv(struct sc_pkcs15_card *p15card, case SC_PKCS15_TYPE_PRKEY_EC: *alg_info_out = sc_card_find_ec_alg(p15card->card, prkey->field_length, NULL); if (*alg_info_out == NULL) { - sc_log(ctx, "Card does not support EC with field_size %d", prkey->field_length); + sc_log(ctx, + "Card does not support EC with field_size %"SC_FORMAT_LEN_SIZE_T"u", + prkey->field_length); LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); } senv_out->algorithm = SC_ALGORITHM_EC; @@ -409,7 +415,7 @@ int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card, } senv.algorithm_flags = sec_flags; - sc_log(ctx, "DEE flags:0x%8.8x alg_info->flags:0x%8.8x pad:0x%8.8x sec:0x%8.8x", + sc_log(ctx, "DEE flags:0x%8.8lx alg_info->flags:0x%8.8x pad:0x%8.8lx sec:0x%8.8lx", flags, alg_info->flags, pad_flags, sec_flags); /* add the padding bytes (if necessary) */ diff --git a/src/libopensc/reader-pcsc.c b/src/libopensc/reader-pcsc.c index f84c9cac..d7bb6bc2 100644 --- a/src/libopensc/reader-pcsc.c +++ b/src/libopensc/reader-pcsc.c @@ -344,8 +344,8 @@ static int refresh_attributes(sc_reader_t *reader) state = priv->reader_state.dwEventState; prev_state = priv->reader_state.dwCurrentState; - sc_log(reader->ctx, "current state: 0x%08X", state); - sc_log(reader->ctx, "previous state: 0x%08X", prev_state); + sc_log(reader->ctx, "current state: 0x%08X", (unsigned int)state); + sc_log(reader->ctx, "previous state: 0x%08X", (unsigned int)prev_state); if (state & SCARD_STATE_UNKNOWN) { /* State means "reader unknown", but we have listed it at least once. @@ -561,7 +561,9 @@ static int pcsc_connect(sc_reader_t *reader) sc_log(reader->ctx, "Reconnecting to force protocol"); r = pcsc_reconnect(reader, SCARD_UNPOWER_CARD); if (r != SC_SUCCESS) { - sc_log(reader->ctx, "pcsc_reconnect (to force protocol) failed", r); + sc_log(reader->ctx, + "pcsc_reconnect (to force protocol) failed (%d)", + r); return r; } } @@ -613,7 +615,8 @@ static int pcsc_lock(sc_reader_t *reader) case SCARD_E_READER_UNAVAILABLE: r = pcsc_connect(reader); if (r != SC_SUCCESS) { - sc_log(reader->ctx, "pcsc_connect failed", r); + sc_log(reader->ctx, "pcsc_connect failed (%d)", + r); return r; } /* return failure so that upper layers will be notified and try to lock again */ @@ -623,7 +626,8 @@ static int pcsc_lock(sc_reader_t *reader) PCSC_TRACE(reader, "SCardBeginTransaction calling pcsc_reconnect", rv); r = pcsc_reconnect(reader, SCARD_LEAVE_CARD); if (r != SC_SUCCESS) { - sc_log(reader->ctx, "pcsc_reconnect failed", r); + sc_log(reader->ctx, + "pcsc_reconnect failed (%d)", r); return r; } /* return failure so that upper layers will be notified and try to lock again */ @@ -766,10 +770,14 @@ static int pcsc_init(sc_context_t *ctx) gpriv->provider_library = scconf_get_str(conf_block, "provider_library", gpriv->provider_library); } - sc_log(ctx, "PC/SC options: connect_exclusive=%d disconnect_action=%d transaction_end_action=%d" - " reconnect_action=%d enable_pinpad=%d enable_pace=%d", - gpriv->connect_exclusive, gpriv->disconnect_action, gpriv->transaction_end_action, - gpriv->reconnect_action, gpriv->enable_pinpad, gpriv->enable_pace); + sc_log(ctx, + "PC/SC options: connect_exclusive=%d disconnect_action=%u transaction_end_action=%u" + " reconnect_action=%u enable_pinpad=%d enable_pace=%d", + gpriv->connect_exclusive, + (unsigned int)gpriv->disconnect_action, + (unsigned int)gpriv->transaction_end_action, + (unsigned int)gpriv->reconnect_action, gpriv->enable_pinpad, + gpriv->enable_pace); gpriv->dlhandle = sc_dlopen(gpriv->provider_library); if (gpriv->dlhandle == NULL) { @@ -1106,7 +1114,10 @@ static void detect_reader_features(sc_reader_t *reader, SCARDHANDLE card_handle) } } else { - sc_log(ctx, "Returned PIN properties structure has bad length (%d/%d)", rcount, sizeof(PIN_PROPERTIES_STRUCTURE)); + sc_log(ctx, + "Returned PIN properties structure has bad length (%lu/%"SC_FORMAT_LEN_SIZE_T"u)", + (unsigned long)rcount, + sizeof(PIN_PROPERTIES_STRUCTURE)); } } } @@ -1328,7 +1339,9 @@ static int pcsc_detect_readers(sc_context_t *ctx) reader->flags |= SC_READER_ENABLE_ESCAPE; } - sc_log(ctx, "reader's max-send-size: %i, max-recv-size: %i", reader->max_send_size, reader->max_recv_size); + sc_log(ctx, + "reader's max-send-size: %"SC_FORMAT_LEN_SIZE_T"u, max-recv-size: %"SC_FORMAT_LEN_SIZE_T"u", + reader->max_send_size, reader->max_recv_size); } continue; @@ -1453,8 +1466,10 @@ static int pcsc_wait_for_event(sc_context_t *ctx, unsigned int event_mask, sc_re *event = 0; for (i = 0, rsp = rgReaderStates; i < num_watch; i++, rsp++) { DWORD state, prev_state; - sc_log(ctx, "'%s' before=0x%08X now=0x%08X", rsp->szReader, - rsp->dwCurrentState, rsp->dwEventState); + sc_log(ctx, "'%s' before=0x%08X now=0x%08X", + rsp->szReader, + (unsigned int)rsp->dwCurrentState, + (unsigned int)rsp->dwEventState); prev_state = rsp->dwCurrentState; state = rsp->dwEventState; rsp->dwCurrentState = rsp->dwEventState; @@ -2372,7 +2387,9 @@ int cardmod_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcs gpriv->pcsc_ctx = *(SCARDCONTEXT *)pcsc_context_handle; card_handle = *(SCARDHANDLE *)pcsc_card_handle; - sc_log(ctx, "gpriv->pcsc_ctx = %X, card_handle = %X", gpriv->pcsc_ctx, card_handle); + sc_log(ctx, "gpriv->pcsc_ctx = %llX, card_handle = %llX", + (unsigned long long)gpriv->pcsc_ctx, + (unsigned long long)card_handle); if(gpriv->SCardGetAttrib(card_handle, SCARD_ATTR_DEVICE_SYSTEM_NAME_A, \ reader_name, &reader_name_size) == SCARD_S_SUCCESS) @@ -2420,7 +2437,7 @@ int cardmod_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcs &state, &prot, atr, &atr_len); if (rv != SCARD_S_SUCCESS) { - sc_log(ctx, "SCardStatus failed %08x", rv); + sc_log(ctx, "SCardStatus failed %08lx", rv); prot = SCARD_PROTOCOL_T0; } sc_log(ctx, "Set protocole to %s", \ @@ -2440,7 +2457,7 @@ int cardmod_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcs rv = gpriv->SCardControl(card_handle, CM_IOCTL_GET_FEATURE_REQUEST, NULL, 0, feature_buf, sizeof(feature_buf), &feature_len); if (rv != SCARD_S_SUCCESS) { - sc_log(ctx, "SCardControl failed %08x", rv); + sc_log(ctx, "SCardControl failed %08lx", rv); } else { @@ -2536,7 +2553,10 @@ int cardmod_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcs } else { - sc_log(ctx, "Returned PIN properties structure has bad length (%d/%d)", rcount, sizeof(PIN_PROPERTIES_STRUCTURE)); + sc_log(ctx, + "Returned PIN properties structure has bad length (%lu/%"SC_FORMAT_LEN_SIZE_T"u)", + (unsigned long)rcount, + sizeof(PIN_PROPERTIES_STRUCTURE)); } } } diff --git a/src/pkcs11/debug.c b/src/pkcs11/debug.c index 075cee03..bb3b1806 100644 --- a/src/pkcs11/debug.c +++ b/src/pkcs11/debug.c @@ -200,14 +200,14 @@ static void sc_pkcs11_print_attr(int level, const char *file, unsigned int line, if (fm == NULL) { sc_do_log(context, level, - file, line, function, - "%s: Attribute 0x%x = %s\n", - info, attr->type, value); + file, line, function, + "%s: Attribute 0x%lx = %s\n", + info, attr->type, value); } else { sc_do_log(context, level, - file, line, function, - "%s: %s = %s\n", - info, fm->name, value); + file, line, function, + "%s: %s = %s\n", + info, fm->name, value); } } diff --git a/src/pkcs11/framework-pkcs15.c b/src/pkcs11/framework-pkcs15.c index 545a22fc..3aece48c 100644 --- a/src/pkcs11/framework-pkcs15.c +++ b/src/pkcs11/framework-pkcs15.c @@ -289,7 +289,8 @@ pkcs15_bind(struct sc_pkcs11_card *p11card, struct sc_app_info *app_info) if (!p11card->nmechanisms) { ck_rv = register_mechanisms(p11card); if (ck_rv != CKR_OK) { - sc_log(context, "cannot register mechanisms; CKR 0x%X", ck_rv); + sc_log(context, "cannot register mechanisms; CKR 0x%lX", + ck_rv); return ck_rv; } } @@ -482,7 +483,7 @@ CK_RV C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo) rv = slot_get_token(slotID, &slot); if (rv != CKR_OK) { - sc_log(context, "C_GetTokenInfo() get token: rv 0x%X", rv); + sc_log(context, "C_GetTokenInfo() get token: rv 0x%lX", rv); goto out; } @@ -497,7 +498,9 @@ CK_RV C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo) /* User PIN flags are cleared before re-calculation */ slot->token_info.flags &= ~(CKF_USER_PIN_COUNT_LOW|CKF_USER_PIN_FINAL_TRY|CKF_USER_PIN_LOCKED); auth = slot_data_auth(slot->fw_data); - sc_log(context, "C_GetTokenInfo() auth. object %p, token-info flags 0x%X", auth, slot->token_info.flags); + sc_log(context, + "C_GetTokenInfo() auth. object %p, token-info flags 0x%lX", auth, + slot->token_info.flags); if (auth) { pin_info = (struct sc_pkcs15_auth_info*) auth->data; @@ -893,7 +896,8 @@ pkcs15_add_object(struct sc_pkcs11_slot *slot, struct pkcs15_any_object *obj, *pHandle = handle; list_append(&slot->objects, obj); - sc_log(context, "Slot:%X Setting object handle of 0x%lx to 0x%lx", slot->id, obj->base.handle, handle); + sc_log(context, "Slot:%lX Setting object handle of 0x%lx to 0x%lx", + slot->id, obj->base.handle, handle); obj->base.handle = handle; obj->base.flags |= SC_PKCS11_OBJECT_SEEN; obj->refcount++; @@ -1828,7 +1832,8 @@ pkcs15_init_pin(struct sc_pkcs11_slot *slot, CK_CHAR_PTR pPin, CK_ULONG ulPinLen return sc_to_cryptoki_error(rc, "C_InitPin"); } - sc_log(context, "Init PIN: pin %p:%d; unblock style %i", pPin, ulPinLen, sc_pkcs11_conf.pin_unblock_style); + sc_log(context, "Init PIN: pin %p:%lu; unblock style %i", pPin, + ulPinLen, sc_pkcs11_conf.pin_unblock_style); fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx]; if (!fw_data) @@ -2597,7 +2602,9 @@ get_X509_usage_privk(CK_ATTRIBUTE_PTR pTempl, CK_ULONG ulCount, unsigned long *x if (typ == CKA_OPENSC_NON_REPUDIATION && *val) *x509_usage |= SC_PKCS15INIT_X509_NON_REPUDIATION; if (typ == CKA_VERIFY || typ == CKA_WRAP || typ == CKA_ENCRYPT) { - sc_log(context, "get_X509_usage_privk(): invalid typ = 0x%0x", typ); + sc_log(context, + "get_X509_usage_privk(): invalid typ = 0x%0lx", + typ); return CKR_ATTRIBUTE_TYPE_INVALID; } } @@ -2623,7 +2630,9 @@ get_X509_usage_pubk(CK_ATTRIBUTE_PTR pTempl, CK_ULONG ulCount, unsigned long *x5 if (typ == CKA_DERIVE && *val) *x509_usage |= SC_PKCS15INIT_X509_KEY_AGREEMENT; if (typ == CKA_SIGN || typ == CKA_UNWRAP || typ == CKA_DECRYPT) { - sc_log(context, "get_X509_usage_pubk(): invalid typ = 0x%0x", typ); + sc_log(context, + "get_X509_usage_pubk(): invalid typ = 0x%0lx", + typ); return CKR_ATTRIBUTE_TYPE_INVALID; } } @@ -2693,7 +2702,8 @@ pkcs15_gen_keypair(struct sc_pkcs11_slot *slot, CK_MECHANISM_PTR pMechanism, char priv_label[SC_PKCS15_MAX_LABEL_SIZE]; int rc, rv = CKR_OK; - sc_log(context, "Keypair generation, mech = 0x%0x", pMechanism->mechanism); + sc_log(context, "Keypair generation, mech = 0x%0lx", + pMechanism->mechanism); if (pMechanism->mechanism != CKM_RSA_PKCS_KEY_PAIR_GEN && pMechanism->mechanism != CKM_GOSTR3410_KEY_PAIR_GEN @@ -3511,7 +3521,8 @@ pkcs15_prkey_sign(struct sc_pkcs11_session *session, void *obj, unsigned sign_flags = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_SIGNRECOVER | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION; - sc_log(context, "Initiating signing operation, mechanism 0x%x.",pMechanism->mechanism); + sc_log(context, "Initiating signing operation, mechanism 0x%lx.", + pMechanism->mechanism); fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx]; if (!fw_data) return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_Sign"); @@ -3564,7 +3575,7 @@ pkcs15_prkey_sign(struct sc_pkcs11_session *session, void *obj, flags = SC_ALGORITHM_ECDSA_HASH_SHA1; break; default: - sc_log(context, "DEE - need EC for %d",pMechanism->mechanism); + sc_log(context, "DEE - need EC for %lu", pMechanism->mechanism); return CKR_MECHANISM_INVALID; } @@ -3572,7 +3583,9 @@ pkcs15_prkey_sign(struct sc_pkcs11_session *session, void *obj, if (rv < 0) return sc_to_cryptoki_error(rv, "C_Sign"); - sc_log(context, "Selected flags %X. Now computing signature for %d bytes. %d bytes reserved.", flags, ulDataLen, *pulDataLen); + sc_log(context, + "Selected flags %X. Now computing signature for %lu bytes. %lu bytes reserved.", + flags, ulDataLen, *pulDataLen); rv = sc_pkcs15_compute_signature(fw_data->p15_card, prkey->prv_p15obj, flags, pData, ulDataLen, pSignature, *pulDataLen); if (rv < 0 && !sc_pkcs11_conf.lock_login && !prkey_has_path) { @@ -3691,7 +3704,8 @@ pkcs15_prkey_derive(struct sc_pkcs11_session *session, void *obj, if (!fw_data) return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_DeriveKey"); - sc_log(context, "derivation %p %p %p %p %d %p %d", session, obj, pMechanism, pParameters, ulParametersLen, pData, *pulDataLen); + sc_log(context, "derivation %p %p %p %p %lu %p %lu", session, obj, + pMechanism, pParameters, ulParametersLen, pData, *pulDataLen); /* See which of the alternative keys supports derivation */ while (prkey && !(prkey->prv_info->usage & SC_PKCS15_PRKEY_USAGE_DERIVE)) @@ -4086,7 +4100,9 @@ data_value_to_attr(CK_ATTRIBUTE_PTR attr, struct sc_pkcs15_data *data) if (!attr || !data) return CKR_ATTRIBUTE_VALUE_INVALID; - sc_log(context, "data_value_to_attr(): data(%p,len:%i)", data, data->data_len); + sc_log(context, + "data_value_to_attr(): data(%p,len:%"SC_FORMAT_LEN_SIZE_T"u)", + data, data->data_len); check_attribute_buffer(attr, data->data_len); memcpy(attr->pValue, data->data, data->data_len); diff --git a/src/pkcs11/mechanism.c b/src/pkcs11/mechanism.c index f6e7b1cd..827857b4 100644 --- a/src/pkcs11/mechanism.c +++ b/src/pkcs11/mechanism.c @@ -252,7 +252,8 @@ sc_pkcs11_sign_init(struct sc_pkcs11_session *session, CK_MECHANISM_PTR pMechani LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD); /* See if we support this mechanism type */ - sc_log(context, "mechanism 0x%X, key-type 0x%X", pMechanism->mechanism, key_type); + sc_log(context, "mechanism 0x%lX, key-type 0x%lX", + pMechanism->mechanism, key_type); mt = sc_pkcs11_find_mechanism(p11card, pMechanism->mechanism, CKF_SIGN); if (mt == NULL) LOG_FUNC_RETURN(context, CKR_MECHANISM_INVALID); diff --git a/src/pkcs11/openssl.c b/src/pkcs11/openssl.c index a1a412e5..d16d3290 100644 --- a/src/pkcs11/openssl.c +++ b/src/pkcs11/openssl.c @@ -286,8 +286,8 @@ static CK_RV sc_pkcs11_openssl_md_final(sc_pkcs11_operation_t *op, EVP_MD_CTX *md_ctx = DIGEST_CTX(op); if (*pulDigestLen < (unsigned) EVP_MD_CTX_size(md_ctx)) { - sc_log(context, "Provided buffer too small: %ul < %d", - *pulDigestLen, EVP_MD_CTX_size(md_ctx)); + sc_log(context, "Provided buffer too small: %lu < %d", + *pulDigestLen, EVP_MD_CTX_size(md_ctx)); *pulDigestLen = EVP_MD_CTX_size(md_ctx); return CKR_BUFFER_TOO_SMALL; } diff --git a/src/pkcs11/pkcs11-global.c b/src/pkcs11/pkcs11-global.c index 9fd0f099..7a45531c 100644 --- a/src/pkcs11/pkcs11-global.c +++ b/src/pkcs11/pkcs11-global.c @@ -423,14 +423,14 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese } if (pSlotList == NULL_PTR) { - sc_log(context, "was only a size inquiry (%d)\n", numMatches); + sc_log(context, "was only a size inquiry (%lu)\n", numMatches); *pulCount = numMatches; rv = CKR_OK; goto out; } if (*pulCount < numMatches) { - sc_log(context, "buffer was too small (needed %d)\n", numMatches); + sc_log(context, "buffer was too small (needed %lu)\n", numMatches); *pulCount = numMatches; rv = CKR_BUFFER_TOO_SMALL; goto out; @@ -440,7 +440,7 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese *pulCount = numMatches; rv = CKR_OK; - sc_log(context, "returned %d slots\n", numMatches); + sc_log(context, "returned %lu slots\n", numMatches); out: if (found != NULL) { @@ -503,7 +503,7 @@ CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) } rv = slot_get_slot(slotID, &slot); - sc_log(context, "C_GetSlotInfo() get slot rv %i", rv); + sc_log(context, "C_GetSlotInfo() get slot rv %lu", rv); if (rv == CKR_OK) { if (slot->reader == NULL) { rv = CKR_TOKEN_NOT_PRESENT; @@ -513,7 +513,7 @@ CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) if (now >= slot->slot_state_expires || now == 0) { /* Update slot status */ rv = card_detect(slot->reader); - sc_log(context, "C_GetSlotInfo() card detect rv 0x%X", rv); + sc_log(context, "C_GetSlotInfo() card detect rv 0x%lX", rv); if (rv == CKR_TOKEN_NOT_RECOGNIZED || rv == CKR_OK) slot->slot_info.flags |= CKF_TOKEN_PRESENT; @@ -530,7 +530,7 @@ CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) if (rv == CKR_OK) memcpy(pInfo, &slot->slot_info, sizeof(CK_SLOT_INFO)); - sc_log(context, "C_GetSlotInfo() flags 0x%X", pInfo->flags); + sc_log(context, "C_GetSlotInfo() flags 0x%lX", pInfo->flags); sc_log(context, "C_GetSlotInfo(0x%lx) = %s", slotID, lookup_enum( RV_T, rv)); sc_pkcs11_unlock(); return rv; diff --git a/src/pkcs11/pkcs11-object.c b/src/pkcs11/pkcs11-object.c index 6e8d648b..e5125e13 100644 --- a/src/pkcs11/pkcs11-object.c +++ b/src/pkcs11/pkcs11-object.c @@ -333,7 +333,7 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */ if (rv != CKR_OK) goto out; - sc_log(context, "C_FindObjectsInit(slot = %d)\n", session->slot->id); + sc_log(context, "C_FindObjectsInit(slot = %lu)\n", session->slot->id); dump_template(SC_LOG_DEBUG_NORMAL, "C_FindObjectsInit()", pTemplate, ulCount); rv = session_start_operation(session, SC_PKCS11_OPERATION_FIND, @@ -362,8 +362,9 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */ if (object->ops->get_attribute(session, object, &private_attribute) != CKR_OK) continue; if (is_private) { - sc_log(context, "Object %d/%d: Private object and not logged in.", - slot->id, object->handle); + sc_log(context, + "Object %lu/%lu: Private object and not logged in.", + slot->id, object->handle); continue; } } @@ -373,20 +374,23 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */ for (j = 0; j < ulCount; j++) { rv = object->ops->cmp_attribute(session, object, &pTemplate[j]); if (rv == 0) { - sc_log(context, "Object %d/%d: Attribute 0x%x does NOT match.", - slot->id, object->handle, pTemplate[j].type); + sc_log(context, + "Object %lu/%lu: Attribute 0x%lx does NOT match.", + slot->id, object->handle, pTemplate[j].type); match = 0; break; } if (context->debug >= 4) { - sc_log(context, "Object %d/%d: Attribute 0x%x matches.", - slot->id, object->handle, pTemplate[j].type); + sc_log(context, + "Object %lu/%lu: Attribute 0x%lx matches.", + slot->id, object->handle, pTemplate[j].type); } } if (match) { - sc_log(context, "Object %d/%d matches\n", slot->id, object->handle); + sc_log(context, "Object %lu/%lu matches\n", slot->id, + object->handle); /* Realloc handles - remove restriction on only 32 matching objects -dee */ if (operation->num_handles >= operation->allocated_handles) { operation->allocated_handles += SC_PKCS11_FIND_INC_HANDLES; diff --git a/src/pkcs11/pkcs11-session.c b/src/pkcs11/pkcs11-session.c index af42b303..d088b2bc 100644 --- a/src/pkcs11/pkcs11-session.c +++ b/src/pkcs11/pkcs11-session.c @@ -273,7 +273,7 @@ CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */ goto out; } - sc_log(context, "C_Login(0x%lx, %d)", hSession, userType); + sc_log(context, "C_Login(0x%lx, %lu)", hSession, userType); slot = session->slot; @@ -295,7 +295,7 @@ CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */ } } else { - sc_log(context, "C_Login() slot->login_user %li", slot->login_user); + sc_log(context, "C_Login() slot->login_user %i", slot->login_user); if (slot->login_user >= 0) { if ((CK_USER_TYPE) slot->login_user == userType) rv = CKR_USER_ALREADY_LOGGED_IN; diff --git a/src/pkcs11/slot.c b/src/pkcs11/slot.c index 24891ef3..5b368511 100644 --- a/src/pkcs11/slot.c +++ b/src/pkcs11/slot.c @@ -329,14 +329,18 @@ again: rv = CKR_OK; } if (rv != CKR_OK) { - sc_log(context, "%s: cannot bind 'generic' token: rv 0x%X", reader->name, rv); + sc_log(context, + "%s: cannot bind 'generic' token: rv 0x%lX", + reader->name, rv); return rv; } sc_log(context, "%s: Creating 'generic' token.", reader->name); rv = frameworks[i]->create_tokens(p11card, app_generic); if (rv != CKR_OK) { - sc_log(context, "%s: create 'generic' token error 0x%X", reader->name, rv); + sc_log(context, + "%s: create 'generic' token error 0x%lX", + reader->name, rv); return rv; } } @@ -352,14 +356,17 @@ again: sc_log(context, "%s: Binding %s token.", reader->name, app_name); rv = frameworks[i]->bind(p11card, app_info); if (rv != CKR_OK) { - sc_log(context, "%s: bind %s token error Ox%X", reader->name, app_name, rv); + sc_log(context, "%s: bind %s token error Ox%lX", + reader->name, app_name, rv); continue; } sc_log(context, "%s: Creating %s token.", reader->name, app_name); rv = frameworks[i]->create_tokens(p11card, app_info); if (rv != CKR_OK) { - sc_log(context, "%s: create %s token error 0x%X", reader->name, app_name, rv); + sc_log(context, + "%s: create %s token error 0x%lX", + reader->name, app_name, rv); return rv; } } @@ -509,7 +516,9 @@ CK_RV slot_find_changed(CK_SLOT_ID_PTR idp, int mask) card_detect_all(); for (i=0; iid, (slot->slot_info.flags & CKF_TOKEN_PRESENT), slot->events); + sc_log(context, "slot 0x%lx token: %lu events: 0x%02X", + slot->id, (slot->slot_info.flags & CKF_TOKEN_PRESENT), + slot->events); if ((slot->events & SC_EVENT_CARD_INSERTED) && !(slot->slot_info.flags & CKF_TOKEN_PRESENT)) { /* If a token has not been initialized, clear the inserted event */ diff --git a/src/pkcs15init/pkcs15-authentic.c b/src/pkcs15init/pkcs15-authentic.c index ec7df8ea..ccc22c84 100644 --- a/src/pkcs15init/pkcs15-authentic.c +++ b/src/pkcs15init/pkcs15-authentic.c @@ -254,8 +254,9 @@ authentic_pkcs15_new_file(struct sc_profile *profile, struct sc_card *card, file->path.count = -1; } - sc_log(ctx, "file(size:%i,type:%i/%i,id:%04X), path(type:%X,'%s')", file->size, file->type, file->ef_structure, file->id, - file->path.type, sc_print_path(&file->path)); + sc_log(ctx, "file(size:%"SC_FORMAT_LEN_SIZE_T"u,type:%i/%i,id:%04X), path(type:%X,'%s')", + file->size, file->type, file->ef_structure, file->id, + file->path.type, sc_print_path(&file->path)); if (out) *out = file; else @@ -525,8 +526,10 @@ authentic_pkcs15_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "create private key(keybits:%i,usage:%X,access:%X,ref:%X)", keybits, - key_info->usage, key_info->access_flags, key_info->key_reference); + sc_log(ctx, + "create private key(keybits:%"SC_FORMAT_LEN_SIZE_T"u,usage:%X,access:%X,ref:%X)", + keybits, key_info->usage, key_info->access_flags, + key_info->key_reference); if (keybits < 1024 || keybits > 2048 || (keybits % 256)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid RSA key size"); @@ -604,8 +607,10 @@ authentic_pkcs15_generate_key(struct sc_profile *profile, sc_pkcs15_card_t *p15c int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "generate key(bits:%i,path:%s,AuthID:%s\n", keybits, - sc_print_path(&key_info->path), sc_pkcs15_print_id(&object->auth_id)); + sc_log(ctx, + "generate key(bits:%"SC_FORMAT_LEN_SIZE_T"u,path:%s,AuthID:%s\n", + keybits, sc_print_path(&key_info->path), + sc_pkcs15_print_id(&object->auth_id)); if (!object->content.value || object->content.len != sizeof(struct sc_authentic_sdo)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data"); @@ -669,8 +674,10 @@ authentic_pkcs15_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p1 int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "Store IAS/ECC key(keybits:%i,AuthID:%s,path:%s)", - keybits, sc_pkcs15_print_id(&object->auth_id), sc_print_path(&key_info->path)); + sc_log(ctx, + "Store IAS/ECC key(keybits:%"SC_FORMAT_LEN_SIZE_T"u,AuthID:%s,path:%s)", + keybits, sc_pkcs15_print_id(&object->auth_id), + sc_print_path(&key_info->path)); if (!object->content.value || object->content.len != sizeof(struct sc_authentic_sdo)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data"); @@ -716,7 +723,8 @@ authentic_pkcs15_delete_rsa_sdo (struct sc_profile *profile, struct sc_pkcs15_ca int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "delete SDO RSA key (ref:%i,size:%i)", key_info->key_reference, key_info->modulus_length); + sc_log(ctx, "delete SDO RSA key (ref:%i,size:%"SC_FORMAT_LEN_SIZE_T"u)", + key_info->key_reference, key_info->modulus_length); rv = authentic_pkcs15_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file); LOG_TEST_GOTO_ERR(ctx, rv, "PRKEY_RSA instantiation file error"); diff --git a/src/pkcs15init/pkcs15-cardos.c b/src/pkcs15init/pkcs15-cardos.c index 2789ad38..1fd5e31c 100644 --- a/src/pkcs15init/pkcs15-cardos.c +++ b/src/pkcs15init/pkcs15-cardos.c @@ -481,8 +481,9 @@ 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, "invalid pin length: %u (max %u)\n", - pin_len, maxlen); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "invalid pin length: %"SC_FORMAT_LEN_SIZE_T"u (max %u)\n", + pin_len, maxlen); return SC_ERROR_INVALID_ARGUMENTS; } memcpy(pinpadded, pin, pin_len); diff --git a/src/pkcs15init/pkcs15-cflex.c b/src/pkcs15init/pkcs15-cflex.c index e25d8729..4117e146 100644 --- a/src/pkcs15init/pkcs15-cflex.c +++ b/src/pkcs15init/pkcs15-cflex.c @@ -289,8 +289,9 @@ 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, "Unsupported key size %u\n", - key_info->modulus_length); + sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, + "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + key_info->modulus_length); r = SC_ERROR_INVALID_ARGUMENTS; goto out; } diff --git a/src/pkcs15init/pkcs15-entersafe.c b/src/pkcs15init/pkcs15-entersafe.c index 12611179..712a02f3 100644 --- a/src/pkcs15init/pkcs15-entersafe.c +++ b/src/pkcs15init/pkcs15-entersafe.c @@ -363,10 +363,10 @@ static int entersafe_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, ( keybits > 2048 ) || ( keybits % 0x20 ) ) { - sc_debug( card->ctx, - SC_LOG_DEBUG_NORMAL, - "Unsupported key size %u\n", - keybits ); + sc_debug(card->ctx, + SC_LOG_DEBUG_NORMAL, + "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + keybits); return SC_ERROR_INVALID_ARGUMENTS; } @@ -413,10 +413,10 @@ static int entersafe_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15ca ( keybits > 2048 ) || ( keybits % 0x20 ) ) { - sc_debug( card->ctx, - SC_LOG_DEBUG_NORMAL, - "Unsupported key size %u\n", - keybits ); + sc_debug(card->ctx, + SC_LOG_DEBUG_NORMAL, + "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + keybits); return SC_ERROR_INVALID_ARGUMENTS; } diff --git a/src/pkcs15init/pkcs15-epass2003.c b/src/pkcs15init/pkcs15-epass2003.c index f639addf..3be5ab85 100644 --- a/src/pkcs15init/pkcs15-epass2003.c +++ b/src/pkcs15init/pkcs15-epass2003.c @@ -371,7 +371,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card, file->ef_structure = structure; sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "file size %i; ef type %i/%i; id %04X, path_len %i\n", + "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", @@ -410,7 +410,8 @@ 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, "index %i; id %s\n", idx, + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "index %"SC_FORMAT_LEN_SIZE_T"u; id %s\n", idx, sc_pkcs15_print_id(&key_info->id)); if (key->algorithm != SC_ALGORITHM_RSA || key->algorithm != SC_ALGORITHM_RSA) @@ -439,11 +440,13 @@ 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, "index %i; keybits %i\n", idx, - keybits); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "index %"SC_FORMAT_LEN_SIZE_T"u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n", + idx, keybits); if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) { sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, - "Unsupported key size %u\n", keybits); + "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + keybits); return SC_ERROR_INVALID_ARGUMENTS; } @@ -518,11 +521,13 @@ 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, "index %i; keybits %i\n", idx, - keybits); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "index %"SC_FORMAT_LEN_SIZE_T"u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n", + idx, keybits); if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) { sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, - "Unsupported key size %u\n", keybits); + "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + keybits); r = SC_ERROR_INVALID_ARGUMENTS; goto err; } @@ -555,7 +560,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile, + pukf->path.value[pukf->path.len - 1]; sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, - "public key size %i; ef type %i/%i; id %04X; path: %s", + "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)); diff --git a/src/pkcs15init/pkcs15-gpk.c b/src/pkcs15init/pkcs15-gpk.c index edb06794..ac9ba210 100644 --- a/src/pkcs15init/pkcs15-gpk.c +++ b/src/pkcs15init/pkcs15-gpk.c @@ -518,8 +518,10 @@ 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, "path=%s, %d bits\n", sc_print_path(&key_info->path), - key_info->modulus_length); + sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, + "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."); diff --git a/src/pkcs15init/pkcs15-iasecc.c b/src/pkcs15init/pkcs15-iasecc.c index 26694cfa..ce2e8e3f 100644 --- a/src/pkcs15init/pkcs15-iasecc.c +++ b/src/pkcs15init/pkcs15-iasecc.c @@ -241,7 +241,9 @@ iasecc_pkcs15_new_file(struct sc_profile *profile, struct sc_card *card, file->path.value[file->path.len - 1] = file->id & 0xFF; file->path.count = -1; - sc_log(ctx, "file size %i; ef type %i/%i; id %04X\n", file->size, file->type, file->ef_structure, file->id); + sc_log(ctx, + "file size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X\n", + file->size, file->type, file->ef_structure, file->id); sc_log(ctx, "path type %X; path '%s'", file->path.type, sc_print_path(&file->path)); if (out) @@ -430,8 +432,8 @@ iasecc_sdo_set_key_acls_from_profile(struct sc_profile *profile, struct sc_card *(sdo->docp.acls_contact.value + 0) = amb; memcpy(sdo->docp.acls_contact.value + 1, scb, cntr); - sc_log(ctx, "AMB: %X, CNTR %i, %x %x %x %x %x %x", - amb, cntr, scb[0], scb[1], scb[2], scb[3], scb[4], scb[5], scb[6]); + sc_log(ctx, "AMB: %X, CNTR %i, %x %x %x %x %x %x %x", + amb, cntr, scb[0], scb[1], scb[2], scb[3], scb[4], scb[5], scb[6]); LOG_FUNC_RETURN(ctx, SC_SUCCESS); } @@ -914,8 +916,10 @@ iasecc_pkcs15_fix_private_key_attributes(struct sc_profile *profile, struct sc_p sc_log(ctx, "SDO(class:%X,ref:%X,usage:%X)", sdo_prvkey->sdo_class, sdo_prvkey->sdo_ref, sdo_prvkey->usage); - sc_log(ctx, "SDO ACLs(%i):%s", sdo_prvkey->docp.acls_contact.size, - sc_dump_hex(sdo_prvkey->docp.acls_contact.value, sdo_prvkey->docp.acls_contact.size)); + sc_log(ctx, "SDO ACLs(%"SC_FORMAT_LEN_SIZE_T"u):%s", + sdo_prvkey->docp.acls_contact.size, + sc_dump_hex(sdo_prvkey->docp.acls_contact.value, + sdo_prvkey->docp.acls_contact.size)); sc_log(ctx, "SDO AMB:%X, SCBS:%s", sdo_prvkey->docp.amb, sc_dump_hex(sdo_prvkey->docp.scbs, IASECC_MAX_SCBS)); @@ -1052,10 +1056,13 @@ iasecc_pkcs15_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15c int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "create private key(keybits:%i,usage:%X,access:%X,ref:%X)", - keybits, key_info->usage, key_info->access_flags, key_info->key_reference); + sc_log(ctx, + "create private key(keybits:%"SC_FORMAT_LEN_SIZE_T"u,usage:%X,access:%X,ref:%X)", + keybits, key_info->usage, key_info->access_flags, + key_info->key_reference); if (keybits < 1024 || keybits > 2048 || (keybits % 256)) { - sc_log(ctx, "Unsupported key size %u", keybits); + sc_log(ctx, "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u", + keybits); return SC_ERROR_INVALID_ARGUMENTS; } @@ -1111,8 +1118,10 @@ iasecc_pkcs15_generate_key(struct sc_profile *profile, sc_pkcs15_card_t *p15card int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "generate key(bits:%i,path:%s,AuthID:%s\n", keybits, - sc_print_path(&key_info->path), sc_pkcs15_print_id(&object->auth_id)); + sc_log(ctx, + "generate key(bits:%"SC_FORMAT_LEN_SIZE_T"u,path:%s,AuthID:%s\n", + keybits, sc_print_path(&key_info->path), + sc_pkcs15_print_id(&object->auth_id)); if (!object->content.value || object->content.len != sizeof(struct iasecc_sdo)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data"); @@ -1122,7 +1131,8 @@ iasecc_pkcs15_generate_key(struct sc_profile *profile, sc_pkcs15_card_t *p15card LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "'Magic' control failed for SDO PrvKey"); if (keybits < 1024 || keybits > 2048 || (keybits%0x100)) { - sc_log(ctx, "Unsupported key size %u\n", keybits); + sc_log(ctx, "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + keybits); return SC_ERROR_INVALID_ARGUMENTS; } @@ -1204,8 +1214,10 @@ iasecc_pkcs15_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15ca int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "Store IAS/ECC key(keybits:%i,AuthID:%s,path:%s)", - keybits, sc_pkcs15_print_id(&object->auth_id), sc_print_path(&key_info->path)); + sc_log(ctx, + "Store IAS/ECC key(keybits:%"SC_FORMAT_LEN_SIZE_T"u,AuthID:%s,path:%s)", + keybits, sc_pkcs15_print_id(&object->auth_id), + sc_print_path(&key_info->path)); if (!object->content.value || object->content.len != sizeof(struct iasecc_sdo)) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data"); @@ -1216,8 +1228,10 @@ iasecc_pkcs15_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15ca if (sdo_prvkey->magic != SC_CARDCTL_IASECC_SDO_MAGIC) LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "'Magic' control failed for SDO PrvKey"); - sc_log(ctx, "key compulsory attr(size:%i,on_card:%i)", - sdo_prvkey->data.prv_key.compulsory.size, sdo_prvkey->data.prv_key.compulsory.on_card); + sc_log(ctx, + "key compulsory attr(size:%"SC_FORMAT_LEN_SIZE_T"u,on_card:%i)", + sdo_prvkey->data.prv_key.compulsory.size, + sdo_prvkey->data.prv_key.compulsory.on_card); rv = sc_profile_get_parent(profile, "private-key", &file); LOG_TEST_RET(ctx, rv, "cannot instantiate parent DF of the private key"); diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c index c2fc2df2..97db6e0f 100644 --- a/src/pkcs15init/pkcs15-lib.c +++ b/src/pkcs15init/pkcs15-lib.c @@ -1741,8 +1741,10 @@ sc_pkcs15init_store_certificate(struct sc_pkcs15_card *p15card, cert_info->path = existing_path; } - sc_log(ctx, "Store cert(%.*s,ID:%s,der(%p,%i))", (int) sizeof object->label, object->label, - sc_pkcs15_print_id(&cert_info->id), args->der_encoded.value, args->der_encoded.len); + sc_log(ctx, "Store cert(%.*s,ID:%s,der(%p,%"SC_FORMAT_LEN_SIZE_T"u))", + (int) sizeof object->label, object->label, + sc_pkcs15_print_id(&cert_info->id), args->der_encoded.value, + args->der_encoded.len); if (!profile->pkcs15.direct_certificates) r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &cert_info->path); @@ -2273,12 +2275,15 @@ prkey_bits(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey *key) return sc_pkcs15init_keybits(&key->u.dsa.q); case SC_ALGORITHM_GOSTR3410: if (sc_pkcs15init_keybits(&key->u.gostr3410.d) > SC_PKCS15_GOSTR3410_KEYSIZE) { - sc_log(ctx, "Unsupported key (keybits %u)", sc_pkcs15init_keybits(&key->u.gostr3410.d)); + sc_log(ctx, + "Unsupported key (keybits %"SC_FORMAT_LEN_SIZE_T"u)", + sc_pkcs15init_keybits(&key->u.gostr3410.d)); return SC_ERROR_OBJECT_NOT_VALID; } return SC_PKCS15_GOSTR3410_KEYSIZE; case SC_ALGORITHM_EC: - sc_log(ctx, "Private EC key length %u", key->u.ec.params.field_length); + sc_log(ctx, "Private EC key length %"SC_FORMAT_LEN_SIZE_T"u", + key->u.ec.params.field_length); if (key->u.ec.params.field_length == 0) { sc_log(ctx, "Invalid EC key length"); return SC_ERROR_OBJECT_NOT_VALID; @@ -2597,7 +2602,8 @@ select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile, if (!name) LOG_FUNC_RETURN(ctx, SC_SUCCESS); - sc_log(ctx, "key-domain.%s @%s (auth_id.len=%d)", name, sc_print_path(path), obj->auth_id.len); + sc_log(ctx, "key-domain.%s @%s (auth_id.len=%"SC_FORMAT_LEN_SIZE_T"u)", + name, sc_print_path(path), obj->auth_id.len); indx_id.len = 1; for (indx = TEMPLATE_INSTANTIATE_MIN_INDEX; indx <= TEMPLATE_INSTANTIATE_MAX_INDEX; indx++) { @@ -3391,7 +3397,7 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p LOG_FUNC_RETURN(ctx, SC_SUCCESS); reference = pin_id; type = SC_AC_CHV; - sc_log(ctx, "Symbolic PIN resolved to PIN(type:CHV,reference:%i)", type, reference); + sc_log(ctx, "Symbolic PIN resolved to PIN(type:CHV,reference:%i)", reference); } if (path && path->len) { @@ -3414,7 +3420,10 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p } if (pin_obj) { - sc_log(ctx, "PIN object '%.*s'; pin_obj->content.len:%i", (int) sizeof pin_obj->label, pin_obj->label, pin_obj->content.len); + sc_log(ctx, + "PIN object '%.*s'; pin_obj->content.len:%"SC_FORMAT_LEN_SIZE_T"u", + (int) sizeof pin_obj->label, pin_obj->label, + pin_obj->content.len); if (pin_obj->content.value && pin_obj->content.len) { if (pin_obj->content.len > sizeof(pinbuf)) LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "PIN buffer is too small"); @@ -3433,7 +3442,9 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p if (callbacks.get_pin) { pinsize = sizeof(pinbuf); r = callbacks.get_pin(profile, pin_id, &auth_info, label, pinbuf, &pinsize); - sc_log(ctx, "'get_pin' callback returned %i; pinsize:%i", r, pinsize); + sc_log(ctx, + "'get_pin' callback returned %i; pinsize:%"SC_FORMAT_LEN_SIZE_T"u", + r, pinsize); } break; case SC_AC_SCB: @@ -3667,8 +3678,10 @@ sc_pkcs15init_update_file(struct sc_profile *profile, } if (selected_file->size < datalen) { - sc_log(ctx, "File %s too small (require %u, have %u)", - sc_print_path(&file->path), datalen, selected_file->size); + sc_log(ctx, + "File %s too small (require %u, have %"SC_FORMAT_LEN_SIZE_T"u)", + sc_print_path(&file->path), datalen, + selected_file->size); sc_file_free(selected_file); LOG_TEST_RET(ctx, SC_ERROR_FILE_TOO_SMALL, "Update file failed"); } @@ -3896,11 +3909,15 @@ sc_pkcs15init_qualify_pin(struct sc_card *card, const char *pin_name, pin_attrs = &auth_info->attrs.pin; if (pin_len < pin_attrs->min_length) { - sc_log(ctx, "%s too short (min length %u)", pin_name, pin_attrs->min_length); + sc_log(ctx, + "%s too short (min length %"SC_FORMAT_LEN_SIZE_T"u)", + pin_name, pin_attrs->min_length); LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH); } if (pin_len > pin_attrs->max_length) { - sc_log(ctx, "%s too long (max length %u)", pin_name, pin_attrs->max_length); + sc_log(ctx, + "%s too long (max length %"SC_FORMAT_LEN_SIZE_T"u)", + pin_name, pin_attrs->max_length); LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH); } diff --git a/src/pkcs15init/pkcs15-myeid.c b/src/pkcs15init/pkcs15-myeid.c index 9ed515d8..1cacc56f 100644 --- a/src/pkcs15init/pkcs15-myeid.c +++ b/src/pkcs15init/pkcs15-myeid.c @@ -290,8 +290,10 @@ myeid_create_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card, int r; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "PIN('%s',ref:%i,flags:0x%X,pin_len:%d,puk_len:%d)\n", - pin_obj->label, auth_info->attrs.pin.reference, auth_info->attrs.pin.flags, pin_len, puk_len); + sc_log(ctx, + "PIN('%s',ref:%i,flags:0x%X,pin_len:%"SC_FORMAT_LEN_SIZE_T"u,puk_len:%"SC_FORMAT_LEN_SIZE_T"u)\n", + pin_obj->label, auth_info->attrs.pin.reference, + auth_info->attrs.pin.flags, pin_len, puk_len); if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN) return SC_ERROR_OBJECT_NOT_VALID; @@ -671,7 +673,10 @@ myeid_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card, else if (object->type == SC_PKCS15_TYPE_PRKEY_EC) { struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)key_info->params.data; - sc_log(ctx, "curve '%s', len %i, oid '%s'", ecparams->named_curve, ecparams->field_length, sc_dump_oid(&(ecparams->id))); + sc_log(ctx, + "curve '%s', len %"SC_FORMAT_LEN_SIZE_T"u, oid '%s'", + ecparams->named_curve, ecparams->field_length, + sc_dump_oid(&(ecparams->id))); pubkey->algorithm = SC_ALGORITHM_EC; r = sc_select_file(card, &file->path, NULL); diff --git a/src/pkcs15init/pkcs15-oberthur-awp.c b/src/pkcs15init/pkcs15-oberthur-awp.c index 83adcb0d..f55f3d33 100644 --- a/src/pkcs15init/pkcs15-oberthur-awp.c +++ b/src/pkcs15init/pkcs15-oberthur-awp.c @@ -170,8 +170,9 @@ 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, "info_file(id:%04X,size:%i,rlen:%i)", - ifile->id, ifile->size, ifile->record_length); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "info_file(id:%04X,size:%"SC_FORMAT_LEN_SIZE_T"u,rlen:%i)", + ifile->id, ifile->size, ifile->record_length); *info_out = ifile; } else { @@ -180,7 +181,9 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile, } if (ofile) { - sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj file %04X; size %i; ", ofile->id, ofile->size); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "obj file %04X; size %"SC_FORMAT_LEN_SIZE_T"u; ", + ofile->id, ofile->size); if (obj_out) *obj_out = ofile; else @@ -346,7 +349,9 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p unsigned char *buff = NULL; SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL); - sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry(type:%X,len:%i,count %i,rec %i,offs %i", type, file_id, rec, offs); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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)", list_file->id, list_file->record_length, list_file->record_count); @@ -724,7 +729,9 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil goto done; } - sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ii %i, rv %i; %X; %i", ii, rv, file->id, file->size); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "ii %i, rv %i; %X; %"SC_FORMAT_LEN_SIZE_T"u", + ii, rv, file->id, file->size); *(buff + ii) = COSM_LIST_TAG; *(buff + ii + 1) = (file->id >> 8) & 0xFF; *(buff + ii + 2) = file->id & 0xFF; @@ -775,12 +782,16 @@ 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, "cosm_encode_key_info() label(%i):%s",ki->label.len, ki->label.value); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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, "pubkey->modulus.len %i",pubkey->modulus.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "pubkey->modulus.len %"SC_FORMAT_LEN_SIZE_T"u", + pubkey->modulus.len); ki->modulus.value = malloc(pubkey->modulus.len); if (!ki->modulus.value) { r = SC_ERROR_OUT_OF_MEMORY; @@ -928,8 +939,10 @@ 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, "Encode cert(%s,id:%s,der(%p,%i))", obj->label, - sc_pkcs15_print_id(&cert_info->id), obj->content.value, obj->content.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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); memset(&pubkey, 0, sizeof(pubkey)); ci->label.value = (unsigned char *)strdup(obj->label); @@ -1095,8 +1108,10 @@ 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, "Encode data(%s,id:%s,der(%p,%i))", obj->label, - sc_pkcs15_print_id(&data_info->id), obj->content.value, obj->content.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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); di->flags = 0x0000; @@ -1370,7 +1385,8 @@ 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, "Cert Der(%p,%i)", der.value, der.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "Cert Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len); rv = awp_encode_cert_info(p15card, obj, &icert); SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot encode info"); @@ -1456,7 +1472,8 @@ 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, "PrKey Der(%p,%i)", der.value, der.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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"); @@ -1508,7 +1525,8 @@ 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, "PrKey Der(%p,%i)", der.value, der.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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"); @@ -1555,7 +1573,8 @@ 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, "Data Der(%p,%i)", der.value, der.len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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"); diff --git a/src/pkcs15init/pkcs15-oberthur.c b/src/pkcs15init/pkcs15-oberthur.c index 62154165..f090cd5e 100644 --- a/src/pkcs15init/pkcs15-oberthur.c +++ b/src/pkcs15init/pkcs15-oberthur.c @@ -276,7 +276,9 @@ 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, "pin lens %i/%i", pin_len, puk_len); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "pin lens %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u", + pin_len, puk_len); if (!pin || pin_len>0x40) return SC_ERROR_INVALID_ARGUMENTS; if (puk && !puk_len) @@ -534,8 +536,9 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card, file->ef_structure = structure; } - sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() file size %i; ef type %i/%i; id %04X",file->size, - file->type, file->ef_structure, file->id); + sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, + "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; SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS); diff --git a/src/pkcs15init/pkcs15-openpgp.c b/src/pkcs15init/pkcs15-openpgp.c index 95ba5ae4..4fcaec92 100644 --- a/src/pkcs15init/pkcs15-openpgp.c +++ b/src/pkcs15init/pkcs15-openpgp.c @@ -279,7 +279,9 @@ static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile r = sc_select_file(card, path, &file); LOG_TEST_RET(card->ctx, r, "Cannot select cert file"); r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE); - sc_log(card->ctx, "Data to write is %d long", content->len); + sc_log(card->ctx, + "Data to write is %"SC_FORMAT_LEN_SIZE_T"u long", + content->len); if (r >= 0 && content->len) r = sc_put_data(p15card->card, 0x7F21, (const unsigned char *) content->value, content->len); break; diff --git a/src/pkcs15init/pkcs15-rtecp.c b/src/pkcs15init/pkcs15-rtecp.c index 0e42c31c..d23d07a0 100644 --- a/src/pkcs15init/pkcs15-rtecp.c +++ b/src/pkcs15init/pkcs15-rtecp.c @@ -321,7 +321,9 @@ 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, "Unsupported key size %u\n", key_info->modulus_length); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n", + key_info->modulus_length); return SC_ERROR_INVALID_ARGUMENTS; } if (obj->type == SC_PKCS15_TYPE_PRKEY_GOSTR3410) diff --git a/src/pkcs15init/pkcs15-setcos.c b/src/pkcs15init/pkcs15-setcos.c index 9a29baea..0a00627e 100644 --- a/src/pkcs15init/pkcs15-setcos.c +++ b/src/pkcs15init/pkcs15-setcos.c @@ -486,8 +486,9 @@ 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, "key-size from card[%i] does not match[%i]\n", - keybits, key_info->modulus_length); + sc_debug(ctx, SC_LOG_DEBUG_NORMAL, + "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"); } memcpy (pubkey->u.rsa.modulus.data, &raw_pubkey[2], pubkey->u.rsa.modulus.len); diff --git a/src/sm/sm-common.c b/src/sm/sm-common.c index 144fe86d..49647b7a 100644 --- a/src/sm/sm-common.c +++ b/src/sm/sm-common.c @@ -308,7 +308,9 @@ sm_encrypt_des_cbc3(struct sc_context *ctx, unsigned char *key, size_t data_len, st; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM encrypt_des_cbc3: not_force_pad:%i,in_len:%i", not_force_pad, in_len); + sc_log(ctx, + "SM encrypt_des_cbc3: not_force_pad:%i,in_len:%"SC_FORMAT_LEN_SIZE_T"u", + not_force_pad, in_len); if (!out || !out_len) LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "SM encrypt_des_cbc3: invalid input arguments"); @@ -328,7 +330,9 @@ sm_encrypt_des_cbc3(struct sc_context *ctx, unsigned char *key, memcpy(data + in_len, "\x80\0\0\0\0\0\0\0", 8); data_len = in_len + (not_force_pad ? 7 : 8); data_len -= (data_len%8); - sc_log(ctx, "SM encrypt_des_cbc3: data to encrypt (len:%i,%s)", data_len, sc_dump_hex(data, data_len)); + sc_log(ctx, + "SM encrypt_des_cbc3: data to encrypt (len:%"SC_FORMAT_LEN_SIZE_T"u,%s)", + data_len, sc_dump_hex(data, data_len)); *out_len = data_len; *out = malloc(data_len + 8); diff --git a/src/smm/sm-card-authentic.c b/src/smm/sm-card-authentic.c index 77fe1d71..13cde7eb 100644 --- a/src/smm/sm-card-authentic.c +++ b/src/smm/sm-card-authentic.c @@ -143,7 +143,8 @@ sm_authentic_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, if (!sm_info) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "SM get APDUs: rdata:%p, init_len:%i", rdata, init_len); + sc_log(ctx, "SM get APDUs: rdata:%p, init_len:%"SC_FORMAT_LEN_SIZE_T"u", + rdata, init_len); sc_log(ctx, "SM get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len)); if (init_data) { diff --git a/src/smm/sm-card-iasecc.c b/src/smm/sm-card-iasecc.c index 89860d2a..a77849d0 100644 --- a/src/smm/sm-card-iasecc.c +++ b/src/smm/sm-card-iasecc.c @@ -67,7 +67,9 @@ sm_iasecc_get_apdu_read_binary(struct sc_context *ctx, struct sm_info *sm_info, if (!rdata || !rdata->alloc) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "SM get 'READ BINARY' APDUs: offset:%i,size:%i", cmd_data->offs, cmd_data->count); + sc_log(ctx, + "SM get 'READ BINARY' APDUs: offset:%"SC_FORMAT_LEN_SIZE_T"u,size:%"SC_FORMAT_LEN_SIZE_T"u", + cmd_data->offs, cmd_data->count); offs = cmd_data->offs; while (cmd_data->count > data_offs) { int sz = (cmd_data->count - data_offs) > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : (cmd_data->count - data_offs); @@ -111,7 +113,9 @@ sm_iasecc_get_apdu_update_binary(struct sc_context *ctx, struct sm_info *sm_info if (!rdata || !rdata->alloc) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "SM get 'UPDATE BINARY' APDUs: offset:%i,size:%i", cmd_data->offs, cmd_data->count); + sc_log(ctx, + "SM get 'UPDATE BINARY' APDUs: offset:%"SC_FORMAT_LEN_SIZE_T"u,size:%"SC_FORMAT_LEN_SIZE_T"u", + cmd_data->offs, cmd_data->count); offs = cmd_data->offs; while (data_offs < cmd_data->count) { int sz = (cmd_data->count - data_offs) > SM_MAX_DATA_SIZE ? SM_MAX_DATA_SIZE : (cmd_data->count - data_offs); @@ -157,7 +161,9 @@ sm_iasecc_get_apdu_create_file(struct sc_context *ctx, struct sm_info *sm_info, if (!cmd_data || !cmd_data->data || !rdata || !rdata->alloc) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "SM get 'CREATE FILE' APDU: FCP(%i) %s", cmd_data->size, sc_dump_hex(cmd_data->data,cmd_data->size)); + sc_log(ctx, + "SM get 'CREATE FILE' APDU: FCP(%"SC_FORMAT_LEN_SIZE_T"u) %s", + cmd_data->size, sc_dump_hex(cmd_data->data,cmd_data->size)); rv = rdata->alloc(rdata, &rapdu); LOG_TEST_RET(ctx, rv, "SM get 'UPDATE BINARY' APDUs: cannot allocate remote APDU"); @@ -231,9 +237,9 @@ sm_iasecc_get_apdu_verify_pin(struct sc_context *ctx, struct sm_info *sm_info, s if (!pin_data || !rdata || !rdata->alloc) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "SM get 'VERIFY PIN' APDU: ", pin_data->pin_reference); + sc_log(ctx, "SM get 'VERIFY PIN' APDU: %u", pin_data->pin_reference); - rv = rdata->alloc(rdata, &rapdu); + rv = rdata->alloc(rdata, &rapdu); LOG_TEST_RET(ctx, rv, "SM get 'VERIFY PIN' APDUs: cannot allocate remote APDU"); rapdu->apdu.cse = SC_APDU_CASE_3_SHORT; @@ -505,7 +511,8 @@ sm_iasecc_get_apdus(struct sc_context *ctx, struct sm_info *sm_info, if (!sm_info) LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS); - sc_log(ctx, "SM IAS/ECC get APDUs: init_len:%i", init_len); + sc_log(ctx, "SM IAS/ECC get APDUs: init_len:%"SC_FORMAT_LEN_SIZE_T"u", + init_len); sc_log(ctx, "SM IAS/ECC get APDUs: rdata:%p", rdata); sc_log(ctx, "SM IAS/ECC get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len)); @@ -579,7 +586,9 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru LOG_FUNC_CALLED(ctx); - sc_log(ctx, "IAS/ECC decode answer() rdata length %i, out length %i", rdata->length, out_len); + sc_log(ctx, + "IAS/ECC decode answer() rdata length %i, out length %"SC_FORMAT_LEN_SIZE_T"u", + rdata->length, out_len); for (rapdu = rdata->data; rapdu; rapdu = rapdu->next) { unsigned char *decrypted; size_t decrypted_len; @@ -590,7 +599,9 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru unsigned char ticket[8]; size_t ticket_len = sizeof(ticket); - sc_log(ctx, "IAS/ECC decode response(%i) %s", rapdu->apdu.resplen, sc_dump_hex(rapdu->apdu.resp, rapdu->apdu.resplen)); + sc_log(ctx, + "IAS/ECC decode response(%"SC_FORMAT_LEN_SIZE_T"u) %s", + rapdu->apdu.resplen, sc_dump_hex(rapdu->apdu.resp, rapdu->apdu.resplen)); sc_copy_asn1_entry(c_asn1_iasecc_sm_data_object, asn1_iasecc_sm_data_object); sc_format_asn1_entry(asn1_iasecc_sm_data_object + 0, resp_data, &resp_len, 0); @@ -614,7 +625,10 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru &decrypted, &decrypted_len); LOG_TEST_RET(ctx, rv, "IAS/ECC decode answer(s): cannot decrypt card answer data"); - sc_log(ctx, "IAS/ECC decrypted data(%i) %s", decrypted_len, sc_dump_hex(decrypted, decrypted_len)); + sc_log(ctx, + "IAS/ECC decrypted data(%"SC_FORMAT_LEN_SIZE_T"u) %s", + decrypted_len, + sc_dump_hex(decrypted, decrypted_len)); while(*(decrypted + decrypted_len - 1) == 0x00) decrypted_len--; if (*(decrypted + decrypted_len - 1) != 0x80) @@ -628,7 +642,9 @@ sm_iasecc_decode_card_data(struct sc_context *ctx, struct sm_info *sm_info, stru memcpy(out + offs, decrypted, decrypted_len); offs += decrypted_len; - sc_log(ctx, "IAS/ECC decode card answer(s): out_len/offs %i/%i", out_len, offs); + sc_log(ctx, + "IAS/ECC decode card answer(s): out_len/offs %"SC_FORMAT_LEN_SIZE_T"u/%i", + out_len, offs); } free(decrypted); diff --git a/src/smm/sm-cwa14890.c b/src/smm/sm-cwa14890.c index 73bd05a3..fc3ff4d6 100644 --- a/src/smm/sm-cwa14890.c +++ b/src/smm/sm-cwa14890.c @@ -147,7 +147,9 @@ sm_cwa_decode_authentication_data(struct sc_context *ctx, struct sm_cwa_keyset * rv = sm_decrypt_des_cbc3(ctx, keyset->enc, session_data->mdata, session_data->mdata_len, &decrypted, &decrypted_len); LOG_TEST_RET(ctx, rv, "sm_ecc_decode_auth_data() DES CBC3 decrypt error"); - sc_log(ctx, "sm_ecc_decode_auth_data() decrypted(%i) %s", decrypted_len, sc_dump_hex(decrypted, decrypted_len)); + sc_log(ctx, + "sm_ecc_decode_auth_data() decrypted(%"SC_FORMAT_LEN_SIZE_T"u) %s", + decrypted_len, sc_dump_hex(decrypted, decrypted_len)); if (memcmp(decrypted, session_data->icc.rnd, 8)) { free(decrypted); @@ -278,14 +280,16 @@ sm_cwa_initialize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_rem rv = sm_encrypt_des_cbc3(ctx, cwa_keyset->enc, buf, offs, &encrypted, &encrypted_len, 1); LOG_TEST_RET(ctx, rv, "_encrypt_des_cbc3() failed"); - sc_log(ctx, "ENCed(%i) %s", encrypted_len, sc_dump_hex(encrypted, encrypted_len)); + sc_log(ctx, "ENCed(%"SC_FORMAT_LEN_SIZE_T"u) %s", encrypted_len, + sc_dump_hex(encrypted, encrypted_len)); memcpy(buf, encrypted, encrypted_len); offs = encrypted_len; rv = sm_cwa_get_mac(ctx, cwa_keyset->mac, &icv, buf, offs, &cblock, 1); LOG_TEST_RET(ctx, rv, "sm_ecc_get_mac() failed"); - sc_log(ctx, "MACed(%i) %s", sizeof(cblock), sc_dump_hex(cblock, sizeof(cblock))); + sc_log(ctx, "MACed(%"SC_FORMAT_LEN_SIZE_T"u) %s", sizeof(cblock), + sc_dump_hex(cblock, sizeof(cblock))); apdu->cse = SC_APDU_CASE_4_SHORT; apdu->cla = 0x00; @@ -315,14 +319,17 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_ int rv; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "securize APDU (cla:%X,ins:%X,p1:%X,p2:%X,data(%i):%p)", - apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data); + sc_log(ctx, + "securize APDU (cla:%X,ins:%X,p1:%X,p2:%X,data(%"SC_FORMAT_LEN_SIZE_T"u):%p)", + apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, + apdu->data); sm_incr_ssc(session_data->ssc, sizeof(session_data->ssc)); rv = sm_encrypt_des_cbc3(ctx, session_data->session_enc, apdu->data, apdu->datalen, &encrypted, &encrypted_len, 0); LOG_TEST_RET(ctx, rv, "securize APDU: DES CBC3 encryption failed"); - sc_log(ctx, "encrypted data (len:%i, %s)", encrypted_len, sc_dump_hex(encrypted, encrypted_len)); + sc_log(ctx, "encrypted data (len:%"SC_FORMAT_LEN_SIZE_T"u, %s)", + encrypted_len, sc_dump_hex(encrypted, encrypted_len)); offs = 0; if (apdu->ins & 0x01) { @@ -341,7 +348,8 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_ memcpy(edfb_data + offs, encrypted, encrypted_len); offs += encrypted_len; edfb_len = offs; - sc_log(ctx, "securize APDU: EDFB(len:%i,%sà", edfb_len, sc_dump_hex(edfb_data, edfb_len)); + sc_log(ctx, "securize APDU: EDFB(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)", + edfb_len, sc_dump_hex(edfb_data, edfb_len)); free(encrypted); encrypted = NULL; @@ -368,7 +376,8 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_ /* } */ mac_len = offs; - sc_log(ctx, "securize APDU: MAC data(len:%i,%s)", mac_len, sc_dump_hex(mac_data, mac_len)); + sc_log(ctx, "securize APDU: MAC data(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)", + mac_len, sc_dump_hex(mac_data, mac_len)); memset(icv, 0, sizeof(icv)); rv = sm_cwa_get_mac(ctx, session_data->session_mac, &icv, mac_data, mac_len, &cblock, 0); @@ -391,7 +400,8 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_ sbuf[offs++] = 8; memcpy(sbuf + offs, cblock, 8); offs += 8; - sc_log(ctx, "securize APDU: SM data(len:%i,%s)", offs, sc_dump_hex(sbuf, offs)); + sc_log(ctx, "securize APDU: SM data(len:%"SC_FORMAT_LEN_SIZE_T"u,%s)", + offs, sc_dump_hex(sbuf, offs)); if (offs > sizeof(rapdu->sbuf)) LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "securize APDU: buffer too small for encrypted data"); diff --git a/src/smm/sm-global-platform.c b/src/smm/sm-global-platform.c index 5f8ec449..e8f10507 100644 --- a/src/smm/sm-global-platform.c +++ b/src/smm/sm-global-platform.c @@ -321,7 +321,9 @@ sm_gp_encrypt_command_data(struct sc_context *ctx, unsigned char *session_key, if (!out || !out_len) LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "SM GP encrypt command data error"); - sc_log(ctx, "SM GP encrypt command data(len:%i,%p)", in_len, in); + sc_log(ctx, + "SM GP encrypt command data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p)", + in_len, in); if (in==NULL || in_len==0) { *out = NULL; *out_len = 0; @@ -363,9 +365,10 @@ sm_gp_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, LOG_FUNC_CALLED(ctx); apdu_data = (unsigned char *)apdu->data; - sc_log(ctx, "SM GP securize APDU(cse:%X,cla:%X,ins:%X,data(len:%i,%p),lc:%i,GP level:%X,GP index:%X", - apdu->cse, apdu->cla, apdu->ins, apdu->datalen, apdu->data, - apdu->lc, gp_level, gp_index); + sc_log(ctx, + "SM GP securize APDU(cse:%X,cla:%X,ins:%X,data(len:%"SC_FORMAT_LEN_SIZE_T"u,%p),lc:%"SC_FORMAT_LEN_SIZE_T"u,GP level:%X,GP index:%X", + apdu->cse, apdu->cla, apdu->ins, apdu->datalen, apdu->data, + apdu->lc, gp_level, gp_index); if (gp_level == 0 || (apdu->cla & 0x04)) return 0; @@ -384,7 +387,9 @@ sm_gp_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, if (encrypted_len + 8 > SC_MAX_APDU_BUFFER_SIZE) LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "SM GP securize APDU: not enough place for encrypted data"); - sc_log(ctx, "SM GP securize APDU: encrypted length %i", encrypted_len); + sc_log(ctx, + "SM GP securize APDU: encrypted length %"SC_FORMAT_LEN_SIZE_T"u", + encrypted_len); } else { LOG_TEST_RET(ctx, SC_ERROR_SM_INVALID_LEVEL, "SM GP securize APDU: invalid SM level"); diff --git a/src/smm/smm-local.c b/src/smm/smm-local.c index c7384f75..e6537cc0 100644 --- a/src/smm/smm-local.c +++ b/src/smm/smm-local.c @@ -87,7 +87,8 @@ sm_gp_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info) return SC_ERROR_UNKNOWN_DATA_RECEIVED; } - sc_log(ctx, "SM type:%X, KMC(%i) %s", sm_info->sm_type, hex_len, sc_dump_hex(hex, hex_len)); + sc_log(ctx, "SM type:%X, KMC(%"SC_FORMAT_LEN_SIZE_T"u) %s", + sm_info->sm_type, hex_len, sc_dump_hex(hex, hex_len)); if (hex_len != 16 && hex_len != 48 ) return SC_ERROR_INVALID_DATA; @@ -135,7 +136,8 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info) return SC_ERROR_SM_KEYSET_NOT_FOUND; } - sc_log(ctx, "keyset::enc(%i) %s", strlen(value), value); + sc_log(ctx, "keyset::enc(%"SC_FORMAT_LEN_SIZE_T"u) %s", strlen(value), + value); if (strlen(value) == 16) { memcpy(cwa_keyset->enc, value, 16); } @@ -147,7 +149,8 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info) return SC_ERROR_UNKNOWN_DATA_RECEIVED; } - sc_log(ctx, "ENC(%i) %s", hex_len, sc_dump_hex(hex, hex_len)); + sc_log(ctx, "ENC(%"SC_FORMAT_LEN_SIZE_T"u) %s", hex_len, + sc_dump_hex(hex, hex_len)); if (hex_len != 16) return SC_ERROR_INVALID_DATA; @@ -167,7 +170,8 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info) return SC_ERROR_SM_KEYSET_NOT_FOUND; } - sc_log(ctx, "keyset::mac(%i) %s", strlen(value), value); + sc_log(ctx, "keyset::mac(%"SC_FORMAT_LEN_SIZE_T"u) %s", strlen(value), + value); if (strlen(value) == 16) { memcpy(cwa_keyset->mac, value, 16); } @@ -179,7 +183,8 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info) return SC_ERROR_UNKNOWN_DATA_RECEIVED; } - sc_log(ctx, "MAC(%i) %s", hex_len, sc_dump_hex(hex, hex_len)); + sc_log(ctx, "MAC(%"SC_FORMAT_LEN_SIZE_T"u) %s", hex_len, + sc_dump_hex(hex, hex_len)); if (hex_len != 16) return SC_ERROR_INVALID_DATA; @@ -203,7 +208,9 @@ sm_cwa_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info) } if (hex_len != sizeof(cwa_session->ifd.sn)) { - sc_log(ctx, "SM get 'ifd_serial': invalid IFD serial length: %i", hex_len); + sc_log(ctx, + "SM get 'ifd_serial': invalid IFD serial length: %"SC_FORMAT_LEN_SIZE_T"u", + hex_len); return SC_ERROR_UNKNOWN_DATA_RECEIVED; } @@ -313,7 +320,8 @@ finalize(struct sc_context *ctx, struct sm_info *sm_info, struct sc_remote_data int rv = SC_ERROR_INTERNAL; LOG_FUNC_CALLED(ctx); - sc_log(ctx, "SM finalize: out buffer(%i) %p", out_len, out); + sc_log(ctx, "SM finalize: out buffer(%"SC_FORMAT_LEN_SIZE_T"u) %p", + out_len, out); if (!sm_info || !rdata) LOG_FUNC_RETURN(ctx, SC_SUCCESS); diff --git a/src/tools/pkcs15-tool.c b/src/tools/pkcs15-tool.c index 092b9d9f..e8163986 100644 --- a/src/tools/pkcs15-tool.c +++ b/src/tools/pkcs15-tool.c @@ -530,7 +530,8 @@ static int list_data_objects(void) return 1; } sc_pkcs15_free_data_object(data_object); - printf(" Size:%5lu", (unsigned long) cinfo->data.len); + printf(" Size:%5"SC_FORMAT_LEN_SIZE_T"u", + cinfo->data.len); } else { printf(" AuthID:%-3s", sc_pkcs15_print_id(&objs[i]->auth_id)); }