pkcs15init: homogenise line ending of debug messages

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4759 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
viktor.tarasov 2010-09-22 12:17:53 +00:00
parent dd6c9006b8
commit dc3b1d008b
3 changed files with 118 additions and 139 deletions

View File

@ -226,7 +226,7 @@ find_library(struct sc_context *ctx, const char *name)
break;
}
if (!libname) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to locate pkcs15init driver for '%s'\n", name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unable to locate pkcs15init driver for '%s'", name);
}
return libname;
}
@ -246,7 +246,7 @@ load_dynamic_driver(struct sc_context *ctx, void **dll,
return NULL;
handle = lt_dlopen(libname);
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;
}
@ -254,19 +254,19 @@ load_dynamic_driver(struct sc_context *ctx, void **dll,
modinit = (void *(*)(const char *)) lt_dlsym(handle, "sc_module_init");
modversion = (const char *(*)(void)) lt_dlsym(handle, "sc_driver_version");
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);
return NULL;
}
/* verify module version */
version = modversion();
if (version == NULL || strncmp(version, "0.9.", strlen("0.9.")) > 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);
return NULL;
}
*dll = handle;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "successfully loaded pkcs15init driver '%s'\n", name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "successfully loaded pkcs15init driver '%s'", name);
return modinit(name);
}
@ -348,21 +348,21 @@ sc_pkcs15init_bind(struct sc_card *card, const char *name,
do {
r = sc_profile_load(profile, profile->name);
if (r < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to load profile '%s': %s\n",
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to load profile '%s': %s",
profile->name, sc_strerror(r));
break;
}
r = sc_profile_load(profile, card_profile);
if (r < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to load profile '%s': %s\n",
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to load profile '%s': %s",
card_profile, sc_strerror(r));
break;
}
r = sc_profile_finish(profile);
if (r < 0)
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to finalize profile: %s\n", sc_strerror(r));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to finalize profile: %s", sc_strerror(r));
} while (0);
if (r < 0) {
@ -384,7 +384,7 @@ sc_pkcs15init_unbind(struct sc_profile *profile)
if (profile->dirty != 0 && profile->p15_data != NULL && profile->pkcs15.do_last_update) {
r = sc_pkcs15init_update_tokeninfo(profile->p15_data, profile);
if (r < 0)
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to update TokenInfo: %s\n", sc_strerror(r));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Failed to update TokenInfo: %s", sc_strerror(r));
}
if (profile->dll)
lt_dlclose(profile->dll);
@ -562,7 +562,7 @@ sc_pkcs15init_rmdir(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
if (df == NULL)
return SC_ERROR_INTERNAL;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_pkcs15init_rmdir(%s)\n", sc_print_path(&df->path));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_pkcs15init_rmdir(%s)", sc_print_path(&df->path));
if (df->type == SC_FILE_TYPE_DF) {
r = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_LIST_FILES);
@ -1965,13 +1965,13 @@ prkey_bits(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey *key)
case SC_ALGORITHM_GOSTR3410:
if (sc_pkcs15init_keybits(&key->u.gostr3410.d)
> SC_PKCS15_GOSTR3410_KEYSIZE) {
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key (keybits %u)\n",
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key (keybits %u)",
sc_pkcs15init_keybits(&key->u.gostr3410.d));
return SC_ERROR_OBJECT_NOT_VALID;
}
return SC_PKCS15_GOSTR3410_KEYSIZE;
}
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key algorithm.\n");
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key algorithm.");
return SC_ERROR_NOT_SUPPORTED;
}
@ -1987,7 +1987,7 @@ prkey_pkcs15_algo(struct sc_pkcs15_card *p15card, struct sc_pkcs15_prkey *key)
case SC_ALGORITHM_GOSTR3410:
return SC_PKCS15_TYPE_PRKEY_GOSTR3410;
}
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key algorithm.\n");
sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL, "Unsupported key algorithm.");
return SC_ERROR_NOT_SUPPORTED;
}
@ -2044,7 +2044,7 @@ select_intrinsic_id(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
allocated = 0;
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Intrinsic ID is not implemented for the object type 0x%X\n", type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Intrinsic ID is not implemented for the object type 0x%X", type);
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
}
@ -2258,7 +2258,7 @@ select_object_path(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
if (!name)
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key-domain.%s @%s (auth_id.len=%d)\n", name, sc_print_path(path), obj->auth_id.len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key-domain.%s @%s (auth_id.len=%d)", name, sc_print_path(path), obj->auth_id.len);
indx_id.len = 1;
for (indx = TEMPLATE_INSTANTIATE_MIN_INDEX; indx <= TEMPLATE_INSTANTIATE_MAX_INDEX; indx++) {
@ -2376,19 +2376,19 @@ get_generalized_time(struct sc_context *ctx)
#endif
tm_time = gmtime(&t);
if (tm_time == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: gmtime failed\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: gmtime failed");
return NULL;
}
ret = calloc(1, 16);
if (ret == NULL) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: calloc failed\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: calloc failed");
return NULL;
}
/* print time in generalized time format */
r = strftime(ret, 16, "%Y%m%d%H%M%SZ", tm_time);
if (r == 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: strftime failed\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "error: strftime failed");
free(ret);
return NULL;
}
@ -2522,7 +2522,7 @@ sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card,
int is_new = 0, r = 0, object_added = 0;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "add object %p to DF of type %u\n", object, df_type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "add object %p to DF of type %u", object, df_type);
df = find_df_by_type(p15card, df_type);
if (df != NULL) {
@ -2981,20 +2981,20 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p
path = file? &file->path : NULL;
ident = get_pin_ident_name(type, reference);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "get and verify PIN('%s',type:0x%X,reference:0x%X)\n", ident, type, reference);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "get and verify PIN('%s',type:0x%X,reference:0x%X)", ident, type, reference);
memset(&pin_info, 0, sizeof(pin_info));
pin_info.auth_method = type;
pin_info.reference = reference;
pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, type, reference);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found PIN reference %i\n", pin_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found PIN reference %i", pin_id);
if (type == SC_AC_SYMBOLIC) {
if (pin_id == -1)
SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
reference = pin_id;
type = SC_AC_CHV;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Symbolic PIN resolved to PIN(type:CHV,reference:%i)\n", type, reference);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Symbolic PIN resolved to PIN(type:CHV,reference:%i)", type, reference);
}
if (p15card) {
@ -3014,18 +3014,18 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p
if (!r && pin_obj) {
memcpy(&pin_info, pin_obj->data, sizeof(pin_info));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found PIN object '%s'\n", pin_obj->label);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found PIN object '%s'", pin_obj->label);
}
}
if (pin_obj) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PIN object '%s'; pin_obj->content.len:%i\n", pin_obj->label, pin_obj->content.len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "PIN object '%s'; pin_obj->content.len:%i", pin_obj->label, pin_obj->content.len);
if (pin_obj->content.value && pin_obj->content.len) {
if (pin_obj->content.len > pinsize)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_BUFFER_TOO_SMALL, "PIN buffer is too small");
memcpy(pinbuf, pin_obj->content.value, pin_obj->content.len);
pinsize = pin_obj->content.len;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "'ve got '%s' value from cache\n", ident);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "'ve got '%s' value from cache", ident);
goto found;
}
}
@ -3037,7 +3037,7 @@ sc_pkcs15init_verify_secret(struct sc_profile *profile, struct sc_pkcs15_card *p
case SC_AC_CHV:
if (callbacks.get_pin) {
r = callbacks.get_pin(profile, pin_id, &pin_info, label, pinbuf, &pinsize);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "'get_pin' callback returned %i; pinsize:%i\n", r, pinsize);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "'get_pin' callback returned %i; pinsize:%i", r, pinsize);
}
break;
default:
@ -3111,7 +3111,7 @@ sc_pkcs15init_authenticate(struct sc_profile *profile, struct sc_pkcs15_card *p1
if (r != SC_SUCCESS)
pbuf[0] = '\0';
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "path=%s, op=%u\n", pbuf, op);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "path=%s, op=%u", pbuf, op);
if (p15card->card->caps & SC_CARD_CAP_USE_FCI_AC) {
r = sc_select_file(p15card->card, &file->path, &file_tmp);
@ -3122,8 +3122,8 @@ sc_pkcs15init_authenticate(struct sc_profile *profile, struct sc_pkcs15_card *p1
acl = sc_file_get_acl_entry(file, op);
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "r:[0x%08x]\n",r);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "acl:[0x%08x]\n",acl);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "r:[0x%08x]",r);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "acl:[0x%08x]",acl);
for (; r == 0 && acl; acl = acl->next) {
if (acl->method == SC_AC_NEVER) {
@ -3138,7 +3138,7 @@ sc_pkcs15init_authenticate(struct sc_profile *profile, struct sc_pkcs15_card *p1
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "unknown acl method");
break;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "verify acl(method:%i,reference:%i)\n", acl->method, acl->key_ref);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "verify acl(method:%i,reference:%i)", acl->method, acl->key_ref);
r = sc_pkcs15init_verify_secret(profile, p15card, file_tmp ? file_tmp : file, acl->method, acl->key_ref);
}
@ -3207,7 +3207,7 @@ sc_pkcs15init_create_file(struct sc_profile *profile, struct sc_pkcs15_card *p15
int r;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create file '%s'\n", sc_print_path(&file->path));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create file '%s'", sc_print_path(&file->path));
/* Select parent DF and verify PINs/key as necessary */
r = do_select_parent(profile, p15card, file, &parent);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, "Cannot create file: select parent error");
@ -3244,7 +3244,7 @@ sc_pkcs15init_update_file(struct sc_profile *profile,
int r, need_to_zap = 0;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "path:%s; datalen:%i\n", sc_print_path(&file->path), datalen);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "path:%s; datalen:%i", sc_print_path(&file->path), datalen);
r = sc_select_file(p15card->card, &file->path, &selected_file);
if (!r) {
@ -3407,7 +3407,7 @@ sc_pkcs15init_fixup_file(struct sc_profile *profile,
user_acl.method = SC_AC_CHV;
user_acl.key_ref = pin_ref;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "so_acl(method:%X,ref:%X), user_acl(method:%X,ref:%X)\n",
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "so_acl(method:%X,ref:%X), user_acl(method:%X,ref:%X)",
so_acl.method, so_acl.key_ref, user_acl.method, user_acl.key_ref);
rv = sc_pkcs15init_fixup_acls(p15card, file, &so_acl, &user_acl);
@ -3605,7 +3605,7 @@ sc_pkcs15init_parse_info(struct sc_card *card,
case OPENSC_INFO_TAG_OPTION:
if (nopts >= SC_PKCS15INIT_MAX_OPTIONS - 1) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
"Too many options in OpenSC Info file\n");
"Too many options in OpenSC Info file");
return SC_ERROR_PKCS15INIT;
}
r = set_info_string(&profile->options[nopts], p, n);
@ -3621,7 +3621,7 @@ sc_pkcs15init_parse_info(struct sc_card *card,
return 0;
error:
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "OpenSC info file corrupted\n");
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "OpenSC info file corrupted");
return SC_ERROR_PKCS15INIT;
}

View File

@ -94,7 +94,7 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
const char *itag=NULL, *desc=NULL, *otag=NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type 0x%X; num %i; info %p; obj %p\n", type, num, info_out, obj_out);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type 0x%X; num %i; info %p; obj %p", type, num, info_out, obj_out);
switch (type) {
case SC_PKCS15_TYPE_CERT_X509:
desc = "Oberthur AWP certificate info";
@ -150,17 +150,17 @@ awp_new_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
if (itag) {
snprintf(name, sizeof(name),"%s-%s", COSM_TITLE, itag);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info template %s\n",name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info template %s",name);
if (sc_profile_get_file(profile, name, &ifile) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'\n", name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'", name);
return SC_ERROR_INCONSISTENT_PROFILE;
}
}
if (otag) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj template %s\n",otag);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj template %s",otag);
if (sc_profile_get_file(profile, otag, &ofile) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'\n", name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "profile does not defines template '%s'", name);
return SC_ERROR_INCONSISTENT_PROFILE;
}
@ -229,7 +229,7 @@ awp_update_blob(struct sc_context *ctx,
*blob_size += lv->len;
break;
default:
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Invalid tlv type %i\n",type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Invalid tlv type %i",type);
return SC_ERROR_INCORRECT_PARAMETERS;
}
@ -278,7 +278,7 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile *
unsigned char *buff = NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container file(file-id:%X,rlen:%i,rcount:%i)\n",
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);
buff = malloc(list_file->record_length);
@ -288,7 +288,6 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile *
memset(buff, 0, list_file->record_length);
rv = awp_new_container_entry(p15card, buff, list_file->record_length);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i", rv);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot create container");
*(buff + 0) = (acc->pubkey_id >> 8) & 0xFF;
@ -300,15 +299,11 @@ awp_create_container_record (struct sc_pkcs15_card *p15card, struct sc_profile *
rv = sc_select_file(p15card->card, &list_file->path, NULL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i", rv);
if (rv == SC_ERROR_FILE_NOT_FOUND) {
if (rv == SC_ERROR_FILE_NOT_FOUND)
rv = sc_pkcs15init_create_file(profile, p15card, list_file);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i", rv);
}
if (!rv) {
if (!rv)
rv = sc_append_record(p15card->card, buff, list_file->record_length, SC_RECORD_BY_REC_NR);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i", rv);
}
free(buff);
@ -329,19 +324,19 @@ awp_create_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
unsigned char *list = NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create container(%X:%X:%X)\n", acc->prkey_id, acc->cert_id, acc->pubkey_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create container(%X:%X:%X)", acc->prkey_id, acc->cert_id, acc->pubkey_id);
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Create container failed");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner cfile(rcount:%i,rlength:%i)\n", clist->record_count, clist->record_length);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner cfile(rcount:%i,rlength:%i)", clist->record_count, clist->record_length);
rv = sc_select_file(p15card->card, &clist->path, &file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Create container failed: cannot select container's list");
file->record_length = clist->record_length;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner file(rcount:%i,rlength:%i)\n", file->record_count, file->record_length);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner file(rcount:%i,rlength:%i)", file->record_count, file->record_length);
rec_offs = 0;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Append new record %i for private key\n", file->record_count + 1);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Append new record %i for private key", file->record_count + 1);
rv = awp_create_container_record(p15card, profile, file, acc);
@ -366,8 +361,8 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
unsigned char *buff = NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry(type:%X,len:%i,count %i,rec %i,offs %i\n", type, file_id, rec, offs);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container file(file-id:%X,rlen:%i,rcount:%i)\n",
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, "container file(file-id:%X,rlen:%i,rcount:%i)",
list_file->id, list_file->record_length, list_file->record_count);
buff = malloc(list_file->record_length);
@ -392,14 +387,14 @@ awp_update_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
case SC_PKCS15_TYPE_PUBKEY_RSA:
case COSM_TYPE_PUBKEY_RSA:
if (*(buff + offs + 4))
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Insert public key to container that contains certificate %02X%02X\n",
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Insert public key to container that contains certificate %02X%02X",
*(buff + offs + 4), *(buff + offs + 5));
*(buff + offs + 0) = (file_id >> 8) & 0xFF;
*(buff + offs + 1) = file_id & 0xFF;
break;
case SC_PKCS15_TYPE_PRKEY_RSA:
case COSM_TYPE_PRKEY_RSA:
if (*(buff + offs + 2))
if (*(buff + offs + 2))
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_CARD, "private key exists already");
*(buff + offs + 2) = (file_id >> 8) & 0xFF;
@ -446,7 +441,7 @@ awp_remove_container_entry (struct sc_pkcs15_card *p15card, struct sc_profile *p
unsigned char *buff=NULL, id[2];
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file_id %X\n", file_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file_id %X", file_id);
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
if (rv)
@ -528,7 +523,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
unsigned char *list = NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container(type:%X,obj_id:%X)\n", type, obj_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container(type:%X,obj_id:%X)", type, obj_id);
if (prkey_id)
*prkey_id = 0;
@ -545,19 +540,18 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
if (rv)
goto done;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner cfile(rcount:%i,rlength:%i)\n", clist->record_count, clist->record_length);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner cfile(rcount:%i,rlength:%i)", clist->record_count, clist->record_length);
rv = sc_select_file(p15card->card, &clist->path, &file);
if (rv)
goto done;
file->record_length = clist->record_length;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner file(rcount:%i,rlength:%i)\n", file->record_count, file->record_length);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "contaner file(rcount:%i,rlength:%i)", file->record_count, file->record_length);
if (type == SC_PKCS15_TYPE_PRKEY_RSA || type == COSM_TYPE_PRKEY_RSA) {
rec_offs = 0;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Append new record %i for private key\n", file->record_count + 1);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Append new record %i for private key", file->record_count + 1);
rv = awp_update_container_entry(p15card, profile, file, type, obj_id, file->record_count + 1, rec_offs);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", rv);
goto done;
}
@ -585,7 +579,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
for (rec_offs=0; !rv && rec_offs<12; rec_offs+=6) {
int offs;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rec %i; rec_offs %i\n", rec, rec_offs);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rec %i; rec_offs %i", rec, rec_offs);
offs = rec*AWP_CONTAINER_RECORD_LEN + rec_offs;
if (*(list + offs + 2)) {
unsigned char *buff = NULL;
@ -593,14 +587,14 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
struct sc_path path = private_path;
struct sc_file *ff = NULL;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container contains PrKey %02X%02X\n", *(list + offs + 2), *(list + offs + 3));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "container contains PrKey %02X%02X", *(list + offs + 2), *(list + offs + 3));
path.value[path.len - 2] = *(list + offs + 2) | 0x01;
path.value[path.len - 1] = *(list + offs + 3);
rv = sc_select_file(p15card->card, &path, &ff);
if (rv)
continue;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file id %X; size %i\n", ff->id, ff->size);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file id %X; size %i", ff->id, ff->size);
buff = malloc(ff->size);
if (!buff) {
rv = SC_ERROR_MEMORY_FAILURE;
@ -609,7 +603,7 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = sc_pkcs15init_authenticate(profile, p15card, ff, SC_AC_OP_READ);
if (rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "failed %s\n","sc_pkcs15init_authenticate()");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "sc_pkcs15init_authenticate(READ) failed");
break;
}
@ -617,16 +611,16 @@ awp_update_container(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
if (rv == ff->size) {
rv = 0;
id_offs = 5 + *(buff+3);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rec %i; id offset %i\n",rec, id_offs);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rec %i; id offset %i",rec, id_offs);
if (key_id->len == *(buff + id_offs) &&
!memcmp(key_id->value, buff + id_offs + 1, key_id->len)) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found key file friend %s\n","");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "found key file friend");
if (!rv)
rv = awp_update_container_entry(p15card, profile, file, type, obj_id, rec + 1, rec_offs);
if (rv >= 0 && prkey_id) {
*prkey_id = *(list + offs + 2) * 0x100 + *(list + offs + 3);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "*prkey_id 0x%X\n", *prkey_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "*prkey_id 0x%X", *prkey_id);
}
}
}
@ -743,7 +737,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
int rv, ii;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %i, num %i\n", type, num);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %i, num %i", type, num);
switch (type) {
case SC_PKCS15_TYPE_CERT_X509:
snprintf(obj_name, NAME_MAX_LEN, "template-certificate");
@ -772,15 +766,15 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
return SC_ERROR_INVALID_ARGUMENTS;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj_name %s; num 0x%X\n",obj_name, num);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lst_name %s\n",lst_name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "obj_name %s; num 0x%X",obj_name, num);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "lst_name %s",lst_name);
if (sc_profile_get_file(profile, obj_name, &obj_file) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No profile template '%s'\n", obj_name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No profile template '%s'", obj_name);
rv = SC_ERROR_NOT_SUPPORTED;
goto done;
}
else if (sc_profile_get_file(profile, lst_name, &lst_file) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No profile template '%s'\n", lst_name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "No profile template '%s'", lst_name);
rv = SC_ERROR_NOT_SUPPORTED;
goto done;
}
@ -789,7 +783,6 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
obj_file->path.value[obj_file->path.len-1] |= (num & 0xFF);
rv = sc_select_file(p15card->card, &obj_file->path, &file);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
if (rv)
goto done;
@ -809,24 +802,19 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
}
rv = sc_pkcs15init_authenticate(profile, p15card, lst_file, SC_AC_OP_READ);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
if (rv)
goto done;
rv = sc_pkcs15init_authenticate(profile, p15card, lst_file, SC_AC_OP_UPDATE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
if (rv)
goto done;
rv = sc_select_file(p15card->card, &lst_file->path, NULL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
if (rv == SC_ERROR_FILE_NOT_FOUND)
rv = sc_pkcs15init_create_file(profile, p15card, lst_file);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
if (rv < 0)
goto done;
rv = sc_read_binary(p15card->card, 0, buff, lst_file->size, lst_file->ef_structure);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
if (rv < 0)
goto done;
@ -838,7 +826,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
goto done;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ii %i, rv %i; %X; %i\n", ii, rv, file->id, file->size);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ii %i, rv %i; %X; %i", ii, rv, file->id, file->size);
*(buff + ii) = COSM_LIST_TAG;
*(buff + ii + 1) = (file->id >> 8) & 0xFF;
*(buff + ii + 2) = file->id & 0xFF;
@ -846,7 +834,7 @@ awp_update_object_list(struct sc_pkcs15_card *p15card, struct sc_profile *profil
*(buff + ii + 4) = file->size & 0xFF;
rv = sc_update_binary(p15card->card, ii, buff + ii, 5, 0);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n",rv);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i",rv);
if (rv < 0)
goto done;
@ -876,7 +864,7 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
key_info = (struct sc_pkcs15_prkey_info *)obj->data;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "object(%s,type:%X)\n", obj->label, obj->type);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "object(%s,type:%X)", obj->label, obj->type);
if (obj->type == SC_PKCS15_TYPE_PUBKEY_RSA || obj->type == COSM_TYPE_PUBKEY_RSA )
ki->flags = COSM_TAG_PUBKEY_RSA;
else if (obj->type == SC_PKCS15_TYPE_PRKEY_RSA || obj->type == COSM_TYPE_PRKEY_RSA)
@ -891,12 +879,12 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
ki->label.value = (unsigned char *)strdup(obj->label);
ki->label.len = strlen(obj->label);
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_encode_key_info() label(%i):%s\n",ki->label.len, ki->label.value);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_encode_key_info() label(%i):%s",ki->label.len, ki->label.value);
/*
* Oberthur saves modulus value without tag and length.
*/
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "pubkey->modulus.len %i\n",pubkey->modulus.len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "pubkey->modulus.len %i",pubkey->modulus.len);
ki->modulus.value = malloc(pubkey->modulus.len);
if (!ki->modulus.value) {
r = SC_ERROR_MEMORY_FAILURE;
@ -925,7 +913,7 @@ awp_encode_key_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *obj
memcpy(ki->id.value, key_info->id.value, key_info->id.len);
ki->id.len = key_info->id.len;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_encode_key_info() label:%s\n",ki->label.value);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_encode_key_info() label:%s",ki->label.value);
done:
ERR_load_ERR_strings();
ERR_load_crypto_strings();
@ -954,13 +942,13 @@ awp_set_key_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile, st
unsigned char *blob;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file:%p,kinfo:%p,cinfo:%p\n", file, ki, ci);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file:%p, kinfo:%p, cinfo:%p", file, ki, ci);
blob_size = 2;
blob = malloc(blob_size);
if (!blob)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_MEMORY_FAILURE, "AWP set key info failed: blob allocation error");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "label:%s\n",ki->label.value);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "label:%s",ki->label.value);
*blob = (ki->flags >> 8) & 0xFF;
*(blob + 1) = ki->flags & 0xFF;
@ -970,17 +958,14 @@ awp_set_key_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile, st
r = awp_update_blob(ctx, &blob, &blob_size, &ci->cn, TLV_TYPE_LLV);
else
r = awp_update_blob(ctx, &blob, &blob_size, &ki->label, TLV_TYPE_LLV);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r)
goto done;
r = awp_update_blob(ctx, &blob, &blob_size, &ki->id, TLV_TYPE_LLV);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r)
goto done;
r = awp_update_blob(ctx, &blob, &blob_size, &x30_lv, TLV_TYPE_V);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r)
goto done;
@ -988,25 +973,21 @@ awp_set_key_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile, st
r = awp_update_blob(ctx, &blob, &blob_size, &(ci->subject), TLV_TYPE_LLV);
else
r = awp_update_blob(ctx, &blob, &blob_size, &zero_lv, TLV_TYPE_LLV);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r)
goto done;
if ((ki->flags & ~COSM_GENERATED) != COSM_TAG_PUBKEY_RSA) {
r = awp_update_blob(ctx, &blob, &blob_size, &ki->modulus, TLV_TYPE_V);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r)
goto done;
r = awp_update_blob(ctx, &blob, &blob_size, &ki->exponent, TLV_TYPE_LV);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r)
goto done;
}
file->size = blob_size;
r = sc_pkcs15init_create_file(profile, p15card, file);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r == SC_ERROR_FILE_ALREADY_EXISTS) {
r = cosm_delete_file(p15card, profile, file);
if (!r)
@ -1017,7 +998,6 @@ awp_set_key_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile, st
goto done;
r = sc_pkcs15init_update_file(profile, p15card, file, blob, blob_size);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv:%i\n", r);
if (r < 0)
goto done;
@ -1052,7 +1032,7 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
cert_info = (struct sc_pkcs15_cert_info *)obj->data;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Encode cert(%s,id:%s,der(%p,%i))\n", obj->label,
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Encode cert(%s,id:%s,der(%p,%i))", obj->label,
sc_pkcs15_print_id(&cert_info->id), obj->content.value, obj->content.len);
memset(&pubkey, 0, sizeof(pubkey));
@ -1131,7 +1111,6 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
if (!(ci->serial.value = malloc(encoded_len + 3))) {
r = SC_ERROR_MEMORY_FAILURE;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "rv %i\n", r);
goto done;
}
@ -1140,7 +1119,7 @@ awp_encode_cert_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
*(ci->serial.value + 1) = encoded_len;
ci->serial.len = encoded_len + 2;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cert. serial encoded length %i\n", encoded_len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cert. serial encoded length %i", encoded_len);
} while (0);
ci->x509 = X509_dup(x);
@ -1197,7 +1176,7 @@ awp_encode_data_info(struct sc_pkcs15_card *p15card, struct sc_pkcs15_object *ob
data_info = (struct sc_pkcs15_data_info *)obj->data;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Encode data(%s,id:%s,der(%p,%i))\n", obj->label,
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Encode data(%s,id:%s,der(%p,%i))", obj->label,
sc_pkcs15_print_id(&data_info->id), obj->content.value, obj->content.len);
di->flags = 0x0000;
@ -1257,7 +1236,7 @@ awp_set_data_info (struct sc_pkcs15_card *p15card, struct sc_profile *profile,
unsigned char *blob;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug (ctx, SC_LOG_DEBUG_NORMAL, "Set 'DATA' info %p\n", di);
sc_debug (ctx, SC_LOG_DEBUG_NORMAL, "Set 'DATA' info %p", di);
blob_size = 2;
if (!(blob = malloc(blob_size))) {
r = SC_ERROR_MEMORY_FAILURE;
@ -1408,17 +1387,17 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = awp_new_file(p15card, profile, SC_PKCS15_TYPE_PRKEY_RSA, prvkey_id & 0xFF, &info_file, &key_file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update key info failed: instantiation error");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key id %X; info id%X\n", key_file->id, info_file->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "key id %X; info id%X", key_file->id, info_file->id);
rv = sc_pkcs15init_authenticate(profile, p15card, info_file, SC_AC_OP_READ);
if (rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: 'READ' authentication error\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: 'READ' authentication error");
goto done;
}
rv = sc_select_file(p15card->card, &info_file->path, &file);
if (rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: cannot select info file\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: cannot select info file");
goto done;
}
@ -1428,7 +1407,7 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
rv = sc_read_binary(p15card->card, 0, buf, file->size, 0);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: read info file error\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: read info file error");
goto done;
}
buf_len = rv;
@ -1436,7 +1415,7 @@ awp_update_key_info(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
memset(&ikey, 0, sizeof(ikey));
rv = awp_parse_key_info(ctx, buf, buf_len, &ikey);
if (rv < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: parse key info error\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update key info failed: parse key info error");
goto done;
}
free(buf);
@ -1719,7 +1698,7 @@ awp_delete_from_container(struct sc_pkcs15_card *p15card,
unsigned char *buff=NULL;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry (type:%X,file-id:%X)\n", type, file_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "update container entry (type:%X,file-id:%X)", type, file_id);
rv = awp_new_file(p15card, profile, COSM_CONTAINER_LIST, 0, &clist, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update contaner entry: cannot get allocate AWP file");
@ -1801,7 +1780,7 @@ awp_remove_from_object_list( struct sc_pkcs15_card *p15card, struct sc_profile *
unsigned char id[2];
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %X; obj_id %X\n",type, obj_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "type %X; obj_id %X",type, obj_id);
switch (type) {
case SC_PKCS15_TYPE_PRKEY_RSA:
@ -1818,7 +1797,7 @@ awp_remove_from_object_list( struct sc_pkcs15_card *p15card, struct sc_profile *
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCORRECT_PARAMETERS, "AWP update object list: invalid type");
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update object list: select '%s' file\n", lst_name);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "AWP update object list: select '%s' file", lst_name);
rv = sc_profile_get_file(profile, lst_name, &lst_file);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP update object list: cannot instantiate list file");
@ -1879,11 +1858,11 @@ awp_update_df_delete_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
path = ((struct sc_pkcs15_cert_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X\n", file_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete cert' update DF failed: cannt get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X\n", info_file->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)
@ -1913,11 +1892,11 @@ awp_update_df_delete_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
path = ((struct sc_pkcs15_prkey_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X\n", file_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete prkey' update DF failed: cannt get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X\n", info_file->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)
@ -1947,11 +1926,11 @@ awp_update_df_delete_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
path = ((struct sc_pkcs15_pubkey_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X\n", file_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete pubkey' update DF failed: cannt get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X\n", info_file->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)
@ -1981,11 +1960,11 @@ awp_update_df_delete_data(struct sc_pkcs15_card *p15card, struct sc_profile *pro
path = ((struct sc_pkcs15_data_info *) obj->data)->path;
file_id = path.value[path.len-2] * 0x100 + path.value[path.len-1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X\n", file_id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "file-id:%X", file_id);
rv = awp_new_file(p15card, profile, obj->type, file_id & 0xFF, &info_file, NULL);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'delete DATA' update DF failed: cannt get allocate new AWP file");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X\n", info_file->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "info file-id:%X", info_file->id);
rv = cosm_delete_file(p15card, profile, info_file);
if (rv != SC_ERROR_FILE_NOT_FOUND)

View File

@ -77,7 +77,7 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile
return SC_ERROR_INVALID_ARGUMENTS;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_write_tokeninfo() label '%s'; flags 0x%X\n", label, p15_flags);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_write_tokeninfo() label '%s'; flags 0x%X", label, p15_flags);
if (sc_profile_get_file(profile, COSM_TITLE"-token-info", &file))
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCONSISTENT_PROFILE, "Cannot find "COSM_TITLE"-token-info");
@ -113,7 +113,7 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile
if (p15_flags & SC_PKCS15_CARD_FLAG_TOKEN_INITIALIZED)
flags |= COSM_TOKEN_FLAG_TOKEN_INITIALIZED;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_write_tokeninfo() token label '%s'; oberthur flags 0x%X\n", buffer, flags);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_write_tokeninfo() token label '%s'; oberthur flags 0x%X", buffer, flags);
memset(buffer + file->size - 4, 0, 4);
*(buffer + file->size - 1) = flags & 0xFF;
@ -143,7 +143,7 @@ cosm_delete_file(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
int rv = 0;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "id %04X\n", df->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "id %04X", df->id);
if (df->type==SC_FILE_TYPE_DF) {
rv = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot authenticate SC_AC_OP_DELETE");
@ -190,18 +190,18 @@ cosm_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card)
* it *after* the DF.
* */
if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X\n",dir->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X",dir->id);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
goto done;
}
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file ddf %04X\n",df->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file ddf %04X",df->id);
rv = cosm_delete_file(p15card, profile, df);
if (sc_profile_get_file(profile, "private-DF", &dir) >= 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X\n",dir->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X",dir->id);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
@ -209,7 +209,7 @@ cosm_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card)
}
if (sc_profile_get_file(profile, "public-DF", &dir) >= 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X\n",dir->id);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "erase file dir %04X",dir->id);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
@ -218,7 +218,7 @@ cosm_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card)
rv = sc_profile_get_file(profile, COSM_TITLE"-AppDF", &dir);
if (!rv) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "delete %s; r %i\n", COSM_TITLE"-AppDF", rv);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "delete %s; r %i", COSM_TITLE"-AppDF", rv);
rv = cosm_delete_file(p15card, profile, dir);
sc_file_free(dir);
}
@ -307,7 +307,7 @@ cosm_create_reference_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
};
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "pin lens %i/%i\n", pin_len, puk_len);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "pin lens %i/%i", pin_len, puk_len);
if (!pin || pin_len>0x40)
return SC_ERROR_INVALID_ARGUMENTS;
if (puk && !puk_len)
@ -372,12 +372,12 @@ cosm_update_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
int rv;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ref %i; flags 0x%X\n", pinfo->reference, pinfo->flags);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ref %i; flags 0x%X", pinfo->reference, pinfo->flags);
if (pinfo->flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
if (pinfo->reference != 4)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INVALID_PIN_REFERENCE, "cosm_update_pin() invalid SOPIN reference");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update SOPIN ignored\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Update SOPIN ignored");
rv = SC_SUCCESS;
}
else {
@ -405,7 +405,7 @@ cosm_select_pin_reference(struct sc_profile *profile, struct sc_pkcs15_card *p15
struct sc_file *pinfile;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ref %i; flags %X\n", pin_info->reference, pin_info->flags);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "ref %i; flags %X", pin_info->reference, pin_info->flags);
if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pinfile) < 0) {
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
return SC_ERROR_INCONSISTENT_PROFILE;
@ -447,7 +447,7 @@ cosm_create_pin(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
int rv = 0, type;
SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create '%s'; ref 0x%X; flags %X\n", pin_obj->label, pin_info->reference, pin_info->flags);
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create '%s'; ref 0x%X; flags %X", pin_obj->label, pin_info->reference, pin_info->flags);
if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pin_file) < 0)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_INCONSISTENT_PROFILE, "\""COSM_TITLE"-AppDF\" not defined");
@ -500,7 +500,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
unsigned int structure = 0xFFFFFFFF;
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() type %X; num %i\n",type, num);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() type %X; num %i",type, num);
while (1) {
switch (type) {
case SC_PKCS15_TYPE_PRKEY_RSA:
@ -542,9 +542,9 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
type &= SC_PKCS15_TYPE_CLASS_MASK;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() template %s; num %i\n",_template, num);
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() template %s; num %i",_template, num);
if (sc_profile_get_file(profile, _template, &file) < 0) {
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define %s template '%s'\n",
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Profile doesn't define %s template '%s'",
desc, _template);
SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED);
}
@ -555,7 +555,7 @@ cosm_new_file(struct sc_profile *profile, struct sc_card *card,
file->ef_structure = structure;
}
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() file size %i; ef type %i/%i; id %04X\n",file->size,
sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "cosm_new_file() file size %i; ef type %i/%i; id %04X",file->size,
file->type, file->ef_structure, file->id);
*out = file;
@ -677,7 +677,7 @@ cosm_generate_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
key_info->key_reference = prkf->path.value[prkf->path.len - 1] & 0xFF;
key_info->path = prkf->path;
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_generate_key() now delete temporary public key\n");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "cosm_generate_key() now delete temporary public key");
rv = cosm_delete_file(p15card, profile, tmpf);
sc_file_free(tmpf);
@ -703,7 +703,7 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Create key failed: RSA only supported");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create private key ID:%s\n", sc_pkcs15_print_id(&key_info->id));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "create private key ID:%s", sc_pkcs15_print_id(&key_info->id));
/* Here, the path of private key file should be defined.
* Neverthelles, we need to instanciate private key to get the ACLs. */
rv = cosm_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
@ -714,7 +714,7 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
file->id = file->path.value[file->path.len - 2] * 0x100
+ file->path.value[file->path.len - 1];
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Path of private key file to create %s\n", sc_print_path(&file->path));
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Path of private key file to create %s", sc_print_path(&file->path));
rv = sc_select_file(p15card->card, &file->path, NULL);
if (rv == 0) {
@ -754,7 +754,7 @@ cosm_store_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
if (object->type != SC_PKCS15_TYPE_PRKEY_RSA || prkey->algorithm != SC_ALGORITHM_RSA)
SC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_NOT_SUPPORTED, "Store key failed: RSA only supported");
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "store key with ID:%s and path:%s\n", sc_pkcs15_print_id(&key_info->id),
sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "store key with ID:%s and path:%s", sc_pkcs15_print_id(&key_info->id),
sc_print_path(&key_info->path));
rv = sc_select_file(p15card->card, &key_info->path, &file);