libopensc: homogenise line ending in the debug messages

continuating r4759


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4774 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
viktor.tarasov 2010-09-25 20:35:59 +00:00
parent 10a99dc055
commit 58c1c88efa
7 changed files with 59 additions and 60 deletions

View File

@ -258,7 +258,7 @@ static const char *find_library(sc_context_t *ctx, const char *name)
#else #else
if (libname && libname[0] != '/' ) { if (libname && libname[0] != '/' ) {
#endif #endif
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "warning: relative path to driver '%s' used\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "warning: relative path to driver '%s' used",
libname); libname);
} }
break; break;
@ -284,7 +284,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_debug(ctx, SC_LOG_DEBUG_NORMAL,"No module specified\n",name); sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"No module specified",name);
return NULL; return NULL;
} }
libname = find_library(ctx, name); libname = find_library(ctx, name);
@ -292,7 +292,7 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name
return NULL; return NULL;
handle = lt_dlopen(libname); handle = lt_dlopen(libname);
if (handle == NULL) { if (handle == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Module %s: cannot load %s library: %s\n", name, libname, lt_dlerror()); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Module %s: cannot load %s library: %s", name, libname, lt_dlerror());
return NULL; return NULL;
} }
@ -300,7 +300,7 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name
*(void **)tmodi = lt_dlsym(handle, "sc_module_init"); *(void **)tmodi = lt_dlsym(handle, "sc_module_init");
*(void **)tmodv = lt_dlsym(handle, "sc_driver_version"); *(void **)tmodv = lt_dlsym(handle, "sc_driver_version");
if (modinit == NULL || modversion == NULL) { if (modinit == NULL || modversion == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "dynamic library '%s' is not a OpenSC module\n",libname); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "dynamic library '%s' is not a OpenSC module",libname);
lt_dlclose(handle); lt_dlclose(handle);
return NULL; return NULL;
} }
@ -308,12 +308,12 @@ static void *load_dynamic_driver(sc_context_t *ctx, void **dll, const char *name
version = modversion(); version = modversion();
/* XXX: We really need to have ABI version for each interface */ /* XXX: We really need to have ABI version for each interface */
if (version == NULL || strncmp(version, PACKAGE_VERSION, strlen(PACKAGE_VERSION)) != 0) { if (version == NULL || strncmp(version, PACKAGE_VERSION, strlen(PACKAGE_VERSION)) != 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"dynamic library '%s': invalid module version\n",libname); sc_debug(ctx, SC_LOG_DEBUG_NORMAL,"dynamic library '%s': invalid module version",libname);
lt_dlclose(handle); lt_dlclose(handle);
return NULL; return NULL;
} }
*dll = handle; *dll = handle;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "successfully loaded card driver '%s'\n", name); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "successfully loaded card driver '%s'", name);
return modinit(name); return modinit(name);
} }
@ -366,7 +366,7 @@ static int load_card_drivers(sc_context_t *ctx,
*(void **)(tfunc) = load_dynamic_driver(ctx, &dll, ent->name); *(void **)(tfunc) = load_dynamic_driver(ctx, &dll, ent->name);
/* if still null, assume driver not found */ /* if still null, assume driver not found */
if (func == NULL) { if (func == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to load '%s'.\n", ent->name); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to load '%s'.", ent->name);
continue; continue;
} }
@ -625,12 +625,12 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm)
} }
process_config_file(ctx, &opts); process_config_file(ctx, &opts);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "===================================\n"); /* first thing in the log */ sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "==================================="); /* first thing in the log */
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "opensc version: %s\n", sc_get_version()); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "opensc version: %s", sc_get_version());
/* initialize ltdl */ /* initialize ltdl */
if (lt_dlinit() != 0) { if (lt_dlinit() != 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lt_dlinit failed\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lt_dlinit failed");
sc_release_context(ctx); sc_release_context(ctx);
return SC_ERROR_OUT_OF_MEMORY; return SC_ERROR_OUT_OF_MEMORY;
} }
@ -710,7 +710,7 @@ int sc_release_context(sc_context_t *ctx)
if (ctx->mutex != NULL) { if (ctx->mutex != NULL) {
int r = sc_mutex_destroy(ctx, ctx->mutex); int r = sc_mutex_destroy(ctx, ctx->mutex);
if (r != SC_SUCCESS) { if (r != SC_SUCCESS) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to destroy mutex\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to destroy mutex");
return r; return r;
} }
} }
@ -819,6 +819,6 @@ int sc_make_cache_dir(sc_context_t *ctx)
return SC_SUCCESS; return SC_SUCCESS;
/* for lack of a better return code */ /* for lack of a better return code */
failed: sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "failed to create cache directory\n"); failed: sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "failed to create cache directory");
return SC_ERROR_INTERNAL; return SC_ERROR_INTERNAL;
} }

View File

@ -87,22 +87,22 @@ static int iso7816_check_sw(sc_card_t *card, unsigned int sw1, unsigned int sw2)
/* Handle special cases here */ /* Handle special cases here */
if (sw1 == 0x6C) { if (sw1 == 0x6C) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Wrong length; correct length is %d\n", sw2); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Wrong length; correct length is %d", sw2);
return SC_ERROR_WRONG_LENGTH; return SC_ERROR_WRONG_LENGTH;
} }
if (sw1 == 0x90) if (sw1 == 0x90)
return SC_NO_ERROR; return SC_NO_ERROR;
if (sw1 == 0x63U && (sw2 & ~0x0fU) == 0xc0U ) { if (sw1 == 0x63U && (sw2 & ~0x0fU) == 0xc0U ) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Verification failed (remaining tries: %d)\n", sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Verification failed (remaining tries: %d)",
(sw2 & 0x0f)); (sw2 & 0x0f));
return SC_ERROR_PIN_CODE_INCORRECT; return SC_ERROR_PIN_CODE_INCORRECT;
} }
for (i = 0; i < err_count; i++) for (i = 0; i < err_count; i++)
if (iso7816_errors[i].SWs == ((sw1 << 8) | sw2)) { if (iso7816_errors[i].SWs == ((sw1 << 8) | sw2)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s\n", iso7816_errors[i].errorstr); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "%s", iso7816_errors[i].errorstr);
return iso7816_errors[i].errorno; return iso7816_errors[i].errorno;
} }
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
return SC_ERROR_CARD_CMD_FAILED; return SC_ERROR_CARD_CMD_FAILED;
} }
@ -169,7 +169,7 @@ static int iso7816_write_record(sc_card_t *card, unsigned int rec_nr,
int r; int r;
if (count > 256) { if (count > 256) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Trying to send too many bytes\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Trying to send too many bytes");
return SC_ERROR_INVALID_ARGUMENTS; return SC_ERROR_INVALID_ARGUMENTS;
} }
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD2, rec_nr, 0); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD2, rec_nr, 0);
@ -196,7 +196,7 @@ static int iso7816_append_record(sc_card_t *card,
int r; int r;
if (count > 256) { if (count > 256) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Trying to send too many bytes\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Trying to send too many bytes");
return SC_ERROR_INVALID_ARGUMENTS; return SC_ERROR_INVALID_ARGUMENTS;
} }
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE2, 0, 0); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE2, 0, 0);
@ -221,7 +221,7 @@ static int iso7816_update_record(sc_card_t *card, unsigned int rec_nr,
int r; int r;
if (count > 256) { if (count > 256) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Trying to send too many bytes\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Trying to send too many bytes");
return SC_ERROR_INVALID_ARGUMENTS; return SC_ERROR_INVALID_ARGUMENTS;
} }
sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDC, rec_nr, 0); sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDC, rec_nr, 0);
@ -301,18 +301,18 @@ static int iso7816_process_fci(sc_card_t *card, sc_file_t *file,
size_t taglen, len = buflen; size_t taglen, len = buflen;
const u8 *tag = NULL, *p = buf; const u8 *tag = NULL, *p = buf;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "processing FCI bytes\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "processing FCI bytes");
tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen); tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
if (tag != NULL && taglen == 2) { if (tag != NULL && taglen == 2) {
file->id = (tag[0] << 8) | tag[1]; file->id = (tag[0] << 8) | tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
" file identifier: 0x%02X%02X\n", tag[0], tag[1]); " file identifier: 0x%02X%02X", tag[0], tag[1]);
} }
tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen); tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
if (tag != NULL && taglen >= 2) { if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1]; int bytes = (tag[0] << 8) + tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
" bytes in file: %d\n", bytes); " bytes in file: %d", bytes);
file->size = bytes; file->size = bytes;
} }
if (tag == NULL) { if (tag == NULL) {
@ -320,7 +320,7 @@ static int iso7816_process_fci(sc_card_t *card, sc_file_t *file,
if (tag != NULL && taglen >= 2) { if (tag != NULL && taglen >= 2) {
int bytes = (tag[0] << 8) + tag[1]; int bytes = (tag[0] << 8) + tag[1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
" bytes in file: %d\n", bytes); " bytes in file: %d", bytes);
file->size = bytes; file->size = bytes;
} }
} }
@ -331,7 +331,7 @@ static int iso7816_process_fci(sc_card_t *card, sc_file_t *file,
const char *type; const char *type;
file->shareable = byte & 0x40 ? 1 : 0; file->shareable = byte & 0x40 ? 1 : 0;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " shareable: %s\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " shareable: %s",
(byte & 0x40) ? "yes" : "no"); (byte & 0x40) ? "yes" : "no");
file->ef_structure = byte & 0x07; file->ef_structure = byte & 0x07;
switch ((byte >> 3) & 7) { switch ((byte >> 3) & 7) {
@ -352,9 +352,9 @@ static int iso7816_process_fci(sc_card_t *card, sc_file_t *file,
break; break;
} }
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
" type: %s\n", type); " type: %s", type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, sc_debug(ctx, SC_LOG_DEBUG_NORMAL,
" EF structure: %d\n", byte & 0x07); " EF structure: %d", byte & 0x07);
} }
} }
tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen); tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
@ -365,7 +365,7 @@ static int iso7816_process_fci(sc_card_t *card, sc_file_t *file,
sc_hex_dump(ctx, SC_LOG_DEBUG_NORMAL, sc_hex_dump(ctx, SC_LOG_DEBUG_NORMAL,
file->name, file->namelen, tbuf, sizeof(tbuf)); file->name, file->namelen, tbuf, sizeof(tbuf));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " File name: %s\n", tbuf); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, " File name: %s", tbuf);
if (!file->type) if (!file->type)
file->type = SC_FILE_TYPE_DF; file->type = SC_FILE_TYPE_DF;
} }
@ -650,7 +650,7 @@ static int iso7816_delete_file(sc_card_t *card, const sc_path_t *path)
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
if (path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) { if (path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "File type has to be SC_PATH_TYPE_FILE_ID");
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);
} }

View File

@ -234,7 +234,7 @@ int sc_pkcs1_encode(sc_context_t *ctx, unsigned long flags,
i = sc_pkcs1_add_digest_info_prefix(hash_algo, in, in_len, i = sc_pkcs1_add_digest_info_prefix(hash_algo, in, in_len,
out, &tmp_len); out, &tmp_len);
if (i != SC_SUCCESS) { if (i != SC_SUCCESS) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to add digest info 0x%x\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to add digest info 0x%x",
hash_algo); hash_algo);
return i; return i;
} }
@ -255,7 +255,7 @@ int sc_pkcs1_encode(sc_context_t *ctx, unsigned long flags,
mod_len); mod_len);
default: default:
/* currently only pkcs1 padding is supported */ /* currently only pkcs1 padding is supported */
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unsupported padding algorithm 0x%x\n", pad_algo); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unsupported padding algorithm 0x%x", pad_algo);
return SC_ERROR_NOT_SUPPORTED; return SC_ERROR_NOT_SUPPORTED;
} }
} }

View File

@ -89,7 +89,7 @@ static int parse_x509_cert(sc_context_t *ctx, const u8 *buf, size_t buflen, stru
obj = sc_asn1_verify_tag(ctx, buf, buflen, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, obj = sc_asn1_verify_tag(ctx, buf, buflen, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS,
&objlen); &objlen);
if (obj == NULL) { if (obj == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "X.509 certificate not found\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "X.509 certificate not found");
return SC_ERROR_INVALID_ASN1_OBJECT; return SC_ERROR_INVALID_ASN1_OBJECT;
} }
cert->data_len = objlen + (obj - buf); cert->data_len = objlen + (obj - buf);

View File

@ -389,7 +389,7 @@ int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *p15card,
puk_info = (struct sc_pkcs15_pin_info *)puk_obj->data; puk_info = (struct sc_pkcs15_pin_info *)puk_obj->data;
} }
if (!puk_info) { if (!puk_info) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to get puk object, using pin object instead!\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to get puk object, using pin object instead!");
puk_info = pin_info; puk_info = pin_info;
} }

View File

@ -197,7 +197,7 @@ int sc_pkcs15_decode_prkdf_entry(struct sc_pkcs15_card *p15card,
keyinfo_gostparams->gostr3411 = gostr3410_params[1]; keyinfo_gostparams->gostr3411 = gostr3410_params[1];
keyinfo_gostparams->gost28147 = gostr3410_params[2]; keyinfo_gostparams->gost28147 = gostr3410_params[2];
} else { } else {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Neither RSA or DSA or GOSTR3410 key in PrKDF entry.\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Neither RSA or DSA or GOSTR3410 key in PrKDF entry.");
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ASN1_OBJECT); SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ASN1_OBJECT);
} }
r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path); r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
@ -303,7 +303,7 @@ int sc_pkcs15_encode_prkdf_entry(sc_context_t *ctx,
} }
break; break;
default: default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Invalid private key type: %X\n", obj->type); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Invalid private key type: %X", obj->type);
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL); SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INTERNAL);
break; break;
} }
@ -369,7 +369,7 @@ sc_pkcs15_encode_prkey(sc_context_t *ctx,
{ {
if (key->algorithm == SC_ALGORITHM_DSA) if (key->algorithm == SC_ALGORITHM_DSA)
return sc_pkcs15_encode_prkey_dsa(ctx, &key->u.dsa, buf, len); return sc_pkcs15_encode_prkey_dsa(ctx, &key->u.dsa, buf, len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Cannot encode private key type %u.\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Cannot encode private key type %u.",
key->algorithm); key->algorithm);
return SC_ERROR_NOT_SUPPORTED; return SC_ERROR_NOT_SUPPORTED;
} }
@ -381,7 +381,7 @@ sc_pkcs15_decode_prkey(sc_context_t *ctx,
{ {
if (key->algorithm == SC_ALGORITHM_DSA) if (key->algorithm == SC_ALGORITHM_DSA)
return sc_pkcs15_decode_prkey_dsa(ctx, &key->u.dsa, buf, len); return sc_pkcs15_decode_prkey_dsa(ctx, &key->u.dsa, buf, len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Cannot decode private key type %u.\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Cannot decode private key type %u.",
key->algorithm); key->algorithm);
return SC_ERROR_NOT_SUPPORTED; return SC_ERROR_NOT_SUPPORTED;
} }
@ -409,7 +409,7 @@ sc_pkcs15_read_prkey(struct sc_pkcs15_card *p15card,
key.algorithm = SC_ALGORITHM_DSA; key.algorithm = SC_ALGORITHM_DSA;
break; break;
default: default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unsupported object type.\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unsupported object type.");
return SC_ERROR_NOT_SUPPORTED; return SC_ERROR_NOT_SUPPORTED;
} }
info = (struct sc_pkcs15_prkey_info *) obj->data; info = (struct sc_pkcs15_prkey_info *) obj->data;
@ -424,7 +424,7 @@ sc_pkcs15_read_prkey(struct sc_pkcs15_card *p15card,
r = sc_pkcs15_read_file(p15card, &path, &data, &len, NULL); r = sc_pkcs15_read_file(p15card, &path, &data, &len, NULL);
if (r < 0) { if (r < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to read private key file.\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unable to read private key file.");
return r; return r;
} }

View File

@ -143,7 +143,7 @@ int sc_pkcs15_parse_tokeninfo(sc_context_t *ctx,
r = sc_asn1_decode(ctx, asn1_tokeninfo, buf, blen, NULL, NULL); r = sc_asn1_decode(ctx, asn1_tokeninfo, buf, blen, NULL, NULL);
if (r) { if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ASN.1 parsing of EF(TokenInfo) failed: %s\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ASN.1 parsing of EF(TokenInfo) failed: %s",
sc_strerror(r)); sc_strerror(r));
return r; return r;
} }
@ -244,7 +244,7 @@ int sc_pkcs15_encode_tokeninfo(sc_context_t *ctx,
r = sc_asn1_encode(ctx, asn1_tokeninfo, buf, buflen); r = sc_asn1_encode(ctx, asn1_tokeninfo, buf, buflen);
if (r) { if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_asn1_encode() failed: %s\n", sc_strerror(r)); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_asn1_encode() failed: %s", sc_strerror(r));
return r; return r;
} }
return 0; return 0;
@ -271,7 +271,7 @@ static int parse_ddo(struct sc_pkcs15_card *p15card, const u8 * buf, size_t bufl
r = sc_asn1_decode(p15card->card->ctx, asn1_ddo, buf, buflen, NULL, NULL); r = sc_asn1_decode(p15card->card->ctx, asn1_ddo, buf, buflen, NULL, NULL);
if (r) { if (r) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "DDO parsing failed: %s\n", sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "DDO parsing failed: %s",
sc_strerror(r)); sc_strerror(r));
return r; return r;
} }
@ -324,7 +324,7 @@ static int encode_ddo(struct sc_pkcs15_card *p15card, u8 **buf, size_t *buflen)
r = sc_asn1_encode(ctx, asn1_dir, buf, buflen); r = sc_asn1_encode(ctx, asn1_dir, buf, buflen);
if (r) { if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_asn1_encode() failed: %s\n", sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_asn1_encode() failed: %s",
sc_strerror(r)); sc_strerror(r));
return r; return r;
} }
@ -410,7 +410,7 @@ int sc_pkcs15_encode_odf(sc_context_t *ctx,
df = df->next; df = df->next;
}; };
if (df_count == 0) { if (df_count == 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No DF's found.\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No DF's found.");
return SC_ERROR_OBJECT_NOT_FOUND; return SC_ERROR_OBJECT_NOT_FOUND;
} }
asn1_odf = malloc(sizeof(struct sc_asn1_entry) * (df_count + 1)); asn1_odf = malloc(sizeof(struct sc_asn1_entry) * (df_count + 1));
@ -432,7 +432,7 @@ int sc_pkcs15_encode_odf(sc_context_t *ctx,
break; break;
} }
if (type == -1) { if (type == -1) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unsupported DF type.\n"); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Unsupported DF type.");
continue; continue;
} }
asn1_odf[c] = c_asn1_odf[type]; asn1_odf[c] = c_asn1_odf[type];
@ -587,14 +587,13 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
sc_context_t *ctx = card->ctx; sc_context_t *ctx = card->ctx;
sc_pkcs15_tokeninfo_t tokeninfo; sc_pkcs15_tokeninfo_t tokeninfo;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "trying normal pkcs15 processing");
"trying normal pkcs15 processing\n");
/* Enumerate apps now */ /* Enumerate apps now */
if (card->app_count < 0) { if (card->app_count < 0) {
err = sc_enum_apps(card); err = sc_enum_apps(card);
if (err < 0 && err != SC_ERROR_FILE_NOT_FOUND) { if (err < 0 && err != SC_ERROR_FILE_NOT_FOUND) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to enumerate apps: %s\n", sc_strerror(err)); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to enumerate apps: %s", sc_strerror(err));
goto end; goto end;
} }
} }
@ -650,12 +649,12 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
if (r != SC_SUCCESS) if (r != SC_SUCCESS)
pbuf[0] = '\0'; pbuf[0] = '\0';
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "EF(ODF) not found in '%s'\n", pbuf); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "EF(ODF) not found in '%s'", pbuf);
goto end; goto end;
} }
if ((len = p15card->file_odf->size) == 0) { if ((len = p15card->file_odf->size) == 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF(ODF) is empty\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF(ODF) is empty");
goto end; goto end;
} }
buf = malloc(len); buf = malloc(len);
@ -671,7 +670,7 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
len = err; len = err;
if (parse_odf(buf, len, p15card)) { if (parse_odf(buf, len, p15card)) {
err = SC_ERROR_PKCS15_APP_NOT_FOUND; err = SC_ERROR_PKCS15_APP_NOT_FOUND;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to parse ODF\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Unable to parse ODF");
goto end; goto end;
} }
free(buf); free(buf);
@ -680,7 +679,7 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
if (card->ctx->debug) { if (card->ctx->debug) {
sc_pkcs15_df_t *df; sc_pkcs15_df_t *df;
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "The following DFs were found:\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "The following DFs were found:");
for (df = p15card->df_list; df; df = df->next) { for (df = p15card->df_list; df; df = df->next) {
char pbuf[SC_MAX_PATH_STRING_SIZE]; char pbuf[SC_MAX_PATH_STRING_SIZE];
@ -689,7 +688,7 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
pbuf[0] = '\0'; pbuf[0] = '\0';
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
" DF type %u, path %s, index %u, count %d\n", " DF type %u, path %s, index %u, count %d",
df->type, pbuf, df->path.index, df->path.count); df->type, pbuf, df->path.index, df->path.count);
} }
} }
@ -707,7 +706,7 @@ static int sc_pkcs15_bind_internal(sc_pkcs15_card_t *p15card)
goto end; goto end;
if ((len = p15card->file_tokeninfo->size) == 0) { if ((len = p15card->file_tokeninfo->size) == 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF(TokenInfo) is empty\n"); sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EF(TokenInfo) is empty");
goto end; goto end;
} }
buf = malloc(len); buf = malloc(len);
@ -796,7 +795,7 @@ int sc_pkcs15_bind(sc_card_t *card,
r = sc_lock(card); r = sc_lock(card);
if (r) { if (r) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_lock() failed: %s\n", sc_strerror(r)); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_lock() failed: %s", sc_strerror(r));
sc_pkcs15_card_free(p15card); sc_pkcs15_card_free(p15card);
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r); SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, r);
} }
@ -842,7 +841,7 @@ done:
* SHA1 prefix itself */ * SHA1 prefix itself */
if (strstr(p15card->label, "2cc") != NULL) { if (strstr(p15card->label, "2cc") != NULL) {
p15card->card->caps |= SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED; p15card->card->caps |= SC_CARD_CAP_ONLY_RAW_HASH_STRIPPED;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "D-TRUST 2cc card detected, only SHA1 works with this card\n"); sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "D-TRUST 2cc card detected, only SHA1 works with this card");
/* XXX: add detection when other hash than SHA1 is used with /* XXX: add detection when other hash than SHA1 is used with
* such a card, as this produces invalid signatures. * such a card, as this produces invalid signatures.
*/ */
@ -852,7 +851,7 @@ done:
* and no addition of prefix) */ * and no addition of prefix) */
else if (strstr(p15card->label, "2ca") != NULL) { else if (strstr(p15card->label, "2ca") != NULL) {
p15card->card->caps |= SC_CARD_CAP_ONLY_RAW_HASH; p15card->card->caps |= SC_CARD_CAP_ONLY_RAW_HASH;
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "D-TRUST 2ca card detected\n"); sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "D-TRUST 2ca card detected");
} }
/* XXX: probably there are more D-Trust card in the wild, /* XXX: probably there are more D-Trust card in the wild,
@ -1488,7 +1487,7 @@ int sc_pkcs15_encode_df(sc_context_t *ctx,
break; break;
} }
if (func == NULL) { if (func == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown DF type: %d\n", df->type); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown DF type: %d", df->type);
*buf_out = NULL; *buf_out = NULL;
*bufsize_out = 0; *bufsize_out = 0;
return 0; return 0;
@ -1554,7 +1553,7 @@ int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card,
break; break;
} }
if (func == NULL) { if (func == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown DF type: %d\n", df->type); sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown DF type: %d", df->type);
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS); SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_ARGUMENTS);
} }
if (df->file != NULL) if (df->file != NULL)
@ -1622,7 +1621,7 @@ int sc_pkcs15_add_unusedspace(struct sc_pkcs15_card *p15card,
if (r != SC_SUCCESS) if (r != SC_SUCCESS)
pbuf[0] = '\0'; pbuf[0] = '\0';
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "No offset and length present in path %s\n", pbuf); sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "No offset and length present in path %s", pbuf);
return SC_ERROR_INVALID_ARGUMENTS; return SC_ERROR_INVALID_ARGUMENTS;
} }
@ -1801,7 +1800,7 @@ int sc_pkcs15_read_file(struct sc_pkcs15_card *p15card,
if (r != SC_SUCCESS) if (r != SC_SUCCESS)
pbuf[0] = '\0'; pbuf[0] = '\0';
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "called, path=%s, index=%u, count=%d\n", sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "called, path=%s, index=%u, count=%d",
pbuf, in_path->index, in_path->count); pbuf, in_path->index, in_path->count);
} }