Fix log messages format and parameter issues flagged by GCC
Since "Add GCC format checking attributes to log functions" commit GCC warns us about problems with format strings and their arguments provided to OpenSC message logging functions. This commit fixes all cases where GCC warned about incorrect format on 64-bit Linux, 32-bit and 64-bit mingw builds (with SM and OpenSSL enabled). Well, almost all since on mingw GCC does not recognize "ll" size specifier (present at least since Visual Studio 2005, also in mingw own CRT) so these (few) warnings about it remain. In most cases format size specifier for size_t type was missing (usually size was left at default int level, with is different on 64-bit x86). Some formats had too few / too many arguments. In some cases pointers were printed as integers. Some long variables were missing "l" prefix (especially with regard to %x format). Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
This commit is contained in:
parent
2e75198181
commit
62cbda6cd9
|
@ -372,8 +372,10 @@ sc_single_transmit(struct sc_card *card, struct sc_apdu *apdu)
|
||||||
if (card->reader->ops->transmit == NULL)
|
if (card->reader->ops->transmit == NULL)
|
||||||
LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "cannot transmit APDU");
|
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",
|
sc_log(ctx,
|
||||||
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data);
|
"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
|
#ifdef ENABLE_SM
|
||||||
if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT)
|
if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT)
|
||||||
return sc_sm_single_transmit(card, apdu);
|
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) {
|
if (!len) {
|
||||||
apdu->cse = SC_APDU_CASE_1;
|
apdu->cse = SC_APDU_CASE_1;
|
||||||
sc_log(ctx, "CASE_1 APDU: %lu bytes:\tins=%02x p1=%02x p2=%02x lc=%04x le=%04x",
|
sc_log(ctx,
|
||||||
(unsigned long) len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
|
"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;
|
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++;
|
apdu->lc += *p++;
|
||||||
len -= 3;
|
len -= 3;
|
||||||
if (len < apdu->lc) {
|
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;
|
return SC_ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
apdu->data = p;
|
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++;
|
apdu->lc = *p++;
|
||||||
len--;
|
len--;
|
||||||
if (len < apdu->lc) {
|
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;
|
return SC_ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
apdu->data = p;
|
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;
|
return SC_ERROR_INVALID_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "Case %d %s APDU, %lu bytes:\tins=%02x p1=%02x p2=%02x lc=%04x le=%04x",
|
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_SHORT_MASK,
|
||||||
(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
|
(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
|
||||||
(unsigned long) len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
|
len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc,
|
||||||
|
apdu->le);
|
||||||
|
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,7 +415,8 @@ const u8 *sc_asn1_skip_tag(sc_context_t *ctx, const u8 ** buf, size_t *buflen,
|
||||||
return NULL;
|
return NULL;
|
||||||
len -= (p - *buf); /* header size */
|
len -= (p - *buf); /* header size */
|
||||||
if (taglen > len) {
|
if (taglen > len) {
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "too long ASN.1 object (size %d while only %d available)\n",
|
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);
|
taglen, len);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1276,7 +1277,9 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
|
||||||
case SC_ASN1_BOOLEAN:
|
case SC_ASN1_BOOLEAN:
|
||||||
if (parm != NULL) {
|
if (parm != NULL) {
|
||||||
if (objlen != 1) {
|
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;
|
r = SC_ERROR_INVALID_ASN1_OBJECT;
|
||||||
} else
|
} else
|
||||||
*((int *) parm) = obj[0] ? 1 : 0;
|
*((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;
|
struct sc_asn1_entry *entry = asn1;
|
||||||
size_t left = len, objlen;
|
size_t left = len, objlen;
|
||||||
|
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*scalled, left=%u, depth %d%s\n",
|
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
|
||||||
depth, depth, "",
|
"%*.*scalled, left=%"SC_FORMAT_LEN_SIZE_T"u, depth %d%s\n",
|
||||||
left, depth,
|
depth, depth, "", left, depth, choice ? ", choice" : "");
|
||||||
choice ? ", choice" : "");
|
|
||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
|
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)");
|
(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
|
||||||
if (!(entry->flags & SC_ASN1_PRESENT))
|
if (!(entry->flags & SC_ASN1_PRESENT))
|
||||||
goto no_object;
|
goto no_object;
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*stype=%d, tag=0x%02x, parm=%p, len=%u\n",
|
sc_debug(ctx, SC_LOG_DEBUG_ASN1,
|
||||||
depth, depth, "",
|
"%*.*stype=%d, tag=0x%02x, parm=%p, len=%"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
entry->type, entry->tag, parm, len? *len : 0);
|
depth, depth, "", entry->type, entry->tag, parm,
|
||||||
|
len ? *len : 0);
|
||||||
|
|
||||||
if (entry->type == SC_ASN1_CHOICE) {
|
if (entry->type == SC_ASN1_CHOICE) {
|
||||||
const struct sc_asn1_entry *list, *choice = NULL;
|
const struct sc_asn1_entry *list, *choice = NULL;
|
||||||
|
@ -1733,7 +1736,9 @@ no_object:
|
||||||
if (buf)
|
if (buf)
|
||||||
free(buf);
|
free(buf);
|
||||||
if (r >= 0)
|
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;
|
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 + (halflen - r_len), r, r_len);
|
||||||
memcpy(buf + (buflen - s_len), s, s_len);
|
memcpy(buf + (buflen - s_len), s, s_len);
|
||||||
|
|
||||||
sc_log(ctx, "r(%i): %s", halflen, sc_dump_hex(buf, halflen));
|
sc_log(ctx, "r(%"SC_FORMAT_LEN_SIZE_T"u): %s", halflen,
|
||||||
sc_log(ctx, "s(%i): %s", halflen, sc_dump_hex(buf + halflen, 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;
|
rv = SC_SUCCESS;
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -157,7 +157,9 @@ sc_aux_data_get_md_guid(struct sc_context *ctx, struct sc_auxiliary_data *aux_da
|
||||||
strlcat(guid, "}", sizeof(guid));
|
strlcat(guid, "}", sizeof(guid));
|
||||||
|
|
||||||
if (*out_size < strlen(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);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_BUFFER_TOO_SMALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,9 +393,10 @@ static int atrust_acos_select_file(struct sc_card *card,
|
||||||
pbuf[0] = '\0';
|
pbuf[0] = '\0';
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"current path (%s, %s): %s (len: %u)\n",
|
"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.current_path.type == SC_PATH_TYPE_DF_NAME ?
|
||||||
(card->cache.valid?"valid":"invalid"), pbuf,
|
"aid" : "path",
|
||||||
|
card->cache.valid ? "valid" : "invalid", pbuf,
|
||||||
card->cache.current_path.len);
|
card->cache.current_path.len);
|
||||||
|
|
||||||
memcpy(path, in_path->value, in_path->len);
|
memcpy(path, in_path->value, in_path->len);
|
||||||
|
|
|
@ -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);
|
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");
|
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) {
|
if (data_len == 10) {
|
||||||
for (ii=0; ii<5; ii++) {
|
for (ii=0; ii<5; ii++) {
|
||||||
unsigned char acl = *(data + ii*2);
|
unsigned char acl = *(data + ii*2);
|
||||||
|
@ -857,14 +857,16 @@ authentic_read_binary(struct sc_card *card, unsigned int idx,
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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
|
/* Data size more then 256 bytes can happen when card reader is
|
||||||
* configurated with max_send/recv_size more then 255/256 bytes
|
* configurated with max_send/recv_size more then 255/256 bytes
|
||||||
* (for ex. 'remote-access' reader) .
|
* (for ex. 'remote-access' reader) .
|
||||||
* In this case create chained 'read-binary' APDUs.
|
* 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))
|
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");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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() */
|
/* 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))
|
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");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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() */
|
/* 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))
|
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");
|
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);
|
tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x6F, &taglen);
|
||||||
if (tag != NULL) {
|
if (tag != NULL) {
|
||||||
sc_log(ctx, " FCP length %i", taglen);
|
sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
|
||||||
buf = tag;
|
buf = tag;
|
||||||
buflen = taglen;
|
buflen = taglen;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x62, &taglen);
|
tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x62, &taglen);
|
||||||
if (tag != NULL) {
|
if (tag != NULL) {
|
||||||
sc_log(ctx, " FCP length %i", taglen);
|
sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
|
||||||
buf = tag;
|
buf = tag;
|
||||||
buflen = taglen;
|
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");
|
LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
|
||||||
|
|
||||||
if (!file->sec_attr_len) {
|
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);
|
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) {
|
if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF) {
|
||||||
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++) {
|
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 op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
|
||||||
unsigned char acl = *(file->sec_attr + ii*2);
|
unsigned char acl = *(file->sec_attr + ii*2);
|
||||||
|
@ -1418,9 +1427,13 @@ authentic_pin_change_pinpad(struct sc_card *card, unsigned reference, int *tries
|
||||||
memset(pin2_data, pin_cmd.pin2.pad_char, sizeof(pin2_data));
|
memset(pin2_data, pin_cmd.pin2.pad_char, sizeof(pin2_data));
|
||||||
pin_cmd.pin2.data = 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,
|
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);
|
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,
|
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);
|
pin_cmd.pin2.pad_length);
|
||||||
|
|
||||||
rv = iso_ops->pin_cmd(card, &pin_cmd, tries_left);
|
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));
|
memcpy(&pin_cmd.pin2, &pin_cmd.pin1, sizeof(pin_cmd.pin1));
|
||||||
memset(&pin_cmd.pin1, 0, sizeof(pin_cmd.pin1));
|
memset(&pin_cmd.pin1, 0, sizeof(pin_cmd.pin1));
|
||||||
|
|
||||||
sc_log(ctx, "PIN2 max/min/pad %i/%i/%i",
|
sc_log(ctx,
|
||||||
pin_cmd.pin2.max_length, pin_cmd.pin2.min_length, pin_cmd.pin2.pad_length);
|
"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);
|
rv = iso_ops->pin_cmd(card, &pin_cmd, NULL);
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, rv);
|
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;
|
data->flags |= SC_PIN_CMD_NEED_PADDING;
|
||||||
|
|
||||||
sc_log(ctx, "PIN policy: size max/min/pad %i/%i/%i, tries max/left %i/%i",
|
sc_log(ctx,
|
||||||
data->pin1.max_length, data->pin1.min_length, data->pin1.pad_length,
|
"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_tries, data->pin1.tries_left);
|
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);
|
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;
|
blob_len = 0;
|
||||||
|
|
||||||
/* Encode public RSA key part */
|
/* 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);
|
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");
|
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);
|
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");
|
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);
|
rv = authentic_manage_sdo_encode(card, sdo, SC_CARDCTL_AUTHENTIC_SDO_GENERATE, &data, &data_len);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot encode SDO data");
|
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);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x47, 0x00, 0x00);
|
||||||
apdu.data = data;
|
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);
|
rv = authentic_manage_sdo_encode(card, sdo, cmd, &data, &data_len);
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot encode SDO data");
|
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);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDB, 0x3F, 0xFF);
|
||||||
apdu.data = data;
|
apdu.data = data;
|
||||||
|
@ -2048,7 +2069,9 @@ authentic_decipher(struct sc_card *card, const unsigned char *in, size_t in_len,
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (!out || !out_len || in_len > SC_MAX_APDU_BUFFER_SIZE)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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)
|
if (!plain || !sm_apdu)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
sc_log(ctx, "called; CLA:%X, INS:%X, P1:%X, P2:%X, data(%i) %p",
|
sc_log(ctx,
|
||||||
plain->cla, plain->ins, plain->p1, plain->p2, plain->datalen, plain->data);
|
"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;
|
*sm_apdu = NULL;
|
||||||
|
|
||||||
if ((plain->cla & 0x04)
|
if ((plain->cla & 0x04)
|
||||||
|
|
|
@ -642,7 +642,9 @@ static int get_carddata(sc_card_t *card, u8* carddata_loc, unsigned int carddata
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
if(apdu.resplen < carddataloc_len) {
|
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;
|
return SC_ERROR_WRONG_LENGTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%02x %02x %02x %d : %d %d\n",
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
ins, p1, p2, sendbuflen, card->max_send_size, card->max_recv_size);
|
"%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;
|
rbuf = rbufinitbuf;
|
||||||
rbuflen = sizeof(rbufinitbuf);
|
rbuflen = sizeof(rbufinitbuf);
|
||||||
|
@ -363,13 +365,15 @@ static int cac_apdu_io(sc_card_t *card, int ins, int p1, int p2,
|
||||||
apdu.resplen = 0;
|
apdu.resplen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"calling sc_transmit_apdu flags=%x le=%d, resplen=%d, resp=%p",
|
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);
|
apdu.flags, apdu.le, apdu.resplen, apdu.resp);
|
||||||
|
|
||||||
/* with new adpu.c and chaining, this actually reads the whole object */
|
/* with new adpu.c and chaining, this actually reads the whole object */
|
||||||
r = sc_transmit_apdu(card, &apdu);
|
r = sc_transmit_apdu(card, &apdu);
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"result r=%d apdu.resplen=%d sw1=%02x sw2=%02x",
|
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);
|
r, apdu.resplen, apdu.sw1, apdu.sw2);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Transmit failed");
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Transmit failed");
|
||||||
|
@ -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);
|
left = size = lebytes2ushort(count);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
|
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);
|
len, out_ptr, &count, count[0], count[1], size, size);
|
||||||
out = out_ptr = malloc(size);
|
out = out_ptr = malloc(size);
|
||||||
if (out == NULL) {
|
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 we didn't return it all last time, return the remainder */
|
||||||
if (priv->cached) {
|
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) {
|
if (idx > priv->cache_buf_len) {
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_FILE_END_REACHED);
|
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_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) {
|
if (priv->cache_buf) {
|
||||||
free(priv->cache_buf);
|
free(priv->cache_buf);
|
||||||
priv->cache_buf = NULL;
|
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:
|
case CAC_OBJECT_TYPE_CERT:
|
||||||
/* read file */
|
/* 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_len = 0;
|
||||||
cert_ptr = NULL;
|
cert_ptr = NULL;
|
||||||
cert_type = 0;
|
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_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);
|
r = sc_lock(card);
|
||||||
if (r != SC_SUCCESS)
|
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_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",
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
env->flags, env->operation, env->algorithm, env->algorithm_flags,
|
"flags=%08lx op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
env->algorithm_ref, env->key_ref[0], env->key_ref_len);
|
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) {
|
if (env->algorithm != SC_ALGORITHM_RSA) {
|
||||||
r = SC_ERROR_NO_CARD_SUPPORT;
|
r = SC_ERROR_NO_CARD_SUPPORT;
|
||||||
|
@ -871,7 +884,9 @@ static int cac_rsa_op(sc_card_t *card,
|
||||||
size_t rbuflen, outplen;
|
size_t rbuflen, outplen;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
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;
|
outp = out;
|
||||||
outplen = outlen;
|
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;
|
pathlen = in_path->len;
|
||||||
pathtype = in_path->type;
|
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)",
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
|
||||||
in_path->aid.value[0], in_path->aid.value[1], in_path->aid.value[2], in_path->aid.value[3],
|
"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[4], in_path->aid.value[5], in_path->aid.value[6], in_path->aid.len,
|
in_path->aid.value[0], in_path->aid.value[1],
|
||||||
in_path->value[0], in_path->value[1], in_path->value[2], in_path->value[3], in_path->len,
|
in_path->aid.value[2], in_path->aid.value[3],
|
||||||
in_path->type, in_path->type);
|
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",
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "file_out=%p index=%d count=%d\n",
|
||||||
file_out, in_path->index, in_path->count);
|
file_out, in_path->index, in_path->count);
|
||||||
|
|
||||||
|
@ -1135,13 +1153,17 @@ 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));
|
memcpy(path->value, &val->objectID, sizeof(val->objectID));
|
||||||
path->len = sizeof(val->objectID);
|
path->len = sizeof(val->objectID);
|
||||||
path->type = SC_PATH_TYPE_FILE_ID;
|
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)",
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
|
||||||
path->aid.value[0], path->aid.value[1], path->aid.value[2], path->aid.value[3],
|
"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[4], path->aid.value[5], path->aid.value[6],
|
path->aid.value[0], path->aid.value[1], path->aid.value[2],
|
||||||
path->aid.len, path->value[0], path->value[1], path->len, path->type, path->type);
|
path->aid.value[3], path->aid.value[4], path->aid.value[5],
|
||||||
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",
|
path->aid.value[6], path->aid.len, path->value[0],
|
||||||
val->rid[0], val->rid[1], val->rid[2], val->rid[3], val->rid[4], sizeof(val->rid),
|
path->value[1], path->len, path->type, path->type);
|
||||||
val->applicationID[0], val->applicationID[1], sizeof(val->applicationID),
|
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));
|
val->objectID[0], val->objectID[1], sizeof(val->objectID));
|
||||||
|
|
||||||
return SC_SUCCESS;
|
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, "manufacture id=%x", val->manufacturer_id);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "cac_type=%d", val->card_type);
|
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "cac_type=%d", val->card_type);
|
||||||
card_id_len = len - (&val->card_id - (u8 *)val);
|
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->cuid = *val;
|
||||||
priv->cac_id = malloc(card_id_len);
|
priv->cac_id = malloc(card_id_len);
|
||||||
if (priv->cac_id == NULL) {
|
if (priv->cac_id == NULL) {
|
||||||
|
|
|
@ -1211,8 +1211,12 @@ cardos_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data,
|
||||||
data->pin_reference |= 0x80;
|
data->pin_reference |= 0x80;
|
||||||
|
|
||||||
sc_log(ctx, "PIN_CMD(cmd:%i, ref:%i)", data->cmd, data->pin_reference);
|
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,
|
||||||
sc_log(ctx, "PIN2(max:%i, min:%i)", data->pin2.max_length, data->pin2.min_length);
|
"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
|
/* FIXME: the following values depend on what pin length was
|
||||||
* used when creating the BS objects */
|
* used when creating the BS objects */
|
||||||
|
|
|
@ -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_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%02x %02x %02x %d : %d %d\n",
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
ins, p1, p2, sendbuflen , card->max_send_size, card->max_recv_size);
|
"%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;
|
rbuf = rbufinitbuf;
|
||||||
rbuflen = sizeof(rbufinitbuf);
|
rbuflen = sizeof(rbufinitbuf);
|
||||||
|
@ -994,13 +996,15 @@ static int coolkey_apdu_io(sc_card_t *card, int cla, int ins, int p1, int p2,
|
||||||
apdu.resplen = 0;
|
apdu.resplen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"calling sc_transmit_apdu flags=%x le=%d, resplen=%d, resp=%p",
|
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);
|
apdu.flags, apdu.le, apdu.resplen, apdu.resp);
|
||||||
|
|
||||||
/* with new adpu.c and chaining, this actually reads the whole object */
|
/* with new adpu.c and chaining, this actually reads the whole object */
|
||||||
r = sc_transmit_apdu(card, &apdu);
|
r = sc_transmit_apdu(card, &apdu);
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"result r=%d apdu.resplen=%d sw1=%02x sw2=%02x",
|
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);
|
r, apdu.resplen, apdu.sw1, apdu.sw2);
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
@ -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 we've already read the data, just return it */
|
||||||
if (priv->obj->data) {
|
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);
|
len = MIN(count, priv->obj->length-idx);
|
||||||
memcpy(buf, &priv->obj->data[idx], len);
|
memcpy(buf, &priv->obj->data[idx], len);
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, 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);
|
data = malloc(priv->obj->length);
|
||||||
if (data == NULL) {
|
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_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);
|
r = sc_lock(card);
|
||||||
if (r != SC_SUCCESS)
|
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_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",
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
env->flags, env->operation, env->algorithm, env->algorithm_flags,
|
"flags=%08lx op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
env->algorithm_ref, env->key_ref[0], env->key_ref_len);
|
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)) {
|
if ((env->algorithm != SC_ALGORITHM_RSA) && (env->algorithm != SC_ALGORITHM_EC)) {
|
||||||
r = SC_ERROR_NO_CARD_SUPPORT;
|
r = SC_ERROR_NO_CARD_SUPPORT;
|
||||||
|
@ -1697,7 +1708,9 @@ static int coolkey_rsa_op(sc_card_t *card,
|
||||||
u8 *buf_out;
|
u8 *buf_out;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
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 = data;
|
||||||
crypt_in_len = datalen;
|
crypt_in_len = datalen;
|
||||||
|
@ -1798,7 +1811,9 @@ static int coolkey_ecc_op(sc_card_t *card,
|
||||||
u8 key_number;
|
u8 key_number;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
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 = data;
|
||||||
crypt_in_len = datalen;
|
crypt_in_len = datalen;
|
||||||
|
|
|
@ -964,7 +964,8 @@ static u8 *dnie_uncompress(sc_card_t * card, u8 * from, size_t *len)
|
||||||
*len = uncompressed;
|
*len = uncompressed;
|
||||||
sc_log(card->ctx, "Compressed data:\n%s\n",
|
sc_log(card->ctx, "Compressed data:\n%s\n",
|
||||||
sc_dump_hex(from + 8, compressed));
|
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);
|
compressed, uncompressed);
|
||||||
sc_log(card->ctx, "Uncompressed data:\n%s\n",
|
sc_log(card->ctx, "Uncompressed data:\n%s\n",
|
||||||
sc_dump_hex(upt, uncompressed));
|
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 */
|
/* ok: as final step, set correct cache data into dnie_priv structures */
|
||||||
GET_DNIE_PRIV_DATA(card)->cache = pt;
|
GET_DNIE_PRIV_DATA(card)->cache = pt;
|
||||||
GET_DNIE_PRIV_DATA(card)->cachelen = len;
|
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);
|
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
|
data and feed them into sign() command
|
||||||
*/
|
*/
|
||||||
sc_log(card->ctx,
|
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));
|
datalen, sc_dump_hex(data, datalen));
|
||||||
|
|
||||||
/*INS: 0x2A PERFORM SECURITY OPERATION
|
/*INS: 0x2A PERFORM SECURITY OPERATION
|
||||||
|
|
|
@ -687,9 +687,10 @@ static int entersafe_select_file(sc_card_t *card,
|
||||||
pbuf[0] = '\0';
|
pbuf[0] = '\0';
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"current path (%s, %s): %s (len: %u)\n",
|
"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.current_path.type == SC_PATH_TYPE_DF_NAME ?
|
||||||
(card->cache.valid?"valid":"invalid"), pbuf,
|
"aid" : "path",
|
||||||
|
card->cache.valid ? "valid" : "invalid", pbuf,
|
||||||
card->cache.current_path.len);
|
card->cache.current_path.len);
|
||||||
|
|
||||||
switch(in_path->type)
|
switch(in_path->type)
|
||||||
|
|
|
@ -978,7 +978,9 @@ epass2003_sm_unwrap_apdu(struct sc_card *card, struct sc_apdu *sm, struct sc_apd
|
||||||
plain->sw1 = sm->sw1;
|
plain->sw1 = sm->sw1;
|
||||||
plain->sw2 = sm->sw2;
|
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);
|
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)
|
if (r != SC_SUCCESS)
|
||||||
pbuf[0] = '\0';
|
pbuf[0] = '\0';
|
||||||
|
|
||||||
sc_log(card->ctx, "current path (%s, %s): %s (len: %u)\n",
|
sc_log(card->ctx,
|
||||||
(card->cache.current_path.type == SC_PATH_TYPE_DF_NAME ? "aid" : "path"),
|
"current path (%s, %s): %s (len: %"SC_FORMAT_LEN_SIZE_T"u)\n",
|
||||||
(card->cache.valid ? "valid" : "invalid"), pbuf, card->cache.current_path.len);
|
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) {
|
switch (in_path->type) {
|
||||||
case SC_PATH_TYPE_FILE_ID:
|
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];
|
file->size = tag[0];
|
||||||
if (taglen == 2)
|
if (taglen == 2)
|
||||||
file->size = (file->size << 8) + tag[1];
|
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) {
|
if (tag == NULL) {
|
||||||
|
|
|
@ -641,7 +641,9 @@ static int cryptoflex_list_files(sc_card_t *card, u8 *buf, size_t buflen)
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
if (apdu.resplen != 4) {
|
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;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
memcpy(buf, rbuf + 2, 2);
|
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)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
if (apdu.resplen != 6) {
|
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;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
memcpy(buf, rbuf + 4, 2);
|
memcpy(buf, rbuf + 4, 2);
|
||||||
|
@ -845,7 +849,8 @@ cyberflex_construct_file_attrs(sc_card_t *card, const sc_file_t *file,
|
||||||
break;
|
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 >> 8,
|
||||||
file->id & 0xFF,
|
file->id & 0xFF,
|
||||||
size,
|
size,
|
||||||
|
@ -983,7 +988,9 @@ cryptoflex_compute_signature(sc_card_t *card, const u8 *data,
|
||||||
size_t i, i2;
|
size_t i, i2;
|
||||||
|
|
||||||
if (data_len != 64 && data_len != 96 && data_len != 128 && data_len != 256) {
|
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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
if (outlen < data_len) {
|
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 96: alg_id = 0xC6; break;
|
||||||
case 128: alg_id = 0xC8; break;
|
case 128: alg_id = 0xC8; break;
|
||||||
default:
|
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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
key_id = prv->rsa_key_ref + 1; /* Why? */
|
key_id = prv->rsa_key_ref + 1; /* Why? */
|
||||||
|
|
|
@ -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 */
|
/* the card can sign 36 bytes of free form data */
|
||||||
if (data_len > 36) {
|
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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%x, responselen=%d\n",
|
"Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
fileIdentifier, dataObjectIdentifier, response, responselen ? *responselen : 0);
|
fileIdentifier, dataObjectIdentifier, response,
|
||||||
|
responselen ? *responselen : 0);
|
||||||
|
|
||||||
sc_format_apdu(card, &apdu,
|
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));
|
response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_GET_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF));
|
||||||
|
@ -250,7 +251,7 @@ static int gids_put_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdenti
|
||||||
u8* p = buffer;
|
u8* p = buffer;
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Got args: fileIdentifier=%x, dataObjectIdentifier=%x, data=%x, datalen=%d\n",
|
"Got args: fileIdentifier=%x, dataObjectIdentifier=%x, data=%p, datalen=%"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
fileIdentifier, dataObjectIdentifier, data, datalen);
|
fileIdentifier, dataObjectIdentifier, data, datalen);
|
||||||
|
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, INS_PUT_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF));
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, INS_PUT_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF));
|
||||||
|
@ -278,7 +279,7 @@ 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_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Got args: aid=%x, aidlen=%d, response=%x, responselen=%d\n",
|
"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);
|
aid, aidlen, response, responselen ? *responselen : 0);
|
||||||
|
|
||||||
sc_format_apdu(card, &apdu,
|
sc_format_apdu(card, &apdu,
|
||||||
|
@ -851,7 +852,7 @@ static int gids_read_public_key (struct sc_card *card , unsigned int algorithm,
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Got args: key_reference=%x, response=%x, responselen=%d\n",
|
"Got args: key_reference=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
key_reference, response, responselen ? *responselen : 0);
|
key_reference, response, responselen ? *responselen : 0);
|
||||||
|
|
||||||
sc_format_apdu(card, &apdu,
|
sc_format_apdu(card, &apdu,
|
||||||
|
@ -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);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, r);
|
||||||
}
|
}
|
||||||
if (data->buffersize != expectedsize) {
|
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);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_DATA);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
}
|
}
|
||||||
if (i > recordsnum) {
|
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);
|
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);
|
keymaprecordnum = (keymapbuffersize - 1) / sizeof(struct gids_keymap_record);
|
||||||
if (keymaprecordnum != recordnum) {
|
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 , "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);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1235,7 +1235,7 @@ gpk_compute_signature(sc_card_t *card, const u8 *data,
|
||||||
|
|
||||||
if (data_len > priv->sec_mod_len) {
|
if (data_len > priv->sec_mod_len) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Data length (%u) does not match key modulus %u.\n",
|
"Data length (%"SC_FORMAT_LEN_SIZE_T"u) does not match key modulus %u.\n",
|
||||||
data_len, priv->sec_mod_len);
|
data_len, priv->sec_mod_len);
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
@ -1289,7 +1289,7 @@ gpk_decipher(sc_card_t *card, const u8 *in, size_t inlen,
|
||||||
|
|
||||||
if (inlen != priv->sec_mod_len) {
|
if (inlen != priv->sec_mod_len) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Data length (%u) does not match key modulus %u.\n",
|
"Data length (%"SC_FORMAT_LEN_SIZE_T"u) does not match key modulus %u.\n",
|
||||||
inlen, priv->sec_mod_len);
|
inlen, priv->sec_mod_len);
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,9 @@ static int iasecc_parse_ef_atr(struct sc_card *card)
|
||||||
if (card->max_send_size > 0xFF)
|
if (card->max_send_size > 0xFF)
|
||||||
card->max_send_size -= 5;
|
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);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -686,7 +688,9 @@ iasecc_read_binary(struct sc_card *card, unsigned int offs,
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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) {
|
if (offs > 0x7fff) {
|
||||||
sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", offs);
|
sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", offs);
|
||||||
return SC_ERROR_OFFSET_TOO_LARGE;
|
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");
|
LOG_TEST_RET(ctx, rv, "APDU transmit failed");
|
||||||
rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_read_binary() failed");
|
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) {
|
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);
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (!count)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "'ERASE BINARY' failed: invalid size to erase");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (offs > 0x7fff)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_OFFSET_TOO_LARGE, "Invalid arguments");
|
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;
|
return SC_SUCCESS;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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);
|
sc_print_cache(card);
|
||||||
|
|
||||||
if (card->cache.valid && card->cache.current_ef) {
|
if (card->cache.valid && card->cache.current_ef) {
|
||||||
|
@ -857,7 +869,8 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
if (file_out)
|
if (file_out)
|
||||||
*file_out = NULL;
|
*file_out = NULL;
|
||||||
|
|
||||||
sc_log(ctx, "iasecc_select_file(card:%p) path.len %i; path.type %i; aid_len %i",
|
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);
|
card, path->len, path->type, path->aid.len);
|
||||||
sc_log(ctx, "iasecc_select_file() path:%s", sc_print_path(path));
|
sc_log(ctx, "iasecc_select_file() path:%s", sc_print_path(path));
|
||||||
|
|
||||||
|
@ -878,7 +891,9 @@ iasecc_select_file(struct sc_card *card, const struct sc_path *path,
|
||||||
struct sc_file *file = NULL;
|
struct sc_file *file = NULL;
|
||||||
struct sc_path ppath;
|
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));
|
sc_log(ctx, "iasecc_select_file() select parent AID:%s", sc_dump_hex(lpath.aid.value, lpath.aid.len));
|
||||||
memset(&ppath, 0, sizeof(ppath));
|
memset(&ppath, 0, sizeof(ppath));
|
||||||
memcpy(ppath.value, lpath.aid.value, lpath.aid.len);
|
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");
|
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) {
|
if (apdu.resplen) {
|
||||||
sc_log(ctx, "apdu.resp %02X:%02X:%02X...", apdu.resp[0], apdu.resp[1], apdu.resp[2]);
|
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);
|
tag = sc_asn1_find_tag(ctx, buf, buflen, 0x6F, &taglen);
|
||||||
sc_log(ctx, "processing FCI: 0x6F tag %p", tag);
|
sc_log(ctx, "processing FCI: 0x6F tag %p", tag);
|
||||||
if (tag != NULL) {
|
if (tag != NULL) {
|
||||||
sc_log(ctx, " FCP length %i", taglen);
|
sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
|
||||||
buf = tag;
|
buf = tag;
|
||||||
buflen = taglen;
|
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);
|
tag = sc_asn1_find_tag(ctx, buf, buflen, 0x62, &taglen);
|
||||||
sc_log(ctx, "processing FCI: 0x62 tag %p", tag);
|
sc_log(ctx, "processing FCI: 0x62 tag %p", tag);
|
||||||
if (tag != NULL) {
|
if (tag != NULL) {
|
||||||
sc_log(ctx, " FCP length %i", taglen);
|
sc_log(ctx, " FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
|
||||||
buf = tag;
|
buf = tag;
|
||||||
buflen = taglen;
|
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);
|
acls = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
|
||||||
|
|
||||||
if (!acls) {
|
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");
|
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;
|
mask = 0x40, offs = 1;
|
||||||
for (ii = 0; ii < 7; ii++, mask /= 2) {
|
for (ii = 0; ii < 7; ii++, mask /= 2) {
|
||||||
unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
|
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");
|
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported AC method");
|
||||||
|
|
||||||
amb |= mask;
|
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 */
|
/* 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() */
|
/* To made by iasecc_sdo_convert_to_file() */
|
||||||
prv->key_size = *(sdo.docp.size.value + 0) * 0x100 + *(sdo.docp.size.value + 1);
|
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);
|
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");
|
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, "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",
|
sc_log(ctx,
|
||||||
se_num, operation, env->algorithm, env->algorithm_ref, env->algorithm_flags, prv->key_size);
|
"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) {
|
switch (operation) {
|
||||||
case SC_SEC_OPERATION_SIGN:
|
case SC_SEC_OPERATION_SIGN:
|
||||||
if (!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1))
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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) {
|
if (type == SC_AC_AUT) {
|
||||||
rv = iasecc_sm_external_authentication(card, reference, tries_left);
|
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));
|
memcpy(&pin_cmd.pin2, &pin_cmd.pin1, sizeof(pin_cmd.pin1));
|
||||||
pin_cmd.pin2.data = pin2_data;
|
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,
|
||||||
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);
|
"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);
|
rv = iso_ops->pin_cmd(card, &pin_cmd, tries_left);
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, rv);
|
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)
|
if (sdo.docp.acls_contact.size == 0)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Extremely strange ... there is no ACLs");
|
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; ii<sizeof(sdo.docp.scbs); ii++) {
|
for (ii=0; ii<sizeof(sdo.docp.scbs); ii++) {
|
||||||
struct iasecc_se_info se;
|
struct iasecc_se_info se;
|
||||||
unsigned char scb = sdo.docp.scbs[ii];
|
unsigned char scb = sdo.docp.scbs[ii];
|
||||||
|
@ -2225,7 +2259,8 @@ iasecc_pin_get_policy (struct sc_card *card, struct sc_pin_cmd_data *data)
|
||||||
data->pin1.offset = 5;
|
data->pin1.offset = 5;
|
||||||
data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
|
data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
|
||||||
|
|
||||||
sc_log(ctx, "PIN policy: size max/min %i/%i, tries max/left %i/%i",
|
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_length, data->pin1.min_length,
|
||||||
data->pin1.max_tries, data->pin1.tries_left);
|
data->pin1.max_tries, data->pin1.tries_left);
|
||||||
iasecc_sdo_free_fields(card, &sdo);
|
iasecc_sdo_free_fields(card, &sdo);
|
||||||
|
@ -3029,7 +3064,9 @@ iasecc_decipher(struct sc_card *card,
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (!out || !out_len || in_len > SC_MAX_APDU_BUFFER_SIZE)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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)
|
if (!in || !in_len || !out)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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));
|
memset(out, 0, sizeof(struct iasecc_qsign_data));
|
||||||
|
|
||||||
SHA1_Init(&sha);
|
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) {
|
if (sha.num) {
|
||||||
memcpy(out->last_block, in + in_len - sha.num, sha.num);
|
memcpy(out->last_block, in + in_len - sha.num, sha.num);
|
||||||
out->last_block_size = 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);
|
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)
|
if (!in || !in_len || !out)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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));
|
memset(out, 0, sizeof(struct iasecc_qsign_data));
|
||||||
|
|
||||||
SHA256_Init(&sha256);
|
SHA256_Init(&sha256);
|
||||||
|
@ -3151,7 +3194,9 @@ iasecc_qsign_data_sha256(struct sc_context *ctx, const unsigned char *in, size_t
|
||||||
if (sha256.num) {
|
if (sha256.num) {
|
||||||
memcpy(out->last_block, in + in_len - sha256.num, sha256.num);
|
memcpy(out->last_block, in + in_len - sha256.num, sha256.num);
|
||||||
out->last_block_size = 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);
|
SHA256_Final(out->hash, &sha256);
|
||||||
|
@ -3178,7 +3223,9 @@ iasecc_compute_signature_dst(struct sc_card *card,
|
||||||
int rv = SC_SUCCESS;
|
int rv = SC_SUCCESS;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (env->operation != SC_SEC_OPERATION_SIGN)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "It's not 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))
|
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, SC_ERROR_INVALID_ARGUMENTS, "Need RSA_HASH_SHA1 or RSA_HASH_SHA256 algorithm");
|
||||||
LOG_TEST_RET(ctx, rv, "Cannot get QSign data");
|
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));
|
memset(sbuf, 0, sizeof(sbuf));
|
||||||
sbuf[offs++] = 0x90;
|
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);
|
memcpy(sbuf + offs, qsign_data.last_block, qsign_data.last_block_size);
|
||||||
offs += 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))
|
if (prv->op_method == SC_AC_SCB && (prv->op_ref & IASECC_SCB_METHOD_SM))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Not yet");
|
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);
|
rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
|
||||||
LOG_TEST_RET(ctx, rv, "Compute signature failed");
|
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)
|
if (apdu.resplen > out_len)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Result buffer too small for the DST signature");
|
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;
|
env = &prv->security_env;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (env->operation == SC_SEC_OPERATION_SIGN)
|
||||||
return iasecc_compute_signature_dst(card, in, in_len, out, out_len);
|
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");
|
LOG_TEST_RET(ctx, rv, "get new key reference failed");
|
||||||
|
|
||||||
sz = *(sdo->docp.size.value + 0) * 0x100 + *(sdo->docp.size.value + 1);
|
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) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,8 @@ jpki_select_file(struct sc_card *card,
|
||||||
struct sc_file *file = NULL;
|
struct sc_file *file = NULL;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_log(card->ctx, "jpki_select_file: path=%s, len=%d",
|
sc_log(card->ctx,
|
||||||
|
"jpki_select_file: path=%s, len=%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
sc_print_path(path), path->len);
|
sc_print_path(path), path->len);
|
||||||
if (path->len == 2 && memcmp(path->value, "\x3F\x00", 2) == 0) {
|
if (path->len == 2 && memcmp(path->value, "\x3F\x00", 2) == 0) {
|
||||||
drvdata->selected = SELECT_MF;
|
drvdata->selected = SELECT_MF;
|
||||||
|
@ -301,7 +302,7 @@ jpki_set_security_env(sc_card_t * card,
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_log(card->ctx,
|
sc_log(card->ctx,
|
||||||
"flags=%08x op=%d alg=%d algf=%08x algr=%08x kr0=%02x, krfl=%d",
|
"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->flags, env->operation, env->algorithm,
|
||||||
env->algorithm_flags, env->algorithm_ref, env->key_ref[0],
|
env->algorithm_flags, env->algorithm_ref, env->key_ref[0],
|
||||||
env->key_ref_len);
|
env->key_ref_len);
|
||||||
|
|
|
@ -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_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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->operation, datalen, datalen, env->key_ref[0],
|
||||||
env->algorithm, env->algorithm_flags);
|
env->algorithm, env->algorithm_flags);
|
||||||
|
|
||||||
|
|
|
@ -472,7 +472,7 @@ static int miocos_card_ctl(sc_card_t *card, unsigned long cmd,
|
||||||
case SC_CARDCTL_MIOCOS_CREATE_AC:
|
case SC_CARDCTL_MIOCOS_CREATE_AC:
|
||||||
return miocos_create_ac(card, (struct sc_cardctl_miocos_ac_info *) arg);
|
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;
|
return SC_ERROR_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,9 @@ auth_process_fci(struct sc_card *card, struct sc_file *file,
|
||||||
else if (file->size==2048)
|
else if (file->size==2048)
|
||||||
file->size = PUBKEY_2048_ASN1_SIZE;
|
file->size = PUBKEY_2048_ASN1_SIZE;
|
||||||
else {
|
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);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
|
||||||
}
|
}
|
||||||
break;
|
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])
|
path.value[offs + 1] != auth_current_df->path.value[offs + 1])
|
||||||
break;
|
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) {
|
if (offs && offs < auth_current_df->path.len) {
|
||||||
size_t deep = auth_current_df->path.len - offs;
|
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; ii<deep; ii+=2) {
|
for (ii=0; ii<deep; ii+=2) {
|
||||||
struct sc_path tmp_path;
|
struct sc_path tmp_path;
|
||||||
|
|
||||||
|
@ -746,7 +749,8 @@ encode_file_structure_V5(struct sc_card *card, const struct sc_file *file,
|
||||||
unsigned char ops[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
unsigned char ops[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_log(card->ctx, "id %04X; size %i; type 0x%X/0x%X",
|
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);
|
file->id, file->size, file->type, file->ef_structure);
|
||||||
|
|
||||||
if (*buflen < 0x18)
|
if (*buflen < 0x18)
|
||||||
|
@ -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)
|
else if (file->size == PUBKEY_2048_ASN1_SIZE || file->size == 2048)
|
||||||
size = 2048;
|
size = 2048;
|
||||||
else {
|
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);
|
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)
|
else if (file->size == 24 || file->size == 192)
|
||||||
size = 192;
|
size = 192;
|
||||||
else {
|
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);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,7 +945,7 @@ auth_create_file(struct sc_card *card, struct sc_file *file)
|
||||||
sc_log(card->ctx, " create path=%s", pbuf);
|
sc_log(card->ctx, " create path=%s", pbuf);
|
||||||
|
|
||||||
sc_log(card->ctx,
|
sc_log(card->ctx,
|
||||||
"id %04X; size %i; type 0x%X; ef 0x%X",
|
"id %04X; size %"SC_FORMAT_LEN_SIZE_T"u; type 0x%X; ef 0x%X",
|
||||||
file->id, file->size, file->type, file->ef_structure);
|
file->id, file->size, file->type, file->ef_structure);
|
||||||
|
|
||||||
if (file->id==0x0000 || file->id==0xFFFF || file->id==0x3FFF)
|
if (file->id==0x0000 || file->id==0xFFFF || file->id==0x3FFF)
|
||||||
|
@ -1015,7 +1023,8 @@ auth_set_security_env(struct sc_card *card,
|
||||||
};
|
};
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_log(card->ctx, "op %i; path %s; key_ref 0x%X; algos 0x%X; flags 0x%X",
|
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->operation, sc_print_path(&env->file_ref), env->key_ref[0],
|
||||||
env->algorithm_flags, env->flags);
|
env->algorithm_flags, env->flags);
|
||||||
|
|
||||||
|
@ -1027,7 +1036,8 @@ auth_set_security_env(struct sc_card *card,
|
||||||
switch (env->algorithm) {
|
switch (env->algorithm) {
|
||||||
case SC_ALGORITHM_DES:
|
case SC_ALGORITHM_DES:
|
||||||
case SC_ALGORITHM_3DES:
|
case SC_ALGORITHM_3DES:
|
||||||
sc_log(card->ctx, "algo SC_ALGORITHM_xDES: ref %X, flags %X",
|
sc_log(card->ctx,
|
||||||
|
"algo SC_ALGORITHM_xDES: ref %X, flags %lX",
|
||||||
env->algorithm_ref, env->flags);
|
env->algorithm_ref, env->flags);
|
||||||
|
|
||||||
if (env->operation == SC_SEC_OPERATION_DECIPHER) {
|
if (env->operation == SC_SEC_OPERATION_DECIPHER) {
|
||||||
|
@ -1049,7 +1059,7 @@ auth_set_security_env(struct sc_card *card,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pads & (~supported_pads)) {
|
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.");
|
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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
else if (ilen > 96) {
|
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_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Illegal input length");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
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);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0x9A);
|
||||||
apdu.datalen = ilen;
|
apdu.datalen = ilen;
|
||||||
|
@ -1130,7 +1144,8 @@ auth_compute_signature(struct sc_card *card, const unsigned char *in, size_t ile
|
||||||
LOG_TEST_RET(card->ctx, rv, "Compute signature failed");
|
LOG_TEST_RET(card->ctx, rv, "Compute signature failed");
|
||||||
|
|
||||||
if (apdu.resplen > olen) {
|
if (apdu.resplen > olen) {
|
||||||
sc_log(card->ctx, "Compute signature failed: invalide response length %i",
|
sc_log(card->ctx,
|
||||||
|
"Compute signature failed: invalid response length %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
apdu.resplen);
|
apdu.resplen);
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
|
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;
|
int rv, _inlen = inlen;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
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)
|
if (!out || !outlen || inlen > SC_MAX_APDU_BUFFER_SIZE)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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;
|
data->pubkey_len = apdu.resplen;
|
||||||
free(apdu.resp);
|
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);
|
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];
|
unsigned char resp[256];
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
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)
|
if (!outlen || type!=SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
|
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,
|
sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
buf, count, debug_buf, sizeof(debug_buf));
|
buf, count, debug_buf, sizeof(debug_buf));
|
||||||
sc_log(card->ctx,
|
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))
|
if (1+offset > sizeof(rsa_der))
|
||||||
LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid offset value");
|
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];
|
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)
|
if (offset + len < der_size + 2)
|
||||||
LOG_FUNC_RETURN(card->ctx, len);
|
LOG_FUNC_RETURN(card->ctx, len);
|
||||||
|
|
||||||
|
@ -2066,7 +2086,8 @@ auth_update_binary(struct sc_card *card, unsigned int offset,
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
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",
|
sc_log(card->ctx, "last selected : magic %X; ef %X",
|
||||||
auth_current_ef->magic, auth_current_ef->ef_structure);
|
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];
|
char debug_buf[2048];
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
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",
|
sc_log(card->ctx,"last selected : magic %X; ef %X",
|
||||||
auth_current_ef->magic, auth_current_ef->ef_structure);
|
auth_current_ef->magic, auth_current_ef->ef_structure);
|
||||||
|
|
||||||
|
@ -2153,7 +2176,7 @@ auth_read_binary(struct sc_card *card, unsigned int offset,
|
||||||
sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_hex_dump(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
buf, rv, debug_buf, sizeof(debug_buf));
|
buf, rv, debug_buf, sizeof(debug_buf));
|
||||||
sc_log(card->ctx,
|
sc_log(card->ctx,
|
||||||
"write_publickey in %d bytes :\n%s",
|
"write_publickey in %"SC_FORMAT_LEN_SIZE_T"u bytes :\n%s",
|
||||||
count, debug_buf);
|
count, debug_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2180,7 +2203,9 @@ auth_read_record(struct sc_card *card, unsigned int nr_rec,
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
unsigned char recvbuf[SC_MAX_APDU_BUFFER_SIZE];
|
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);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB2, nr_rec, 0);
|
||||||
apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
|
apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
|
||||||
|
|
|
@ -962,7 +962,9 @@ pgp_get_blob(sc_card_t *card, pgp_blob_t *blob, unsigned int id,
|
||||||
return SC_SUCCESS;
|
return SC_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
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;
|
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);
|
size_t plen = MIN(length - i*256, 256);
|
||||||
u8 roundbuf[256]; /* space to build APDU data with even length for Gnuk */
|
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 */
|
/* 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);
|
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.
|
* 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. */
|
* 7F21 size is soft-coded, so we can check it. */
|
||||||
if (tag == DO_CERT && buf_len > priv->max_cert_size) {
|
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);
|
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);
|
r = pgp_seek_blob(card, priv->mf, (0x00C0 | key_info->keytype), &algo_blob);
|
||||||
LOG_TEST_RET(card->ctx, r, "Cannot get old algorithm attributes");
|
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 */
|
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 */
|
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 */
|
/* Modulus */
|
||||||
/* If passed modulus_len is zero, it means using old key size */
|
/* 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);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
|
|
||||||
if (id > card->algorithm_count) {
|
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);
|
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 */
|
/* we only support exponent of maximum 32 bits */
|
||||||
if (key_info->e_len > 4) {
|
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);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
|
||||||
|
|
||||||
sc_log(card->ctx, "%02x %02x %02x %d : %d %d",
|
sc_log(card->ctx,
|
||||||
ins, p1, p2, sendbuflen, card->max_send_size, card->max_recv_size);
|
"%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;
|
rbuf = rbufinitbuf;
|
||||||
rbuflen = sizeof(rbufinitbuf);
|
rbuflen = sizeof(rbufinitbuf);
|
||||||
|
@ -523,13 +525,15 @@ static int piv_general_io(sc_card_t *card, int ins, int p1, int p2,
|
||||||
apdu.resplen = 0;
|
apdu.resplen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(card->ctx, "calling sc_transmit_apdu flags=%x le=%d, resplen=%d, resp=%p",
|
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);
|
apdu.flags, apdu.le, apdu.resplen, apdu.resp);
|
||||||
|
|
||||||
/* with new adpu.c and chaining, this actually reads the whole object */
|
/* with new adpu.c and chaining, this actually reads the whole object */
|
||||||
r = sc_transmit_apdu(card, &apdu);
|
r = sc_transmit_apdu(card, &apdu);
|
||||||
|
|
||||||
sc_log(card->ctx, "DEE r=%d apdu.resplen=%d sw1=%02x sw2=%02x",
|
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);
|
r, apdu.resplen, apdu.sw1, apdu.sw2);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
sc_log(card->ctx, "Transmit failed");
|
sc_log(card->ctx, "Transmit failed");
|
||||||
|
@ -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 using internal buffer, alloc new one */
|
||||||
if (rbuf == rbufinitbuf) {
|
if (rbuf == rbufinitbuf) {
|
||||||
*recvbuf = malloc(rbuflen);
|
*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) {
|
if (*recvbuf == NULL) {
|
||||||
r = SC_ERROR_OUT_OF_MEMORY;
|
r = SC_ERROR_OUT_OF_MEMORY;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -718,7 +724,8 @@ static int piv_select_aid(sc_card_t* card, u8* aid, size_t aidlen, u8* response,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_log(card->ctx, "Got args: aid=%x, aidlen=%d, response=%x, responselen=%d",
|
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);
|
aid, aidlen, response, responselen ? *responselen : 0);
|
||||||
|
|
||||||
sc_format_apdu(card, &apdu,
|
sc_format_apdu(card, &apdu,
|
||||||
|
@ -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) {
|
if (*buf == NULL && *buf_len > 0) {
|
||||||
*buf = malloc(*buf_len);
|
*buf = malloc(*buf_len);
|
||||||
if (*buf == NULL ) {
|
if (*buf == NULL ) {
|
||||||
|
@ -978,7 +987,8 @@ piv_get_cached_data(sc_card_t * card, int enumtag, u8 **buf, size_t *buf_len)
|
||||||
/* see if we have it cached */
|
/* see if we have it cached */
|
||||||
if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_VALID) {
|
if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_VALID) {
|
||||||
|
|
||||||
sc_log(card->ctx, "found #%d %p:%d %p:%d",
|
sc_log(card->ctx,
|
||||||
|
"found #%d %p:%"SC_FORMAT_LEN_SIZE_T"u %p:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
enumtag,
|
enumtag,
|
||||||
priv->obj_cache[enumtag].obj_data,
|
priv->obj_cache[enumtag].obj_data,
|
||||||
priv->obj_cache[enumtag].obj_len,
|
priv->obj_cache[enumtag].obj_len,
|
||||||
|
@ -1020,7 +1030,8 @@ piv_get_cached_data(sc_card_t * card, int enumtag, u8 **buf, size_t *buf_len)
|
||||||
*buf = rbuf;
|
*buf = rbuf;
|
||||||
*buf_len = r;
|
*buf_len = r;
|
||||||
|
|
||||||
sc_log(card->ctx, "added #%d %p:%d %p:%d",
|
sc_log(card->ctx,
|
||||||
|
"added #%d %p:%"SC_FORMAT_LEN_SIZE_T"u %p:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
enumtag,
|
enumtag,
|
||||||
priv->obj_cache[enumtag].obj_data,
|
priv->obj_cache[enumtag].obj_data,
|
||||||
priv->obj_cache[enumtag].obj_len,
|
priv->obj_cache[enumtag].obj_len,
|
||||||
|
@ -1053,7 +1064,9 @@ piv_cache_internal_data(sc_card_t *card, int enumtag)
|
||||||
|
|
||||||
/* if already cached */
|
/* if already cached */
|
||||||
if (priv->obj_cache[enumtag].internal_obj_data && priv->obj_cache[enumtag].internal_obj_len) {
|
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,
|
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_data,
|
||||||
priv->obj_cache[enumtag].internal_obj_len);
|
priv->obj_cache[enumtag].internal_obj_len);
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
|
||||||
|
@ -1127,7 +1140,8 @@ piv_cache_internal_data(sc_card_t *card, int enumtag)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(card->ctx, "added #%d internal %p:%d", enumtag,
|
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_data,
|
||||||
priv->obj_cache[enumtag].internal_obj_len);
|
priv->obj_cache[enumtag].internal_obj_len);
|
||||||
|
|
||||||
|
@ -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;
|
r = SC_ERROR_FILE_NOT_FOUND;
|
||||||
goto err;
|
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);
|
body = sc_asn1_find_tag(card->ctx, rbuf, rbuflen, rbuf[0], &bodylen);
|
||||||
if (body == NULL) {
|
if (body == NULL) {
|
||||||
/* if missing, assume its the body */
|
/* if missing, assume its the body */
|
||||||
|
@ -1176,7 +1192,8 @@ piv_read_binary(sc_card_t *card, unsigned int idx, unsigned char *buf, size_t co
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
if (bodylen > body - rbuf + rbuflen) {
|
if (bodylen > body - rbuf + rbuflen) {
|
||||||
sc_log(card->ctx, " ***** tag length > then data: %d>%d+%d",
|
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);
|
bodylen, body - rbuf, rbuflen);
|
||||||
r = SC_ERROR_INVALID_DATA;
|
r = SC_ERROR_INVALID_DATA;
|
||||||
goto err;
|
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 sbuflen;
|
||||||
size_t taglen;
|
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)
|
taglen = put_tag_and_len(0x70, count, NULL)
|
||||||
+ put_tag_and_len(0x71, 1, NULL)
|
+ put_tag_and_len(0x71, 1, NULL)
|
||||||
+ put_tag_and_len(0xFE, 0, 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? */
|
*p++ = (flags)? 0x01:0x00; /* certinfo, i.e. gziped? */
|
||||||
put_tag_and_len(0xFE,0,&p); /* LRC tag */
|
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;
|
enumtag = piv_objects[priv->selected_obj].enumtag;
|
||||||
r = piv_put_data(card, enumtag, sbuf, sbuflen);
|
r = piv_put_data(card, enumtag, sbuf, sbuflen);
|
||||||
|
@ -1691,7 +1709,8 @@ static int piv_general_mutual_authenticate(sc_card_t *card,
|
||||||
*/
|
*/
|
||||||
nonce = malloc(witness_len);
|
nonce = malloc(witness_len);
|
||||||
if(!nonce) {
|
if(!nonce) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "OOM allocating nonce\n",
|
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);
|
witness_len, plain_text_len);
|
||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -1700,7 +1719,8 @@ static int piv_general_mutual_authenticate(sc_card_t *card,
|
||||||
|
|
||||||
r = RAND_bytes(nonce, witness_len);
|
r = RAND_bytes(nonce, witness_len);
|
||||||
if(!r) {
|
if(!r) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Generating random for nonce\n",
|
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);
|
witness_len, plain_text_len);
|
||||||
r = SC_ERROR_INTERNAL;
|
r = SC_ERROR_INTERNAL;
|
||||||
goto err;
|
goto err;
|
||||||
|
@ -2090,7 +2110,8 @@ 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 */
|
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",
|
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);
|
fascn, fascnlen, guid, guidlen, gbits);
|
||||||
|
|
||||||
if (fascn && fascnlen == 25) {
|
if (fascn && fascnlen == 25) {
|
||||||
|
@ -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_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);
|
r = sc_lock(card);
|
||||||
if (r != SC_SUCCESS)
|
if (r != SC_SUCCESS)
|
||||||
|
@ -2258,7 +2279,8 @@ 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_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",
|
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->flags, env->operation, env->algorithm, env->algorithm_flags,
|
||||||
env->algorithm_ref, env->key_ref[0], env->key_ref_len);
|
env->algorithm_ref, env->key_ref[0], env->key_ref_len);
|
||||||
|
|
||||||
|
@ -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 ) {
|
if (priv->alg_id == 0x11 || priv->alg_id == 0x14 ) {
|
||||||
nLen = (priv->key_size + 7) / 8;
|
nLen = (priv->key_size + 7) / 8;
|
||||||
if (outlen < 2*nLen) {
|
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;
|
r = SC_ERROR_INVALID_DATA;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -2582,7 +2606,8 @@ static int piv_process_discovery(sc_card_t *card)
|
||||||
goto err;
|
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 */
|
/* the object is now cached, see what we have */
|
||||||
if (rbuflen != 0) {
|
if (rbuflen != 0) {
|
||||||
body = rbuf;
|
body = rbuf;
|
||||||
|
@ -2592,11 +2617,14 @@ static int piv_process_discovery(sc_card_t *card)
|
||||||
goto err;
|
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) {
|
if ( cla_out+tag_out == 0x7E && body != NULL && bodylen != 0) {
|
||||||
aidlen = 0;
|
aidlen = 0;
|
||||||
aid = sc_asn1_find_tag(card->ctx, body, bodylen, 0x4F, &aidlen);
|
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 ||
|
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 */
|
memcmp(aid,piv_aids[0].value,piv_aids[0].len_short) != 0) { /*TODO look at long */
|
||||||
sc_log(card->ctx, "Discovery object not PIV");
|
sc_log(card->ctx, "Discovery object not PIV");
|
||||||
|
@ -2604,7 +2632,9 @@ static int piv_process_discovery(sc_card_t *card)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
pinp = sc_asn1_find_tag(card->ctx, body, bodylen, 0x5F2F, &pinplen);
|
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) {
|
if (pinp && pinplen == 2) {
|
||||||
sc_log(card->ctx, "Discovery pinp flags=0x%2.2x 0x%2.2x",*pinp, *(pinp+1));
|
sc_log(card->ctx, "Discovery pinp flags=0x%2.2x 0x%2.2x",*pinp, *(pinp+1));
|
||||||
r = SC_SUCCESS;
|
r = SC_SUCCESS;
|
||||||
|
@ -2831,7 +2861,8 @@ piv_process_history(sc_card_t *card)
|
||||||
|
|
||||||
certobj = NULL;
|
certobj = NULL;
|
||||||
|
|
||||||
sc_log(card->ctx, "Added from off card file #%d %p:%d 0x%02X",
|
sc_log(card->ctx,
|
||||||
|
"Added from off card file #%d %p:%"SC_FORMAT_LEN_SIZE_T"u 0x%02X",
|
||||||
enumtag,
|
enumtag,
|
||||||
priv->obj_cache[enumtag].obj_data,
|
priv->obj_cache[enumtag].obj_data,
|
||||||
priv->obj_cache[enumtag].obj_len, *keyref);
|
priv->obj_cache[enumtag].obj_len, *keyref);
|
||||||
|
@ -2861,10 +2892,13 @@ piv_finish(sc_card_t *card)
|
||||||
if (priv->offCardCertURL)
|
if (priv->offCardCertURL)
|
||||||
free(priv->offCardCertURL);
|
free(priv->offCardCertURL);
|
||||||
for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) {
|
for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) {
|
||||||
sc_log(card->ctx, "DEE freeing #%d, 0x%02x %p:%d %p:%d", i,
|
sc_log(card->ctx,
|
||||||
priv->obj_cache[i].flags,
|
"DEE freeing #%d, 0x%02x %p:%"SC_FORMAT_LEN_SIZE_T"u %p:%"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
priv->obj_cache[i].obj_data, priv->obj_cache[i].obj_len,
|
i, priv->obj_cache[i].flags,
|
||||||
priv->obj_cache[i].internal_obj_data, priv->obj_cache[i].internal_obj_len);
|
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)
|
if (priv->obj_cache[i].obj_data)
|
||||||
free(priv->obj_cache[i].obj_data);
|
free(priv->obj_cache[i].obj_data);
|
||||||
if (priv->obj_cache[i].internal_obj_data)
|
if (priv->obj_cache[i].internal_obj_data)
|
||||||
|
@ -2994,7 +3028,8 @@ static int piv_init(sc_card_t *card)
|
||||||
if (!priv || card->type == -1)
|
if (!priv || card->type == -1)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT);
|
||||||
|
|
||||||
sc_log(card->ctx, "Max send = %d recv = %d card->type = %d",
|
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->max_send_size, card->max_recv_size, card->type);
|
||||||
card->cla = 0x00;
|
card->cla = 0x00;
|
||||||
if(card->name == NULL)
|
if(card->name == NULL)
|
||||||
|
|
|
@ -435,7 +435,8 @@ static int rtecp_change_reference_data(sc_card_t *card, unsigned int type,
|
||||||
int transmits_num, r;
|
int transmits_num, r;
|
||||||
|
|
||||||
assert(card && card->ctx && newref);
|
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)
|
if (newlen > 0xFFFF)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
if (type == SC_AC_CHV && old && oldlen != 0)
|
if (type == SC_AC_CHV && old && oldlen != 0)
|
||||||
|
|
|
@ -550,7 +550,8 @@ static int set_sec_attr_from_acl(sc_card_t *card, sc_file_t *file)
|
||||||
{
|
{
|
||||||
/* AccessMode.[conv_attr[i].sec_attr_pos] */
|
/* AccessMode.[conv_attr[i].sec_attr_pos] */
|
||||||
attr[0] |= 1 << 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",
|
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]);
|
conv_attr[i].sec_attr_pos, attr[0]);
|
||||||
attr[1 + conv_attr[i].sec_attr_pos] = (u8)entry->method;
|
attr[1 + conv_attr[i].sec_attr_pos] = (u8)entry->method;
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "method %u", (u8)entry->method);
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "method %u", (u8)entry->method);
|
||||||
|
@ -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_apdu_t apdu;
|
||||||
|
|
||||||
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
|
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)
|
if (!out)
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
|
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);
|
} 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)
|
if (ret == SC_SUCCESS)
|
||||||
ret = (outlen_tail == 0) ? (int)outlen : SC_ERROR_WRONG_LENGTH;
|
ret = (outlen_tail == 0) ? (int)outlen : SC_ERROR_WRONG_LENGTH;
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, ret);
|
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 */
|
ret = rutoken_format(card, 0x7b); /* APDU: FORMAT END */
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
ret = SC_ERROR_NOT_SUPPORTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,7 +486,9 @@ static int sc_hsm_decode_ecdsa_signature(sc_card_t *card,
|
||||||
fieldsizebytes = 64;
|
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)) {
|
if (outlen < (fieldsizebytes * 2)) {
|
||||||
LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "output too small for EC signature");
|
LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "output too small for EC signature");
|
||||||
|
|
|
@ -272,7 +272,8 @@ static int process_fci_v3_4(sc_context_t *ctx, sc_file_t *file,
|
||||||
size_t taglen, len = buflen;
|
size_t taglen, len = buflen;
|
||||||
const u8 *tag = NULL, *p;
|
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)
|
if (buflen < 2)
|
||||||
return SC_ERROR_INTERNAL;
|
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;
|
size_t taglen, len = buflen;
|
||||||
const u8 *tag = NULL, *p;
|
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)
|
if (buflen < 2)
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
|
@ -640,9 +642,10 @@ static int starcos_select_file(sc_card_t *card,
|
||||||
pbuf[0] = '\0';
|
pbuf[0] = '\0';
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"current path (%s, %s): %s (len: %u)\n",
|
"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.current_path.type == SC_PATH_TYPE_DF_NAME ?
|
||||||
(card->cache.valid?"valid":"invalid"), pbuf,
|
"aid" : "path",
|
||||||
|
card->cache.valid ? "valid" : "invalid", pbuf,
|
||||||
card->cache.current_path.len);
|
card->cache.current_path.len);
|
||||||
|
|
||||||
memcpy(path, in_path->value, in_path->len);
|
memcpy(path, in_path->value, in_path->len);
|
||||||
|
|
|
@ -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");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "List Dir failed");
|
||||||
if (apdu.resplen > buflen) return SC_ERROR_BUFFER_TOO_SMALL;
|
if (apdu.resplen > buflen) return SC_ERROR_BUFFER_TOO_SMALL;
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"got %d %s-FileIDs\n", apdu.resplen/2,
|
"got %"SC_FORMAT_LEN_SIZE_T"u %s-FileIDs\n",
|
||||||
p1==1 ? "DF" : "EF");
|
apdu.resplen / 2, p1 == 1 ? "DF" : "EF");
|
||||||
|
|
||||||
memcpy(buf, apdu.resp, apdu.resplen);
|
memcpy(buf, apdu.resp, apdu.resplen);
|
||||||
buf += apdu.resplen;
|
buf += apdu.resplen;
|
||||||
|
@ -530,7 +530,7 @@ static int tcos_set_security_env(sc_card_t *card, const sc_security_env_t *env,
|
||||||
"No Key-Reference in SecEnvironment\n");
|
"No Key-Reference in SecEnvironment\n");
|
||||||
else
|
else
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
"Key-Reference %02X (len=%d)\n",
|
"Key-Reference %02X (len=%"SC_FORMAT_LEN_SIZE_T"u)\n",
|
||||||
env->key_ref[0], env->key_ref_len);
|
env->key_ref[0], env->key_ref_len);
|
||||||
/* Key-Reference 0x80 ?? */
|
/* Key-Reference 0x80 ?? */
|
||||||
default_key= !(env->flags & SC_SEC_ENV_KEY_REF_PRESENT) || (env->key_ref_len==1 && env->key_ref[0]==0x80);
|
default_key= !(env->flags & SC_SEC_ENV_KEY_REF_PRESENT) || (env->key_ref_len==1 && env->key_ref[0]==0x80);
|
||||||
|
|
|
@ -600,7 +600,7 @@ static int westcos_create_file(sc_card_t *card, struct sc_file *file)
|
||||||
p2 = (file->id) % 256;
|
p2 = (file->id) % 256;
|
||||||
}
|
}
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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);
|
file->path.value, file->id, file->size);
|
||||||
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, p1, p2);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, p1, p2);
|
||||||
apdu.cla = 0x80;
|
apdu.cla = 0x80;
|
||||||
|
@ -866,7 +866,7 @@ static int westcos_card_ctl(sc_card_t * card, unsigned long cmd, void *ptr)
|
||||||
if (card == NULL)
|
if (card == NULL)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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;
|
priv_data = (priv_data_t *) card->drv_data;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SC_CARDCTL_GET_DEFAULT_KEY:
|
case SC_CARDCTL_GET_DEFAULT_KEY:
|
||||||
|
@ -1110,8 +1110,10 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
|
||||||
|
|
||||||
if (card == NULL)
|
if (card == NULL)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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
|
#ifndef ENABLE_OPENSSL
|
||||||
r = SC_ERROR_NOT_SUPPORTED;
|
r = SC_ERROR_NOT_SUPPORTED;
|
||||||
|
@ -1176,7 +1178,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
|
||||||
BIO_set_mem_eof_return(mem, -1);
|
BIO_set_mem_eof_return(mem, -1);
|
||||||
if (!d2i_RSAPrivateKey_bio(mem, &rsa)) {
|
if (!d2i_RSAPrivateKey_bio(mem, &rsa)) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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;
|
r = SC_ERROR_UNKNOWN;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1199,7 +1201,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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;
|
r = SC_ERROR_UNKNOWN;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1215,7 +1217,7 @@ static int westcos_sign_decipher(int mode, sc_card_t *card,
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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;
|
r = SC_ERROR_UNKNOWN;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_recv_size = sc_get_max_recv_size(card);
|
||||||
card->max_send_size = sc_get_max_send_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",
|
sc_log(ctx,
|
||||||
card->name, card->type, card->flags, card->max_send_size, card->max_recv_size);
|
"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
|
#ifdef ENABLE_SM
|
||||||
/* Check, if secure messaging module present. */
|
/* 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)
|
if (r != SC_SUCCESS)
|
||||||
pbuf[0] = '\0';
|
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"
|
/* ISO 7816-4: "Number of data bytes in the file, including structural information if any"
|
||||||
* can not be bigger than two bytes */
|
* can not be bigger than two bytes */
|
||||||
if (file->size > 0xFFFF)
|
if (file->size > 0xFFFF)
|
||||||
|
@ -539,7 +543,8 @@ int sc_read_binary(sc_card_t *card, unsigned int idx,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(card != NULL && card->ops != NULL && buf != NULL);
|
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)
|
if (count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -589,7 +594,8 @@ int sc_write_binary(sc_card_t *card, unsigned int idx,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(card != NULL && card->ops != NULL && buf != NULL);
|
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)
|
if (count == 0)
|
||||||
LOG_FUNC_RETURN(card->ctx, 0);
|
LOG_FUNC_RETURN(card->ctx, 0);
|
||||||
if (card->ops->write_binary == NULL)
|
if (card->ops->write_binary == NULL)
|
||||||
|
@ -632,7 +638,8 @@ int sc_update_binary(sc_card_t *card, unsigned int idx,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(card != NULL && card->ops != NULL && buf != NULL);
|
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)
|
if (count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -683,7 +690,9 @@ int sc_erase_binary(struct sc_card *card, unsigned int offs, size_t count, unsi
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(card != NULL && card->ops != NULL);
|
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)
|
if (card->ops->erase_binary == NULL)
|
||||||
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
|
LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
|
||||||
|
@ -1185,7 +1194,9 @@ void sc_print_cache(struct sc_card *card) {
|
||||||
sc_print_path(&card->cache.current_ef->path));
|
sc_print_path(&card->cache.current_ef->path));
|
||||||
|
|
||||||
if (card->cache.current_df)
|
if (card->cache.current_df)
|
||||||
sc_log(ctx, "current_df(type=%i, aid_len=%i) %s", card->cache.current_df->path.type,
|
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,
|
card->cache.current_df->path.aid.len,
|
||||||
sc_print_path(&card->cache.current_df->path));
|
sc_print_path(&card->cache.current_df->path));
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,7 +428,7 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name
|
||||||
const char *(**tmodv)(void) = &modversion;
|
const char *(**tmodv)(void) = &modversion;
|
||||||
|
|
||||||
if (name == NULL) { /* should not occurr, but... */
|
if (name == NULL) { /* should not occurr, but... */
|
||||||
sc_log(ctx, "No module specified", name);
|
sc_log(ctx, "No module specified");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
libname = find_library(ctx, name);
|
libname = find_library(ctx, name);
|
||||||
|
|
|
@ -327,7 +327,8 @@ int dnie_read_file(sc_card_t * card,
|
||||||
goto dnie_read_file_err;
|
goto dnie_read_file_err;
|
||||||
}
|
}
|
||||||
/* call sc_read_binary() to retrieve data */
|
/* 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);
|
res = sc_read_binary(card, 0, data, fsize, 0L);
|
||||||
if (res < 0) { /* read_binary returns number of bytes readed */
|
if (res < 0) { /* read_binary returns number of bytes readed */
|
||||||
res = SC_ERROR_CARD_CMD_FAILED;
|
res = SC_ERROR_CARD_CMD_FAILED;
|
||||||
|
|
|
@ -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 */
|
if (apdu->datalen > 0) { /* apdu data to show */
|
||||||
buf = cwa_hexdump(apdu->data, apdu->datalen);
|
buf = cwa_hexdump(apdu->data, apdu->datalen);
|
||||||
sc_log(card->ctx,
|
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->cla, apdu->ins, apdu->p1, apdu->p2,
|
||||||
apdu->lc, apdu->le, apdu->datalen, buf);
|
apdu->lc, apdu->le, apdu->datalen, buf);
|
||||||
} else { /* apdu data field is empty */
|
} else { /* apdu data field is empty */
|
||||||
sc_log(card->ctx,
|
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->cla, apdu->ins, apdu->p1, apdu->p2,
|
||||||
apdu->lc, apdu->le);
|
apdu->lc, apdu->le);
|
||||||
}
|
}
|
||||||
} else { /* apdu response */
|
} else { /* apdu response */
|
||||||
buf = cwa_hexdump(apdu->resp, apdu->resplen);
|
buf = cwa_hexdump(apdu->resp, apdu->resplen);
|
||||||
sc_log(card->ctx,
|
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);
|
apdu->sw1, apdu->sw2, apdu->resplen, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -338,7 +338,7 @@ static int cwa_parse_tlv(sc_card_t * card,
|
||||||
}
|
}
|
||||||
tlv->data = buffer + n + j;
|
tlv->data = buffer + n + j;
|
||||||
tlv->buflen = j + tlv->len;;
|
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));
|
tlv->tag, tlv->len, sc_dump_hex(tlv->data, tlv->len));
|
||||||
/* set index to next Tag to jump to */
|
/* set index to next Tag to jump to */
|
||||||
next = tlv->buflen;
|
next = tlv->buflen;
|
||||||
|
@ -1571,7 +1571,7 @@ int cwa_encode_apdu(sc_card_t * card,
|
||||||
|
|
||||||
/* compose and add computed MAC TLV to result buffer */
|
/* compose and add computed MAC TLV to result buffer */
|
||||||
tlv_len = (card->atr.value[15] >= DNIE_30_VERSION)? 8 : 4;
|
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);
|
res = cwa_compose_tlv(card, 0x8E, tlv_len, macbuf, &apdubuf, &apdulen);
|
||||||
if (res != SC_SUCCESS) {
|
if (res != SC_SUCCESS) {
|
||||||
msg = "Encode APDU compose_tlv(0x87) failed";
|
msg = "Encode APDU compose_tlv(0x87) failed";
|
||||||
|
|
|
@ -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.df_selection = *(tag + 0);
|
||||||
ef_atr.unit_size = *(tag + 1);
|
ef_atr.unit_size = *(tag + 1);
|
||||||
ef_atr.card_capabilities = *(tag + 2);
|
ef_atr.card_capabilities = *(tag + 2);
|
||||||
sc_log(ctx, "EF.ATR: DF selection %X, unit_size %X, card caps %X",
|
sc_log(ctx,
|
||||||
ef_atr.df_selection, ef_atr.unit_size, ef_atr.card_capabilities);
|
"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) {
|
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 */
|
* We skip parsing the nested DOs and jump directly to the numbers */
|
||||||
ef_atr.max_command_apdu = bebytes2ushort(tag + 2);
|
ef_atr.max_command_apdu = bebytes2ushort(tag + 2);
|
||||||
ef_atr.max_response_apdu = bebytes2ushort(tag + 6);
|
ef_atr.max_response_apdu = bebytes2ushort(tag + 6);
|
||||||
sc_log(ctx, "EF.ATR: Biggest command APDU %u bytes, response APDU %u",
|
sc_log(ctx,
|
||||||
(unsigned long) ef_atr.max_command_apdu,
|
"EF.ATR: Biggest command APDU %"SC_FORMAT_LEN_SIZE_T"u bytes, response APDU %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
(unsigned long) ef_atr.max_response_apdu);
|
ef_atr.max_command_apdu,
|
||||||
|
ef_atr.max_response_apdu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -330,7 +330,9 @@ iasecc_se_parse(struct sc_card *card, unsigned char *data, size_t data_len, stru
|
||||||
|
|
||||||
data += size_size + 1;
|
data += size_size + 1;
|
||||||
data_len = size;
|
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)
|
if (*data != IASECC_SDO_TAG_HEADER)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
|
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 += 3 + size_size;
|
||||||
data_len = 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) {
|
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);
|
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;
|
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;
|
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);
|
rv = iasecc_parse_get_tlv(card, data + offs, &tlv);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_parse_chv() get and parse TLV error");
|
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)
|
if (tlv.tag == IASECC_SDO_CHV_TAG_SIZE_MAX)
|
||||||
chv->size_max = tlv;
|
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);
|
rv = iasecc_parse_get_tlv(card, data + offs, &tlv);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_parse_prvkey() get and parse TLV error");
|
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)
|
if (tlv.tag == IASECC_SDO_PRVKEY_TAG_COMPULSORY)
|
||||||
prvkey->compulsory = tlv;
|
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);
|
rv = iasecc_parse_get_tlv(card, data + offs, &tlv);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_parse_pubkey() get and parse TLV error");
|
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)
|
if (tlv.tag == IASECC_SDO_PUBKEY_TAG_N)
|
||||||
pubkey->n = tlv;
|
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);
|
rv = iasecc_parse_get_tlv(card, data + offs, &tlv);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_parse_keyset() get and parse TLV error");
|
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)
|
if (tlv.tag == IASECC_SDO_KEYSET_TAG_COMPULSORY)
|
||||||
keyset->compulsory = tlv;
|
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);
|
rv = iasecc_parse_get_tlv(card, data + offs, &tlv);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_parse_get_tlv() get and parse TLV error");
|
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) {
|
if (tlv.tag == IASECC_DOCP_TAG_ACLS) {
|
||||||
int _rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo);
|
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);
|
sc_log(ctx, "iasecc_sdo_parse_data() tlv.tag 0x%X", tlv.tag);
|
||||||
if (tlv.tag == IASECC_DOCP_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);
|
rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo);
|
||||||
sc_log(ctx, "iasecc_sdo_parse_data() parsed IASECC_DOCP_TAG rv %i", rv);
|
sc_log(ctx, "iasecc_sdo_parse_data() parsed IASECC_DOCP_TAG rv %i", rv);
|
||||||
free(tlv.value);
|
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 += size_size + 1;
|
||||||
data_len = size;
|
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)
|
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)
|
if (data_len != size + size_size + 3)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalide SDO data size");
|
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;
|
offs = 3 + size_size;
|
||||||
for (; offs < data_len;) {
|
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)
|
if (offs != data_len)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: not totaly parsed");
|
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);
|
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)
|
if (data_len != size + size_size + 3)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalide SDO data size");
|
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;
|
offs = 3 + size_size;
|
||||||
for (; offs < data_len;) {
|
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)
|
if (offs != data_len)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: not totaly parsed");
|
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);
|
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);
|
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.on_card) {
|
||||||
if (sdo->data.prv_key.compulsory.value) {
|
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].parent_tag = IASECC_SDO_PRVKEY_TAG;
|
||||||
sdo_update->fields[indx].tag = IASECC_SDO_PRVKEY_TAG_COMPULSORY;
|
sdo_update->fields[indx].tag = IASECC_SDO_PRVKEY_TAG_COMPULSORY;
|
||||||
sdo_update->fields[indx].value = sdo->data.prv_key.compulsory.value;
|
sdo_update->fields[indx].value = sdo->data.prv_key.compulsory.value;
|
||||||
|
|
|
@ -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);
|
sc_log(ctx, "iasecc_sm_transmit_apdus() rdata-length %i", rdata->length);
|
||||||
|
|
||||||
while (rapdu) {
|
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);
|
rv = sc_transmit_apdu(card, &rapdu->apdu);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_sm_transmit_apdus() failed to execute r-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);
|
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];
|
unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
|
||||||
int rv;
|
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);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x84, 0, 0);
|
||||||
apdu.le = len;
|
apdu.le = len;
|
||||||
apdu.resplen = len;
|
apdu.resplen = len;
|
||||||
|
@ -339,7 +339,9 @@ iasecc_sm_initialize(struct sc_card *card, unsigned se_num, unsigned cmd)
|
||||||
|
|
||||||
rdata.free(&rdata);
|
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)
|
if (cwa_session->mdata_len != 0x48)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "iasecc_sm_initialize() invalid MUTUAL AUTHENTICATE result data");
|
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) {
|
for (rapdu = rdata->data; rapdu; rapdu = rapdu->next) {
|
||||||
struct sc_apdu *apdu = &rapdu->apdu;
|
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)
|
if (!apdu->ins)
|
||||||
break;
|
break;
|
||||||
rv = sc_transmit_apdu(card, apdu);
|
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);
|
sc_log(ctx, "iasecc_sm_cmd() APDU error rv:%i", rv);
|
||||||
break;
|
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);
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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);
|
rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_CREATE);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_sm_create_file() SM INITIALIZE failed");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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);
|
rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_READ);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM INITIALIZE failed");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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);
|
rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_UPDATE);
|
||||||
LOG_TEST_RET(ctx, rv, "iasecc_sm_update_binary() SM INITIALIZE failed");
|
LOG_TEST_RET(ctx, rv, "iasecc_sm_update_binary() SM INITIALIZE failed");
|
||||||
|
|
|
@ -360,7 +360,8 @@ iso7816_process_fci(struct sc_card *card, struct sc_file *file,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
file->size = size;
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,7 +902,8 @@ iso7816_compute_signature(struct sc_card *card,
|
||||||
|
|
||||||
assert(card != NULL && data != NULL && out != NULL);
|
assert(card != NULL && data != NULL && out != NULL);
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
LOG_FUNC_CALLED(card->ctx);
|
||||||
sc_log(card->ctx, "ISO7816 compute signature: in-len %i, out-len %i",
|
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);
|
datalen, outlen);
|
||||||
|
|
||||||
/* INS: 0x2A PERFORM SECURITY OPERATION
|
/* INS: 0x2A PERFORM SECURITY OPERATION
|
||||||
|
@ -940,7 +942,9 @@ iso7816_decipher(struct sc_card *card,
|
||||||
|
|
||||||
assert(card != NULL && crgram != NULL && out != NULL);
|
assert(card != NULL && crgram != NULL && out != NULL);
|
||||||
LOG_FUNC_CALLED(card->ctx);
|
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);
|
sbuf = malloc(crgram_len + 1);
|
||||||
if (sbuf == NULL)
|
if (sbuf == NULL)
|
||||||
|
|
|
@ -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 */
|
if(apdu.resplen == 0) /* No more left */
|
||||||
return 0;
|
return 0;
|
||||||
if (apdu.resplen != 14) {
|
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;
|
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
||||||
}
|
}
|
||||||
memcpy(file->objectId.id, fileData, 4);
|
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_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x56, 0x00, 0x00);
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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);
|
memcpy(buffer, objectId.id, 4);
|
||||||
ulong2bebytes(buffer + 4, offset);
|
ulong2bebytes(buffer + 4, offset);
|
||||||
buffer[8] = (u8)dataLength;
|
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);
|
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x54, 0x00, 0x00);
|
||||||
apdu.lc = dataLength + 9;
|
apdu.lc = dataLength + 9;
|
||||||
if (card->ctx->debug >= 2)
|
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);
|
memcpy(buffer, objectId.id, 4);
|
||||||
ulong2bebytes(buffer + 4, offset);
|
ulong2bebytes(buffer + 4, offset);
|
||||||
|
|
|
@ -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;
|
*out_len = len - n;
|
||||||
memmove(out, data + n, *out_len);
|
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);
|
LOG_FUNC_RETURN(ctx, len - n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +285,7 @@ int sc_get_encoding_flags(sc_context_t *ctx,
|
||||||
if (pflags == NULL || sflags == NULL)
|
if (pflags == NULL || sflags == NULL)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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++) {
|
for (i = 0; digest_info_prefix[i].algorithm != 0; i++) {
|
||||||
if (iflags & digest_info_prefix[i].algorithm) {
|
if (iflags & digest_info_prefix[i].algorithm) {
|
||||||
if (digest_info_prefix[i].algorithm != SC_ALGORITHM_RSA_HASH_NONE &&
|
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");
|
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);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,9 @@ asn1_decode_ec_params(sc_context_t *ctx, void **paramp,
|
||||||
struct sc_asn1_entry asn1_ec_params[4];
|
struct sc_asn1_entry asn1_ec_params[4];
|
||||||
struct sc_ec_parameters *ecp;
|
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));
|
memset(&curve, 0, sizeof(curve));
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,8 @@ static int sc_pkcs15emu_cac_init(sc_pkcs15_card_t *p15card)
|
||||||
}
|
}
|
||||||
cert_info.path.count = cert_der.len;
|
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",
|
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);
|
cert_der.len, cert_info.path.count, r);
|
||||||
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "cert", cert_der.value, cert_der.len);
|
sc_debug_hex(card->ctx, SC_LOG_DEBUG_NORMAL, "cert", cert_der.value, cert_der.len);
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,9 @@ int sc_pkcs15_cache_file(struct sc_pkcs15_card *p15card,
|
||||||
c = fwrite(buf, 1, bufsize, f);
|
c = fwrite(buf, 1, bufsize, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
if (c != bufsize) {
|
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);
|
unlink(fname);
|
||||||
return SC_ERROR_INTERNAL;
|
return SC_ERROR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -487,8 +487,8 @@ static int sc_pkcs15emu_gemsafeGPK_init(sc_pkcs15_card_t *p15card)
|
||||||
|
|
||||||
for (j = 0; j < num_keyinfo; j++) {
|
for (j = 0; j < num_keyinfo; j++) {
|
||||||
if (sc_pkcs15_compare_id(&kinfo[j].id, &prkey_info.id)) {
|
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",
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "found key in file %d for id %s",
|
||||||
kinfo[j].fileid, prkey_info.id);
|
kinfo[j].fileid, prkeys[i].id);
|
||||||
prkey_info.path.value[0] = kinfo[j].fileid >> 8;
|
prkey_info.path.value[0] = kinfo[j].fileid >> 8;
|
||||||
prkey_info.path.value[1] = kinfo[j].fileid & 0xff;
|
prkey_info.path.value[1] = kinfo[j].fileid & 0xff;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -185,9 +185,11 @@ static int gemsafe_get_cert_len(sc_card_t *card)
|
||||||
* (allocated EF space is much greater!)
|
* (allocated EF space is much greater!)
|
||||||
*/
|
*/
|
||||||
objlen = (((size_t) ibuf[0]) << 8) | ibuf[1];
|
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) {
|
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;
|
return SC_ERROR_INTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +261,9 @@ static int gemsafe_get_cert_len(sc_card_t *card)
|
||||||
if (ind+3 >= sizeof ibuf)
|
if (ind+3 >= sizeof ibuf)
|
||||||
return SC_ERROR_INVALID_DATA;
|
return SC_ERROR_INVALID_DATA;
|
||||||
certlen = ((((size_t) ibuf[ind+2]) << 8) | ibuf[ind+3]) + 4;
|
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].index = ind;
|
||||||
gemsafe_cert[i].count = certlen;
|
gemsafe_cert[i].count = certlen;
|
||||||
ind += certlen;
|
ind += certlen;
|
||||||
|
|
|
@ -51,7 +51,8 @@ static int sc_pkcs15emu_gids_add_prkey(sc_pkcs15_card_t * p15card, sc_cardctl_gi
|
||||||
int r;
|
int r;
|
||||||
char ch_tmp[10];
|
char ch_tmp[10];
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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_info, 0, sizeof(prkey_info));
|
||||||
memset(&prkey_obj, 0, sizeof(prkey_obj));
|
memset(&prkey_obj, 0, sizeof(prkey_obj));
|
||||||
|
|
|
@ -389,7 +389,9 @@ sc_oberthur_parse_containers (struct sc_pkcs15_card *p15card,
|
||||||
struct container *cont;
|
struct container *cont;
|
||||||
unsigned char *ptr = buff + offs + 2;
|
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')
|
if (*(buff + offs) != 'R')
|
||||||
return SC_ERROR_INVALID_DATA;
|
return SC_ERROR_INVALID_DATA;
|
||||||
|
|
||||||
|
@ -1019,7 +1021,8 @@ sc_pkcs15emu_oberthur_init(struct sc_pkcs15_card * p15card)
|
||||||
&oberthur_infos[ii].content, &oberthur_infos[ii].len, 1);
|
&oberthur_infos[ii].content, &oberthur_infos[ii].len, 1);
|
||||||
LOG_TEST_RET(ctx, rv, "Oberthur init failed: read oberthur file error");
|
LOG_TEST_RET(ctx, rv, "Oberthur init failed: read oberthur file error");
|
||||||
|
|
||||||
sc_log(ctx, "Oberthur init: parse %s file, content length %i",
|
sc_log(ctx,
|
||||||
|
"Oberthur init: parse %s file, content length %"SC_FORMAT_LEN_SIZE_T"u",
|
||||||
oberthur_infos[ii].name, oberthur_infos[ii].len);
|
oberthur_infos[ii].name, oberthur_infos[ii].len);
|
||||||
rv = oberthur_infos[ii].parser(p15card, oberthur_infos[ii].content, oberthur_infos[ii].len,
|
rv = oberthur_infos[ii].parser(p15card, oberthur_infos[ii].content, oberthur_infos[ii].len,
|
||||||
oberthur_infos[ii].postpone_allowed);
|
oberthur_infos[ii].postpone_allowed);
|
||||||
|
|
|
@ -318,7 +318,9 @@ _sc_pkcs15_verify_pin(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *p
|
||||||
struct sc_pin_cmd_data data;
|
struct sc_pin_cmd_data data;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "PIN(type:%X; method:%X; value(%p:%i)", auth_info->auth_type, auth_info->auth_method,
|
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);
|
pincode, pinlen);
|
||||||
|
|
||||||
if (pinlen > SC_MAX_PIN_SIZE)
|
if (pinlen > SC_MAX_PIN_SIZE)
|
||||||
|
|
|
@ -505,7 +505,8 @@ sc_pkcs15_prkey_attrs_from_cert(struct sc_pkcs15_card *p15card, struct sc_pkcs15
|
||||||
ERR_load_ERR_strings();
|
ERR_load_ERR_strings();
|
||||||
ERR_load_crypto_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);
|
mem = BIO_new_mem_buf(cert_object->content.value, cert_object->content.len);
|
||||||
if (!mem)
|
if (!mem)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "MEM buffer allocation error");
|
LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "MEM buffer allocation error");
|
||||||
|
|
|
@ -726,7 +726,8 @@ sc_pkcs15_decode_pubkey_ec(sc_context_t *ctx,
|
||||||
if (*ecpoint_data != 0x04)
|
if (*ecpoint_data != 0x04)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Supported only uncompressed EC pointQ value");
|
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.len = ecpoint_len;
|
||||||
key->ecpointQ.value = ecpoint_data;
|
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);
|
r = sc_asn1_encode(ctx, asn1_ec_pointQ, buf, buflen);
|
||||||
LOG_TEST_RET(ctx, r, "ASN.1 encoding failed");
|
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);
|
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;
|
unsigned char *tmp_buf = NULL;
|
||||||
int r;
|
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);
|
tmp_buf = malloc(buflen);
|
||||||
if (!tmp_buf) {
|
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);
|
sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
|
||||||
|
|
||||||
ecparams->field_length = ec_curve_infos[ii].size;
|
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 */
|
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++) {
|
for (ii=0; ec_curve_infos[ii].name; ii++) {
|
||||||
|
|
|
@ -149,7 +149,9 @@ static int format_senv(struct sc_pkcs15_card *p15card,
|
||||||
case SC_PKCS15_TYPE_PRKEY_RSA:
|
case SC_PKCS15_TYPE_PRKEY_RSA:
|
||||||
*alg_info_out = sc_card_find_rsa_alg(p15card->card, prkey->modulus_length);
|
*alg_info_out = sc_card_find_rsa_alg(p15card->card, prkey->modulus_length);
|
||||||
if (*alg_info_out == NULL) {
|
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);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
senv_out->algorithm = SC_ALGORITHM_RSA;
|
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:
|
case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
|
||||||
*alg_info_out = sc_card_find_gostr3410_alg(p15card->card, prkey->modulus_length);
|
*alg_info_out = sc_card_find_gostr3410_alg(p15card->card, prkey->modulus_length);
|
||||||
if (*alg_info_out == NULL) {
|
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);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
senv_out->algorithm = SC_ALGORITHM_GOSTR3410;
|
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:
|
case SC_PKCS15_TYPE_PRKEY_EC:
|
||||||
*alg_info_out = sc_card_find_ec_alg(p15card->card, prkey->field_length, NULL);
|
*alg_info_out = sc_card_find_ec_alg(p15card->card, prkey->field_length, NULL);
|
||||||
if (*alg_info_out == 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);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
|
||||||
}
|
}
|
||||||
senv_out->algorithm = SC_ALGORITHM_EC;
|
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;
|
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);
|
flags, alg_info->flags, pad_flags, sec_flags);
|
||||||
|
|
||||||
/* add the padding bytes (if necessary) */
|
/* add the padding bytes (if necessary) */
|
||||||
|
|
|
@ -344,8 +344,8 @@ static int refresh_attributes(sc_reader_t *reader)
|
||||||
state = priv->reader_state.dwEventState;
|
state = priv->reader_state.dwEventState;
|
||||||
prev_state = priv->reader_state.dwCurrentState;
|
prev_state = priv->reader_state.dwCurrentState;
|
||||||
|
|
||||||
sc_log(reader->ctx, "current state: 0x%08X", state);
|
sc_log(reader->ctx, "current state: 0x%08X", (unsigned int)state);
|
||||||
sc_log(reader->ctx, "previous state: 0x%08X", prev_state);
|
sc_log(reader->ctx, "previous state: 0x%08X", (unsigned int)prev_state);
|
||||||
|
|
||||||
if (state & SCARD_STATE_UNKNOWN) {
|
if (state & SCARD_STATE_UNKNOWN) {
|
||||||
/* State means "reader unknown", but we have listed it at least once.
|
/* 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");
|
sc_log(reader->ctx, "Reconnecting to force protocol");
|
||||||
r = pcsc_reconnect(reader, SCARD_UNPOWER_CARD);
|
r = pcsc_reconnect(reader, SCARD_UNPOWER_CARD);
|
||||||
if (r != SC_SUCCESS) {
|
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;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,7 +615,8 @@ static int pcsc_lock(sc_reader_t *reader)
|
||||||
case SCARD_E_READER_UNAVAILABLE:
|
case SCARD_E_READER_UNAVAILABLE:
|
||||||
r = pcsc_connect(reader);
|
r = pcsc_connect(reader);
|
||||||
if (r != SC_SUCCESS) {
|
if (r != SC_SUCCESS) {
|
||||||
sc_log(reader->ctx, "pcsc_connect failed", r);
|
sc_log(reader->ctx, "pcsc_connect failed (%d)",
|
||||||
|
r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
/* return failure so that upper layers will be notified and try to lock again */
|
/* 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);
|
PCSC_TRACE(reader, "SCardBeginTransaction calling pcsc_reconnect", rv);
|
||||||
r = pcsc_reconnect(reader, SCARD_LEAVE_CARD);
|
r = pcsc_reconnect(reader, SCARD_LEAVE_CARD);
|
||||||
if (r != SC_SUCCESS) {
|
if (r != SC_SUCCESS) {
|
||||||
sc_log(reader->ctx, "pcsc_reconnect failed", r);
|
sc_log(reader->ctx,
|
||||||
|
"pcsc_reconnect failed (%d)", r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
/* return failure so that upper layers will be notified and try to lock again */
|
/* 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 =
|
gpriv->provider_library =
|
||||||
scconf_get_str(conf_block, "provider_library", 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"
|
sc_log(ctx,
|
||||||
" reconnect_action=%d enable_pinpad=%d enable_pace=%d",
|
"PC/SC options: connect_exclusive=%d disconnect_action=%u transaction_end_action=%u"
|
||||||
gpriv->connect_exclusive, gpriv->disconnect_action, gpriv->transaction_end_action,
|
" reconnect_action=%u enable_pinpad=%d enable_pace=%d",
|
||||||
gpriv->reconnect_action, gpriv->enable_pinpad, gpriv->enable_pace);
|
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);
|
gpriv->dlhandle = sc_dlopen(gpriv->provider_library);
|
||||||
if (gpriv->dlhandle == NULL) {
|
if (gpriv->dlhandle == NULL) {
|
||||||
|
@ -1106,7 +1114,10 @@ static void detect_reader_features(sc_reader_t *reader, SCARDHANDLE card_handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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;
|
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;
|
continue;
|
||||||
|
@ -1453,8 +1466,10 @@ static int pcsc_wait_for_event(sc_context_t *ctx, unsigned int event_mask, sc_re
|
||||||
*event = 0;
|
*event = 0;
|
||||||
for (i = 0, rsp = rgReaderStates; i < num_watch; i++, rsp++) {
|
for (i = 0, rsp = rgReaderStates; i < num_watch; i++, rsp++) {
|
||||||
DWORD state, prev_state;
|
DWORD state, prev_state;
|
||||||
sc_log(ctx, "'%s' before=0x%08X now=0x%08X", rsp->szReader,
|
sc_log(ctx, "'%s' before=0x%08X now=0x%08X",
|
||||||
rsp->dwCurrentState, rsp->dwEventState);
|
rsp->szReader,
|
||||||
|
(unsigned int)rsp->dwCurrentState,
|
||||||
|
(unsigned int)rsp->dwEventState);
|
||||||
prev_state = rsp->dwCurrentState;
|
prev_state = rsp->dwCurrentState;
|
||||||
state = rsp->dwEventState;
|
state = rsp->dwEventState;
|
||||||
rsp->dwCurrentState = 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;
|
gpriv->pcsc_ctx = *(SCARDCONTEXT *)pcsc_context_handle;
|
||||||
card_handle = *(SCARDHANDLE *)pcsc_card_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, \
|
if(gpriv->SCardGetAttrib(card_handle, SCARD_ATTR_DEVICE_SYSTEM_NAME_A, \
|
||||||
reader_name, &reader_name_size) == SCARD_S_SUCCESS)
|
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);
|
&state, &prot, atr, &atr_len);
|
||||||
if (rv != SCARD_S_SUCCESS)
|
if (rv != SCARD_S_SUCCESS)
|
||||||
{
|
{
|
||||||
sc_log(ctx, "SCardStatus failed %08x", rv);
|
sc_log(ctx, "SCardStatus failed %08lx", rv);
|
||||||
prot = SCARD_PROTOCOL_T0;
|
prot = SCARD_PROTOCOL_T0;
|
||||||
}
|
}
|
||||||
sc_log(ctx, "Set protocole to %s", \
|
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);
|
rv = gpriv->SCardControl(card_handle, CM_IOCTL_GET_FEATURE_REQUEST, NULL, 0, feature_buf, sizeof(feature_buf), &feature_len);
|
||||||
if (rv != SCARD_S_SUCCESS)
|
if (rv != SCARD_S_SUCCESS)
|
||||||
{
|
{
|
||||||
sc_log(ctx, "SCardControl failed %08x", rv);
|
sc_log(ctx, "SCardControl failed %08lx", rv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2536,7 +2553,10 @@ int cardmod_use_reader(sc_context_t *ctx, void * pcsc_context_handle, void * pcs
|
||||||
}
|
}
|
||||||
else
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ static void sc_pkcs11_print_attr(int level, const char *file, unsigned int line,
|
||||||
if (fm == NULL) {
|
if (fm == NULL) {
|
||||||
sc_do_log(context, level,
|
sc_do_log(context, level,
|
||||||
file, line, function,
|
file, line, function,
|
||||||
"%s: Attribute 0x%x = %s\n",
|
"%s: Attribute 0x%lx = %s\n",
|
||||||
info, attr->type, value);
|
info, attr->type, value);
|
||||||
} else {
|
} else {
|
||||||
sc_do_log(context, level,
|
sc_do_log(context, level,
|
||||||
|
|
|
@ -289,7 +289,8 @@ pkcs15_bind(struct sc_pkcs11_card *p11card, struct sc_app_info *app_info)
|
||||||
if (!p11card->nmechanisms) {
|
if (!p11card->nmechanisms) {
|
||||||
ck_rv = register_mechanisms(p11card);
|
ck_rv = register_mechanisms(p11card);
|
||||||
if (ck_rv != CKR_OK) {
|
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;
|
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);
|
rv = slot_get_token(slotID, &slot);
|
||||||
if (rv != CKR_OK) {
|
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;
|
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 */
|
/* 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);
|
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);
|
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) {
|
if (auth) {
|
||||||
pin_info = (struct sc_pkcs15_auth_info*) auth->data;
|
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;
|
*pHandle = handle;
|
||||||
|
|
||||||
list_append(&slot->objects, obj);
|
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.handle = handle;
|
||||||
obj->base.flags |= SC_PKCS11_OBJECT_SEEN;
|
obj->base.flags |= SC_PKCS11_OBJECT_SEEN;
|
||||||
obj->refcount++;
|
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");
|
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];
|
fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
|
||||||
if (!fw_data)
|
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)
|
if (typ == CKA_OPENSC_NON_REPUDIATION && *val)
|
||||||
*x509_usage |= SC_PKCS15INIT_X509_NON_REPUDIATION;
|
*x509_usage |= SC_PKCS15INIT_X509_NON_REPUDIATION;
|
||||||
if (typ == CKA_VERIFY || typ == CKA_WRAP || typ == CKA_ENCRYPT) {
|
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;
|
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)
|
if (typ == CKA_DERIVE && *val)
|
||||||
*x509_usage |= SC_PKCS15INIT_X509_KEY_AGREEMENT;
|
*x509_usage |= SC_PKCS15INIT_X509_KEY_AGREEMENT;
|
||||||
if (typ == CKA_SIGN || typ == CKA_UNWRAP || typ == CKA_DECRYPT) {
|
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;
|
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];
|
char priv_label[SC_PKCS15_MAX_LABEL_SIZE];
|
||||||
int rc, rv = CKR_OK;
|
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
|
if (pMechanism->mechanism != CKM_RSA_PKCS_KEY_PAIR_GEN
|
||||||
&& pMechanism->mechanism != CKM_GOSTR3410_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
|
unsigned sign_flags = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_SIGNRECOVER
|
||||||
| SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
|
| 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];
|
fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
|
||||||
if (!fw_data)
|
if (!fw_data)
|
||||||
return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_Sign");
|
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;
|
flags = SC_ALGORITHM_ECDSA_HASH_SHA1;
|
||||||
break;
|
break;
|
||||||
default:
|
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;
|
return CKR_MECHANISM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3572,7 +3583,9 @@ pkcs15_prkey_sign(struct sc_pkcs11_session *session, void *obj,
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
return sc_to_cryptoki_error(rv, "C_Sign");
|
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,
|
rv = sc_pkcs15_compute_signature(fw_data->p15_card, prkey->prv_p15obj, flags,
|
||||||
pData, ulDataLen, pSignature, *pulDataLen);
|
pData, ulDataLen, pSignature, *pulDataLen);
|
||||||
if (rv < 0 && !sc_pkcs11_conf.lock_login && !prkey_has_path) {
|
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)
|
if (!fw_data)
|
||||||
return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_DeriveKey");
|
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 */
|
/* See which of the alternative keys supports derivation */
|
||||||
while (prkey && !(prkey->prv_info->usage & SC_PKCS15_PRKEY_USAGE_DERIVE))
|
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)
|
if (!attr || !data)
|
||||||
return CKR_ATTRIBUTE_VALUE_INVALID;
|
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);
|
check_attribute_buffer(attr, data->data_len);
|
||||||
memcpy(attr->pValue, data->data, data->data_len);
|
memcpy(attr->pValue, data->data, data->data_len);
|
||||||
|
|
|
@ -252,7 +252,8 @@ sc_pkcs11_sign_init(struct sc_pkcs11_session *session, CK_MECHANISM_PTR pMechani
|
||||||
LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
|
LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
|
||||||
|
|
||||||
/* See if we support this mechanism type */
|
/* 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);
|
mt = sc_pkcs11_find_mechanism(p11card, pMechanism->mechanism, CKF_SIGN);
|
||||||
if (mt == NULL)
|
if (mt == NULL)
|
||||||
LOG_FUNC_RETURN(context, CKR_MECHANISM_INVALID);
|
LOG_FUNC_RETURN(context, CKR_MECHANISM_INVALID);
|
||||||
|
|
|
@ -286,7 +286,7 @@ static CK_RV sc_pkcs11_openssl_md_final(sc_pkcs11_operation_t *op,
|
||||||
EVP_MD_CTX *md_ctx = DIGEST_CTX(op);
|
EVP_MD_CTX *md_ctx = DIGEST_CTX(op);
|
||||||
|
|
||||||
if (*pulDigestLen < (unsigned) EVP_MD_CTX_size(md_ctx)) {
|
if (*pulDigestLen < (unsigned) EVP_MD_CTX_size(md_ctx)) {
|
||||||
sc_log(context, "Provided buffer too small: %ul < %d",
|
sc_log(context, "Provided buffer too small: %lu < %d",
|
||||||
*pulDigestLen, EVP_MD_CTX_size(md_ctx));
|
*pulDigestLen, EVP_MD_CTX_size(md_ctx));
|
||||||
*pulDigestLen = EVP_MD_CTX_size(md_ctx);
|
*pulDigestLen = EVP_MD_CTX_size(md_ctx);
|
||||||
return CKR_BUFFER_TOO_SMALL;
|
return CKR_BUFFER_TOO_SMALL;
|
||||||
|
|
|
@ -423,14 +423,14 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSlotList == NULL_PTR) {
|
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;
|
*pulCount = numMatches;
|
||||||
rv = CKR_OK;
|
rv = CKR_OK;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*pulCount < numMatches) {
|
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;
|
*pulCount = numMatches;
|
||||||
rv = CKR_BUFFER_TOO_SMALL;
|
rv = CKR_BUFFER_TOO_SMALL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -440,7 +440,7 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
||||||
*pulCount = numMatches;
|
*pulCount = numMatches;
|
||||||
rv = CKR_OK;
|
rv = CKR_OK;
|
||||||
|
|
||||||
sc_log(context, "returned %d slots\n", numMatches);
|
sc_log(context, "returned %lu slots\n", numMatches);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (found != NULL) {
|
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);
|
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 (rv == CKR_OK) {
|
||||||
if (slot->reader == NULL) {
|
if (slot->reader == NULL) {
|
||||||
rv = CKR_TOKEN_NOT_PRESENT;
|
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) {
|
if (now >= slot->slot_state_expires || now == 0) {
|
||||||
/* Update slot status */
|
/* Update slot status */
|
||||||
rv = card_detect(slot->reader);
|
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)
|
if (rv == CKR_TOKEN_NOT_RECOGNIZED || rv == CKR_OK)
|
||||||
slot->slot_info.flags |= CKF_TOKEN_PRESENT;
|
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)
|
if (rv == CKR_OK)
|
||||||
memcpy(pInfo, &slot->slot_info, sizeof(CK_SLOT_INFO));
|
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_log(context, "C_GetSlotInfo(0x%lx) = %s", slotID, lookup_enum( RV_T, rv));
|
||||||
sc_pkcs11_unlock();
|
sc_pkcs11_unlock();
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -333,7 +333,7 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||||
if (rv != CKR_OK)
|
if (rv != CKR_OK)
|
||||||
goto out;
|
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);
|
dump_template(SC_LOG_DEBUG_NORMAL, "C_FindObjectsInit()", pTemplate, ulCount);
|
||||||
|
|
||||||
rv = session_start_operation(session, SC_PKCS11_OPERATION_FIND,
|
rv = session_start_operation(session, SC_PKCS11_OPERATION_FIND,
|
||||||
|
@ -362,7 +362,8 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||||
if (object->ops->get_attribute(session, object, &private_attribute) != CKR_OK)
|
if (object->ops->get_attribute(session, object, &private_attribute) != CKR_OK)
|
||||||
continue;
|
continue;
|
||||||
if (is_private) {
|
if (is_private) {
|
||||||
sc_log(context, "Object %d/%d: Private object and not logged in.",
|
sc_log(context,
|
||||||
|
"Object %lu/%lu: Private object and not logged in.",
|
||||||
slot->id, object->handle);
|
slot->id, object->handle);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -373,20 +374,23 @@ C_FindObjectsInit(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||||
for (j = 0; j < ulCount; j++) {
|
for (j = 0; j < ulCount; j++) {
|
||||||
rv = object->ops->cmp_attribute(session, object, &pTemplate[j]);
|
rv = object->ops->cmp_attribute(session, object, &pTemplate[j]);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
sc_log(context, "Object %d/%d: Attribute 0x%x does NOT match.",
|
sc_log(context,
|
||||||
|
"Object %lu/%lu: Attribute 0x%lx does NOT match.",
|
||||||
slot->id, object->handle, pTemplate[j].type);
|
slot->id, object->handle, pTemplate[j].type);
|
||||||
match = 0;
|
match = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->debug >= 4) {
|
if (context->debug >= 4) {
|
||||||
sc_log(context, "Object %d/%d: Attribute 0x%x matches.",
|
sc_log(context,
|
||||||
|
"Object %lu/%lu: Attribute 0x%lx matches.",
|
||||||
slot->id, object->handle, pTemplate[j].type);
|
slot->id, object->handle, pTemplate[j].type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
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 */
|
/* Realloc handles - remove restriction on only 32 matching objects -dee */
|
||||||
if (operation->num_handles >= operation->allocated_handles) {
|
if (operation->num_handles >= operation->allocated_handles) {
|
||||||
operation->allocated_handles += SC_PKCS11_FIND_INC_HANDLES;
|
operation->allocated_handles += SC_PKCS11_FIND_INC_HANDLES;
|
||||||
|
|
|
@ -273,7 +273,7 @@ CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||||
goto out;
|
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;
|
slot = session->slot;
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ CK_RV C_Login(CK_SESSION_HANDLE hSession, /* the session's handle */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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 (slot->login_user >= 0) {
|
||||||
if ((CK_USER_TYPE) slot->login_user == userType)
|
if ((CK_USER_TYPE) slot->login_user == userType)
|
||||||
rv = CKR_USER_ALREADY_LOGGED_IN;
|
rv = CKR_USER_ALREADY_LOGGED_IN;
|
||||||
|
|
|
@ -329,14 +329,18 @@ again:
|
||||||
rv = CKR_OK;
|
rv = CKR_OK;
|
||||||
}
|
}
|
||||||
if (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;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(context, "%s: Creating 'generic' token.", reader->name);
|
sc_log(context, "%s: Creating 'generic' token.", reader->name);
|
||||||
rv = frameworks[i]->create_tokens(p11card, app_generic);
|
rv = frameworks[i]->create_tokens(p11card, app_generic);
|
||||||
if (rv != CKR_OK) {
|
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;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,14 +356,17 @@ again:
|
||||||
sc_log(context, "%s: Binding %s token.", reader->name, app_name);
|
sc_log(context, "%s: Binding %s token.", reader->name, app_name);
|
||||||
rv = frameworks[i]->bind(p11card, app_info);
|
rv = frameworks[i]->bind(p11card, app_info);
|
||||||
if (rv != CKR_OK) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(context, "%s: Creating %s token.", reader->name, app_name);
|
sc_log(context, "%s: Creating %s token.", reader->name, app_name);
|
||||||
rv = frameworks[i]->create_tokens(p11card, app_info);
|
rv = frameworks[i]->create_tokens(p11card, app_info);
|
||||||
if (rv != CKR_OK) {
|
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;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,7 +516,9 @@ CK_RV slot_find_changed(CK_SLOT_ID_PTR idp, int mask)
|
||||||
card_detect_all();
|
card_detect_all();
|
||||||
for (i=0; i<list_size(&virtual_slots); i++) {
|
for (i=0; i<list_size(&virtual_slots); i++) {
|
||||||
sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
|
sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
|
||||||
sc_log(context, "slot 0x%lx token: %d events: 0x%02X",slot->id, (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)
|
if ((slot->events & SC_EVENT_CARD_INSERTED)
|
||||||
&& !(slot->slot_info.flags & CKF_TOKEN_PRESENT)) {
|
&& !(slot->slot_info.flags & CKF_TOKEN_PRESENT)) {
|
||||||
/* If a token has not been initialized, clear the inserted event */
|
/* If a token has not been initialized, clear the inserted event */
|
||||||
|
|
|
@ -254,7 +254,8 @@ authentic_pkcs15_new_file(struct sc_profile *profile, struct sc_card *card,
|
||||||
file->path.count = -1;
|
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,
|
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));
|
file->path.type, sc_print_path(&file->path));
|
||||||
if (out)
|
if (out)
|
||||||
*out = file;
|
*out = file;
|
||||||
|
@ -525,8 +526,10 @@ authentic_pkcs15_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "create private key(keybits:%i,usage:%X,access:%X,ref:%X)", keybits,
|
sc_log(ctx,
|
||||||
key_info->usage, key_info->access_flags, key_info->key_reference);
|
"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))
|
if (keybits < 1024 || keybits > 2048 || (keybits % 256))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid RSA key size");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "generate key(bits:%i,path:%s,AuthID:%s\n", keybits,
|
sc_log(ctx,
|
||||||
sc_print_path(&key_info->path), sc_pkcs15_print_id(&object->auth_id));
|
"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))
|
if (!object->content.value || object->content.len != sizeof(struct sc_authentic_sdo))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "Store IAS/ECC key(keybits:%i,AuthID:%s,path:%s)",
|
sc_log(ctx,
|
||||||
keybits, sc_pkcs15_print_id(&object->auth_id), sc_print_path(&key_info->path));
|
"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))
|
if (!object->content.value || object->content.len != sizeof(struct sc_authentic_sdo))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data");
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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);
|
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");
|
LOG_TEST_GOTO_ERR(ctx, rv, "PRKEY_RSA instantiation file error");
|
||||||
|
|
|
@ -481,7 +481,8 @@ cardos_store_pin(sc_profile_t *profile, sc_card_t *card,
|
||||||
* "no padding required". */
|
* "no padding required". */
|
||||||
maxlen = MIN(profile->pin_maxlen, sizeof(pinpadded));
|
maxlen = MIN(profile->pin_maxlen, sizeof(pinpadded));
|
||||||
if (pin_len > maxlen) {
|
if (pin_len > maxlen) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "invalid pin length: %u (max %u)\n",
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
|
"invalid pin length: %"SC_FORMAT_LEN_SIZE_T"u (max %u)\n",
|
||||||
pin_len, maxlen);
|
pin_len, maxlen);
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,7 +289,8 @@ cflex_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_pkcs15_obj
|
||||||
case 1024: size = 326; break;
|
case 1024: size = 326; break;
|
||||||
case 2048: size = 646; break;
|
case 2048: size = 646; break;
|
||||||
default:
|
default:
|
||||||
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key size %u\n",
|
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
|
"Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
key_info->modulus_length);
|
key_info->modulus_length);
|
||||||
r = SC_ERROR_INVALID_ARGUMENTS;
|
r = SC_ERROR_INVALID_ARGUMENTS;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -365,7 +365,7 @@ static int entersafe_store_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
{
|
{
|
||||||
sc_debug(card->ctx,
|
sc_debug(card->ctx,
|
||||||
SC_LOG_DEBUG_NORMAL,
|
SC_LOG_DEBUG_NORMAL,
|
||||||
"Unsupported key size %u\n",
|
"Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
keybits);
|
keybits);
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ static int entersafe_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15ca
|
||||||
{
|
{
|
||||||
sc_debug(card->ctx,
|
sc_debug(card->ctx,
|
||||||
SC_LOG_DEBUG_NORMAL,
|
SC_LOG_DEBUG_NORMAL,
|
||||||
"Unsupported key size %u\n",
|
"Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
keybits);
|
keybits);
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,7 +371,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
|
||||||
file->ef_structure = structure;
|
file->ef_structure = structure;
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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->size, file->type, file->ef_structure, file->id,
|
||||||
file->path.len);
|
file->path.len);
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "file path: %s",
|
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_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));
|
sc_pkcs15_print_id(&key_info->id));
|
||||||
if (key->algorithm != SC_ALGORITHM_RSA
|
if (key->algorithm != SC_ALGORITHM_RSA
|
||||||
|| 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,
|
SC_TEST_RET(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
||||||
"create key: failed to create key file");
|
"create key: failed to create key file");
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "index %i; keybits %i\n", idx,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
keybits);
|
"index %"SC_FORMAT_LEN_SIZE_T"u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
|
idx, keybits);
|
||||||
if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
|
if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL,
|
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;
|
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,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
||||||
"create key: failed to create key file");
|
"create key: failed to create key file");
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "index %i; keybits %i\n", idx,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
keybits);
|
"index %"SC_FORMAT_LEN_SIZE_T"u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n",
|
||||||
|
idx, keybits);
|
||||||
if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
|
if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL,
|
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;
|
r = SC_ERROR_INVALID_ARGUMENTS;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -555,7 +560,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
+ pukf->path.value[pukf->path.len - 1];
|
+ pukf->path.value[pukf->path.len - 1];
|
||||||
|
|
||||||
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
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,
|
pukf->size, pukf->type, pukf->ef_structure, pukf->id,
|
||||||
sc_print_path(&pukf->path));
|
sc_print_path(&pukf->path));
|
||||||
|
|
||||||
|
|
|
@ -518,7 +518,9 @@ gpk_generate_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
sc_file_t *keyfile;
|
sc_file_t *keyfile;
|
||||||
int r, n;
|
int r, n;
|
||||||
|
|
||||||
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "path=%s, %d bits\n", sc_print_path(&key_info->path),
|
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);
|
key_info->modulus_length);
|
||||||
|
|
||||||
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
|
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
|
||||||
|
|
|
@ -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.value[file->path.len - 1] = file->id & 0xFF;
|
||||||
file->path.count = -1;
|
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));
|
sc_log(ctx, "path type %X; path '%s'", file->path.type, sc_print_path(&file->path));
|
||||||
|
|
||||||
if (out)
|
if (out)
|
||||||
|
@ -430,7 +432,7 @@ iasecc_sdo_set_key_acls_from_profile(struct sc_profile *profile, struct sc_card
|
||||||
*(sdo->docp.acls_contact.value + 0) = amb;
|
*(sdo->docp.acls_contact.value + 0) = amb;
|
||||||
memcpy(sdo->docp.acls_contact.value + 1, scb, cntr);
|
memcpy(sdo->docp.acls_contact.value + 1, scb, cntr);
|
||||||
|
|
||||||
sc_log(ctx, "AMB: %X, CNTR %i, %x %x %x %x %x %x",
|
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]);
|
amb, cntr, scb[0], scb[1], scb[2], scb[3], scb[4], scb[5], scb[6]);
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
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)",
|
sc_log(ctx, "SDO(class:%X,ref:%X,usage:%X)",
|
||||||
sdo_prvkey->sdo_class, sdo_prvkey->sdo_ref, sdo_prvkey->usage);
|
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_log(ctx, "SDO ACLs(%"SC_FORMAT_LEN_SIZE_T"u):%s",
|
||||||
sc_dump_hex(sdo_prvkey->docp.acls_contact.value, sdo_prvkey->docp.acls_contact.size));
|
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_log(ctx, "SDO AMB:%X, SCBS:%s", sdo_prvkey->docp.amb,
|
||||||
sc_dump_hex(sdo_prvkey->docp.scbs, IASECC_MAX_SCBS));
|
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;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "create private key(keybits:%i,usage:%X,access:%X,ref:%X)",
|
sc_log(ctx,
|
||||||
keybits, key_info->usage, key_info->access_flags, key_info->key_reference);
|
"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)) {
|
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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,8 +1118,10 @@ iasecc_pkcs15_generate_key(struct sc_profile *profile, sc_pkcs15_card_t *p15card
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "generate key(bits:%i,path:%s,AuthID:%s\n", keybits,
|
sc_log(ctx,
|
||||||
sc_print_path(&key_info->path), sc_pkcs15_print_id(&object->auth_id));
|
"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))
|
if (!object->content.value || object->content.len != sizeof(struct iasecc_sdo))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data");
|
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");
|
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "'Magic' control failed for SDO PrvKey");
|
||||||
|
|
||||||
if (keybits < 1024 || keybits > 2048 || (keybits%0x100)) {
|
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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,8 +1214,10 @@ iasecc_pkcs15_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15ca
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "Store IAS/ECC key(keybits:%i,AuthID:%s,path:%s)",
|
sc_log(ctx,
|
||||||
keybits, sc_pkcs15_print_id(&object->auth_id), sc_print_path(&key_info->path));
|
"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))
|
if (!object->content.value || object->content.len != sizeof(struct iasecc_sdo))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data");
|
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)
|
if (sdo_prvkey->magic != SC_CARDCTL_IASECC_SDO_MAGIC)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "'Magic' control failed for SDO PrvKey");
|
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)",
|
sc_log(ctx,
|
||||||
sdo_prvkey->data.prv_key.compulsory.size, sdo_prvkey->data.prv_key.compulsory.on_card);
|
"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);
|
rv = sc_profile_get_parent(profile, "private-key", &file);
|
||||||
LOG_TEST_RET(ctx, rv, "cannot instantiate parent DF of the private key");
|
LOG_TEST_RET(ctx, rv, "cannot instantiate parent DF of the private key");
|
||||||
|
|
|
@ -1741,8 +1741,10 @@ sc_pkcs15init_store_certificate(struct sc_pkcs15_card *p15card,
|
||||||
cert_info->path = existing_path;
|
cert_info->path = existing_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_log(ctx, "Store cert(%.*s,ID:%s,der(%p,%i))", (int) sizeof object->label, object->label,
|
sc_log(ctx, "Store cert(%.*s,ID:%s,der(%p,%"SC_FORMAT_LEN_SIZE_T"u))",
|
||||||
sc_pkcs15_print_id(&cert_info->id), args->der_encoded.value, args->der_encoded.len);
|
(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)
|
if (!profile->pkcs15.direct_certificates)
|
||||||
r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &cert_info->path);
|
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);
|
return sc_pkcs15init_keybits(&key->u.dsa.q);
|
||||||
case SC_ALGORITHM_GOSTR3410:
|
case SC_ALGORITHM_GOSTR3410:
|
||||||
if (sc_pkcs15init_keybits(&key->u.gostr3410.d) > SC_PKCS15_GOSTR3410_KEYSIZE) {
|
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_ERROR_OBJECT_NOT_VALID;
|
||||||
}
|
}
|
||||||
return SC_PKCS15_GOSTR3410_KEYSIZE;
|
return SC_PKCS15_GOSTR3410_KEYSIZE;
|
||||||
case SC_ALGORITHM_EC:
|
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) {
|
if (key->u.ec.params.field_length == 0) {
|
||||||
sc_log(ctx, "Invalid EC key length");
|
sc_log(ctx, "Invalid EC key length");
|
||||||
return SC_ERROR_OBJECT_NOT_VALID;
|
return SC_ERROR_OBJECT_NOT_VALID;
|
||||||
|
@ -2597,7 +2602,8 @@ select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
if (!name)
|
if (!name)
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
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;
|
indx_id.len = 1;
|
||||||
for (indx = TEMPLATE_INSTANTIATE_MIN_INDEX; indx <= TEMPLATE_INSTANTIATE_MAX_INDEX; indx++) {
|
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);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
reference = pin_id;
|
reference = pin_id;
|
||||||
type = SC_AC_CHV;
|
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) {
|
if (path && path->len) {
|
||||||
|
@ -3414,7 +3420,10 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pin_obj) {
|
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.value && pin_obj->content.len) {
|
||||||
if (pin_obj->content.len > sizeof(pinbuf))
|
if (pin_obj->content.len > sizeof(pinbuf))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "PIN buffer is too small");
|
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) {
|
if (callbacks.get_pin) {
|
||||||
pinsize = sizeof(pinbuf);
|
pinsize = sizeof(pinbuf);
|
||||||
r = callbacks.get_pin(profile, pin_id, &auth_info, label, pinbuf, &pinsize);
|
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;
|
break;
|
||||||
case SC_AC_SCB:
|
case SC_AC_SCB:
|
||||||
|
@ -3667,8 +3678,10 @@ sc_pkcs15init_update_file(struct sc_profile *profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected_file->size < datalen) {
|
if (selected_file->size < datalen) {
|
||||||
sc_log(ctx, "File %s too small (require %u, have %u)",
|
sc_log(ctx,
|
||||||
sc_print_path(&file->path), datalen, selected_file->size);
|
"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);
|
sc_file_free(selected_file);
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_FILE_TOO_SMALL, "Update file failed");
|
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;
|
pin_attrs = &auth_info->attrs.pin;
|
||||||
|
|
||||||
if (pin_len < pin_attrs->min_length) {
|
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);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH);
|
||||||
}
|
}
|
||||||
if (pin_len > pin_attrs->max_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);
|
LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -290,8 +290,10 @@ myeid_create_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "PIN('%s',ref:%i,flags:0x%X,pin_len:%d,puk_len:%d)\n",
|
sc_log(ctx,
|
||||||
pin_obj->label, auth_info->attrs.pin.reference, auth_info->attrs.pin.flags, pin_len, puk_len);
|
"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)
|
if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
|
||||||
return SC_ERROR_OBJECT_NOT_VALID;
|
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) {
|
else if (object->type == SC_PKCS15_TYPE_PRKEY_EC) {
|
||||||
struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)key_info->params.data;
|
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;
|
pubkey->algorithm = SC_ALGORITHM_EC;
|
||||||
|
|
||||||
r = sc_select_file(card, &file->path, NULL);
|
r = sc_select_file(card, &file->path, NULL);
|
||||||
|
|
|
@ -170,7 +170,8 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
ifile->path.value[ifile->path.len-2] |= 0x01;
|
ifile->path.value[ifile->path.len-2] |= 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info_file(id:%04X,size:%i,rlen:%i)",
|
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);
|
ifile->id, ifile->size, ifile->record_length);
|
||||||
*info_out = ifile;
|
*info_out = ifile;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +181,9 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ofile) {
|
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)
|
if (obj_out)
|
||||||
*obj_out = ofile;
|
*obj_out = ofile;
|
||||||
else
|
else
|
||||||
|
@ -346,7 +349,9 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
|
||||||
unsigned char *buff = NULL;
|
unsigned char *buff = NULL;
|
||||||
|
|
||||||
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
|
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)",
|
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);
|
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;
|
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) = COSM_LIST_TAG;
|
||||||
*(buff + ii + 1) = (file->id >> 8) & 0xFF;
|
*(buff + ii + 1) = (file->id >> 8) & 0xFF;
|
||||||
*(buff + ii + 2) = file->id & 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.value = (unsigned char *)strdup(obj->label);
|
||||||
ki->label.len = strlen(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.
|
* 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);
|
ki->modulus.value = malloc(pubkey->modulus.len);
|
||||||
if (!ki->modulus.value) {
|
if (!ki->modulus.value) {
|
||||||
r = SC_ERROR_OUT_OF_MEMORY;
|
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;
|
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_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
sc_pkcs15_print_id(&cert_info->id), obj->content.value, obj->content.len);
|
"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));
|
memset(&pubkey, 0, sizeof(pubkey));
|
||||||
|
|
||||||
ci->label.value = (unsigned char *)strdup(obj->label);
|
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;
|
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_debug(ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
sc_pkcs15_print_id(&data_info->id), obj->content.value, obj->content.len);
|
"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;
|
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");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "COSM new file error");
|
||||||
|
|
||||||
memset(&icert, 0, sizeof(icert));
|
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);
|
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");
|
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");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "New private key info file error");
|
||||||
|
|
||||||
pubkey.algorithm = SC_ALGORITHM_RSA;
|
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);
|
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");
|
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");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "New public key info file error");
|
||||||
|
|
||||||
pubkey.algorithm = SC_ALGORITHM_RSA;
|
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);
|
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");
|
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");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "COSM new file error");
|
||||||
|
|
||||||
memset(&idata, 0, sizeof(idata));
|
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);
|
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");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Data' update DF failed: cannot encode info");
|
||||||
|
|
||||||
|
|
|
@ -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_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)
|
if (!pin || pin_len>0x40)
|
||||||
return SC_ERROR_INVALID_ARGUMENTS;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
if (puk && !puk_len)
|
if (puk && !puk_len)
|
||||||
|
@ -534,8 +536,9 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
|
||||||
file->ef_structure = structure;
|
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,
|
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
|
||||||
file->type, file->ef_structure, file->id);
|
"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;
|
*out = file;
|
||||||
|
|
||||||
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_SUCCESS);
|
||||||
|
|
|
@ -279,7 +279,9 @@ static int openpgp_store_data(struct sc_pkcs15_card *p15card, struct sc_profile
|
||||||
r = sc_select_file(card, path, &file);
|
r = sc_select_file(card, path, &file);
|
||||||
LOG_TEST_RET(card->ctx, r, "Cannot select cert file");
|
LOG_TEST_RET(card->ctx, r, "Cannot select cert file");
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
|
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)
|
if (r >= 0 && content->len)
|
||||||
r = sc_put_data(p15card->card, 0x7F21, (const unsigned char *) content->value, content->len);
|
r = sc_put_data(p15card->card, 0x7F21, (const unsigned char *) content->value, content->len);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -321,7 +321,9 @@ static int rtecp_create_key(sc_profile_t *profile, sc_pkcs15_card_t *p15card,
|
||||||
&& key_info->modulus_length
|
&& key_info->modulus_length
|
||||||
!= SC_PKCS15_GOSTR3410_KEYSIZE))
|
!= 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;
|
return SC_ERROR_INVALID_ARGUMENTS;
|
||||||
}
|
}
|
||||||
if (obj->type == SC_PKCS15_TYPE_PRKEY_GOSTR3410)
|
if (obj->type == SC_PKCS15_TYPE_PRKEY_GOSTR3410)
|
||||||
|
|
|
@ -486,7 +486,8 @@ setcos_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
|
|
||||||
keybits = ((raw_pubkey[0] * 256) + raw_pubkey[1]); /* modulus bit length */
|
keybits = ((raw_pubkey[0] * 256) + raw_pubkey[1]); /* modulus bit length */
|
||||||
if (keybits != key_info->modulus_length) {
|
if (keybits != key_info->modulus_length) {
|
||||||
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key-size from card[%i] does not match[%i]\n",
|
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);
|
keybits, key_info->modulus_length);
|
||||||
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PKCS15INIT, "Failed to generate key");
|
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_PKCS15INIT, "Failed to generate key");
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,9 @@ sm_encrypt_des_cbc3(struct sc_context *ctx, unsigned char *key,
|
||||||
size_t data_len, st;
|
size_t data_len, st;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (!out || !out_len)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "SM encrypt_des_cbc3: invalid input arguments");
|
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);
|
memcpy(data + in_len, "\x80\0\0\0\0\0\0\0", 8);
|
||||||
data_len = in_len + (not_force_pad ? 7 : 8);
|
data_len = in_len + (not_force_pad ? 7 : 8);
|
||||||
data_len -= (data_len%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_len = data_len;
|
||||||
*out = malloc(data_len + 8);
|
*out = malloc(data_len + 8);
|
||||||
|
|
|
@ -143,7 +143,8 @@ sm_authentic_get_apdus(struct sc_context *ctx, struct sm_info *sm_info,
|
||||||
if (!sm_info)
|
if (!sm_info)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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));
|
sc_log(ctx, "SM get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
||||||
|
|
||||||
if (init_data) {
|
if (init_data) {
|
||||||
|
|
|
@ -67,7 +67,9 @@ sm_iasecc_get_apdu_read_binary(struct sc_context *ctx, struct sm_info *sm_info,
|
||||||
if (!rdata || !rdata->alloc)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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;
|
offs = cmd_data->offs;
|
||||||
while (cmd_data->count > 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);
|
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)
|
if (!rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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;
|
offs = cmd_data->offs;
|
||||||
while (data_offs < cmd_data->count) {
|
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);
|
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)
|
if (!cmd_data || !cmd_data->data || !rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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);
|
rv = rdata->alloc(rdata, &rapdu);
|
||||||
LOG_TEST_RET(ctx, rv, "SM get 'UPDATE BINARY' APDUs: cannot allocate remote APDU");
|
LOG_TEST_RET(ctx, rv, "SM get 'UPDATE BINARY' APDUs: cannot allocate remote APDU");
|
||||||
|
@ -231,7 +237,7 @@ sm_iasecc_get_apdu_verify_pin(struct sc_context *ctx, struct sm_info *sm_info, s
|
||||||
if (!pin_data || !rdata || !rdata->alloc)
|
if (!pin_data || !rdata || !rdata->alloc)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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");
|
LOG_TEST_RET(ctx, rv, "SM get 'VERIFY PIN' APDUs: cannot allocate remote APDU");
|
||||||
|
@ -505,7 +511,8 @@ sm_iasecc_get_apdus(struct sc_context *ctx, struct sm_info *sm_info,
|
||||||
if (!sm_info)
|
if (!sm_info)
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
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: rdata:%p", rdata);
|
||||||
sc_log(ctx, "SM IAS/ECC get APDUs: serial %s", sc_dump_hex(sm_info->serialnr.value, sm_info->serialnr.len));
|
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);
|
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) {
|
for (rapdu = rdata->data; rapdu; rapdu = rapdu->next) {
|
||||||
unsigned char *decrypted;
|
unsigned char *decrypted;
|
||||||
size_t decrypted_len;
|
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];
|
unsigned char ticket[8];
|
||||||
size_t ticket_len = sizeof(ticket);
|
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_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);
|
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);
|
&decrypted, &decrypted_len);
|
||||||
LOG_TEST_RET(ctx, rv, "IAS/ECC decode answer(s): cannot decrypt card answer data");
|
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)
|
while(*(decrypted + decrypted_len - 1) == 0x00)
|
||||||
decrypted_len--;
|
decrypted_len--;
|
||||||
if (*(decrypted + decrypted_len - 1) != 0x80)
|
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);
|
memcpy(out + offs, decrypted, decrypted_len);
|
||||||
|
|
||||||
offs += 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);
|
free(decrypted);
|
||||||
|
|
|
@ -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);
|
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");
|
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)) {
|
if (memcmp(decrypted, session_data->icc.rnd, 8)) {
|
||||||
free(decrypted);
|
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);
|
rv = sm_encrypt_des_cbc3(ctx, cwa_keyset->enc, buf, offs, &encrypted, &encrypted_len, 1);
|
||||||
LOG_TEST_RET(ctx, rv, "_encrypt_des_cbc3() failed");
|
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);
|
memcpy(buf, encrypted, encrypted_len);
|
||||||
offs = encrypted_len;
|
offs = encrypted_len;
|
||||||
|
|
||||||
rv = sm_cwa_get_mac(ctx, cwa_keyset->mac, &icv, buf, offs, &cblock, 1);
|
rv = sm_cwa_get_mac(ctx, cwa_keyset->mac, &icv, buf, offs, &cblock, 1);
|
||||||
LOG_TEST_RET(ctx, rv, "sm_ecc_get_mac() failed");
|
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->cse = SC_APDU_CASE_4_SHORT;
|
||||||
apdu->cla = 0x00;
|
apdu->cla = 0x00;
|
||||||
|
@ -315,14 +319,17 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
sc_log(ctx, "securize APDU (cla:%X,ins:%X,p1:%X,p2:%X,data(%i):%p)",
|
sc_log(ctx,
|
||||||
apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data);
|
"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));
|
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);
|
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");
|
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;
|
offs = 0;
|
||||||
if (apdu->ins & 0x01) {
|
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);
|
memcpy(edfb_data + offs, encrypted, encrypted_len);
|
||||||
offs += encrypted_len;
|
offs += encrypted_len;
|
||||||
edfb_len = offs;
|
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);
|
free(encrypted);
|
||||||
encrypted = NULL;
|
encrypted = NULL;
|
||||||
|
@ -368,7 +376,8 @@ sm_cwa_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info, struct sc_
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
mac_len = offs;
|
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));
|
memset(icv, 0, sizeof(icv));
|
||||||
rv = sm_cwa_get_mac(ctx, session_data->session_mac, &icv, mac_data, mac_len, &cblock, 0);
|
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;
|
sbuf[offs++] = 8;
|
||||||
memcpy(sbuf + offs, cblock, 8);
|
memcpy(sbuf + offs, cblock, 8);
|
||||||
offs += 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))
|
if (offs > sizeof(rapdu->sbuf))
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "securize APDU: buffer too small for encrypted data");
|
LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "securize APDU: buffer too small for encrypted data");
|
||||||
|
|
|
@ -321,7 +321,9 @@ sm_gp_encrypt_command_data(struct sc_context *ctx, unsigned char *session_key,
|
||||||
if (!out || !out_len)
|
if (!out || !out_len)
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "SM GP encrypt command data error");
|
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) {
|
if (in==NULL || in_len==0) {
|
||||||
*out = NULL;
|
*out = NULL;
|
||||||
*out_len = 0;
|
*out_len = 0;
|
||||||
|
@ -363,7 +365,8 @@ sm_gp_securize_apdu(struct sc_context *ctx, struct sm_info *sm_info,
|
||||||
LOG_FUNC_CALLED(ctx);
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
|
||||||
apdu_data = (unsigned char *)apdu->data;
|
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",
|
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->cse, apdu->cla, apdu->ins, apdu->datalen, apdu->data,
|
||||||
apdu->lc, gp_level, gp_index);
|
apdu->lc, gp_level, gp_index);
|
||||||
|
|
||||||
|
@ -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)
|
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");
|
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 {
|
else {
|
||||||
LOG_TEST_RET(ctx, SC_ERROR_SM_INVALID_LEVEL, "SM GP securize APDU: invalid SM level");
|
LOG_TEST_RET(ctx, SC_ERROR_SM_INVALID_LEVEL, "SM GP securize APDU: invalid SM level");
|
||||||
|
|
|
@ -87,7 +87,8 @@ sm_gp_config_get_keyset(struct sc_context *ctx, struct sm_info *sm_info)
|
||||||
return SC_ERROR_UNKNOWN_DATA_RECEIVED;
|
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 )
|
if (hex_len != 16 && hex_len != 48 )
|
||||||
return SC_ERROR_INVALID_DATA;
|
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;
|
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) {
|
if (strlen(value) == 16) {
|
||||||
memcpy(cwa_keyset->enc, 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;
|
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)
|
if (hex_len != 16)
|
||||||
return SC_ERROR_INVALID_DATA;
|
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;
|
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) {
|
if (strlen(value) == 16) {
|
||||||
memcpy(cwa_keyset->mac, 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;
|
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)
|
if (hex_len != 16)
|
||||||
return SC_ERROR_INVALID_DATA;
|
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)) {
|
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;
|
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;
|
int rv = SC_ERROR_INTERNAL;
|
||||||
|
|
||||||
LOG_FUNC_CALLED(ctx);
|
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)
|
if (!sm_info || !rdata)
|
||||||
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
|
|
||||||
|
|
|
@ -530,7 +530,8 @@ static int list_data_objects(void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
sc_pkcs15_free_data_object(data_object);
|
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 {
|
} else {
|
||||||
printf(" AuthID:%-3s", sc_pkcs15_print_id(&objs[i]->auth_id));
|
printf(" AuthID:%-3s", sc_pkcs15_print_id(&objs[i]->auth_id));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue