log errors in verbose
This commit is contained in:
parent
00a150f74c
commit
e3dda8894e
|
@ -1462,10 +1462,10 @@ static int gids_import_key(sc_card_t *card, sc_pkcs15_object_t *object, sc_pkcs1
|
||||||
sc_format_asn1_entry(asn1_key_usage_template + 1, asn1_key_value_template, NULL, 1);
|
sc_format_asn1_entry(asn1_key_usage_template + 1, asn1_key_value_template, NULL, 1);
|
||||||
|
|
||||||
r = sc_asn1_encode(card->ctx, asn1_key_usage_template, &buffer, &buflen);
|
r = sc_asn1_encode(card->ctx, asn1_key_usage_template, &buffer, &buflen);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r, "unable to encode the private key");
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r, "unable to encode the private key");
|
||||||
|
|
||||||
r = gids_put_DO(card, GIDS_APPLET_EFID, GIDS_PUT_KEY_DO, buffer, buflen);
|
r = gids_put_DO(card, GIDS_APPLET_EFID, GIDS_PUT_KEY_DO, buffer, buflen);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r, "unable to put the private key - key greater than 2048 bits ?");
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r, "unable to put the private key - key greater than 2048 bits ?");
|
||||||
r = SC_SUCCESS;
|
r = SC_SUCCESS;
|
||||||
err:
|
err:
|
||||||
sc_mem_clear(buffer, buflen);
|
sc_mem_clear(buffer, buflen);
|
||||||
|
|
|
@ -519,7 +519,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
|
|
||||||
/* allocate key object */
|
/* allocate key object */
|
||||||
r = cosm_new_file(profile, card, obj->type, idx, &file); //replace SC_PKCS15_TYPE_PRKEY_RSA with obj->type
|
r = cosm_new_file(profile, card, obj->type, idx, &file); //replace SC_PKCS15_TYPE_PRKEY_RSA with obj->type
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"create key: failed to allocate new key object");
|
"create key: failed to allocate new key object");
|
||||||
file->size = keybits;
|
file->size = keybits;
|
||||||
sc_log(card->ctx, "private key path: %s",
|
sc_log(card->ctx, "private key path: %s",
|
||||||
|
@ -529,13 +529,13 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
|
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, file,
|
r = sc_pkcs15init_authenticate(profile, p15card, file,
|
||||||
SC_AC_OP_DELETE);
|
SC_AC_OP_DELETE);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate key: pkcs15init_authenticate(SC_AC_OP_DELETE) failed");
|
"generate key: pkcs15init_authenticate(SC_AC_OP_DELETE) failed");
|
||||||
|
|
||||||
sc_delete_file(p15card->card, &file->path);
|
sc_delete_file(p15card->card, &file->path);
|
||||||
/* create */
|
/* create */
|
||||||
r = sc_pkcs15init_create_file(profile, p15card, file);
|
r = sc_pkcs15init_create_file(profile, p15card, file);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"create key: failed to create key file");
|
"create key: failed to create key file");
|
||||||
|
|
||||||
sc_log(card->ctx,
|
sc_log(card->ctx,
|
||||||
|
@ -560,17 +560,17 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
path.len -= 2;
|
path.len -= 2;
|
||||||
|
|
||||||
r = sc_select_file(card, &path, &tfile);
|
r = sc_select_file(card, &path, &tfile);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate key: no private object DF");
|
"generate key: no private object DF");
|
||||||
|
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, tfile,
|
r = sc_pkcs15init_authenticate(profile, p15card, tfile,
|
||||||
SC_AC_OP_CRYPTO);
|
SC_AC_OP_CRYPTO);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate key: pkcs15init_authenticate(SC_AC_OP_CRYPTO) failed");
|
"generate key: pkcs15init_authenticate(SC_AC_OP_CRYPTO) failed");
|
||||||
|
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, tfile,
|
r = sc_pkcs15init_authenticate(profile, p15card, tfile,
|
||||||
SC_AC_OP_CREATE);
|
SC_AC_OP_CREATE);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate key: pkcs15init_authenticate(SC_AC_OP_CREATE) failed");
|
"generate key: pkcs15init_authenticate(SC_AC_OP_CREATE) failed");
|
||||||
|
|
||||||
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA )
|
if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA )
|
||||||
|
@ -604,7 +604,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
if (r == SC_SUCCESS) {
|
if (r == SC_SUCCESS) {
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, pukf,
|
r = sc_pkcs15init_authenticate(profile, p15card, pukf,
|
||||||
SC_AC_OP_DELETE);
|
SC_AC_OP_DELETE);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate key - pubkey: pkcs15init_authenticate(SC_AC_OP_DELETE) failed");
|
"generate key - pubkey: pkcs15init_authenticate(SC_AC_OP_DELETE) failed");
|
||||||
|
|
||||||
r = sc_pkcs15init_delete_by_path(profile, p15card, &pukf->path);
|
r = sc_pkcs15init_delete_by_path(profile, p15card, &pukf->path);
|
||||||
|
@ -624,7 +624,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
|
|
||||||
r = sc_pkcs15init_authenticate(profile, p15card, pukf,
|
r = sc_pkcs15init_authenticate(profile, p15card, pukf,
|
||||||
SC_AC_OP_UPDATE);
|
SC_AC_OP_UPDATE);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate key - pubkey: pkcs15init_authenticate(SC_AC_OP_UPDATE) failed");
|
"generate key - pubkey: pkcs15init_authenticate(SC_AC_OP_UPDATE) failed");
|
||||||
|
|
||||||
/* generate key pair */
|
/* generate key pair */
|
||||||
|
@ -636,7 +636,7 @@ static int epass2003_pkcs15_generate_key(struct sc_profile *profile,
|
||||||
gendat.key_length = keybits;
|
gendat.key_length = keybits;
|
||||||
gendat.modulus = NULL;
|
gendat.modulus = NULL;
|
||||||
r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_GENERATE_KEY, &gendat);
|
r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_GENERATE_KEY, &gendat);
|
||||||
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_NORMAL, r,
|
SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
|
||||||
"generate RSA key pair failed");
|
"generate RSA key pair failed");
|
||||||
|
|
||||||
/* get the modulus */
|
/* get the modulus */
|
||||||
|
|
|
@ -1388,22 +1388,22 @@ awp_update_df_create_cert(struct sc_pkcs15_card *p15card, struct sc_profile *pro
|
||||||
sc_log(ctx,
|
sc_log(ctx,
|
||||||
"Cert Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
|
"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_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot encode info");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "'Create Cert' update DF failed: cannot encode info");
|
||||||
|
|
||||||
rv = awp_set_certificate_info(p15card, profile, info_file, &icert);
|
rv = awp_set_certificate_info(p15card, profile, info_file, &icert);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot set info");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "'Create Cert' update DF failed: cannot set info");
|
||||||
|
|
||||||
rv = awp_update_object_list(p15card, profile, SC_PKCS15_TYPE_CERT_X509, obj_id & 0xFF);
|
rv = awp_update_object_list(p15card, profile, SC_PKCS15_TYPE_CERT_X509, obj_id & 0xFF);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot update list");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "'Create Cert' update DF failed: cannot update list");
|
||||||
|
|
||||||
rv = awp_update_container(p15card, profile, SC_PKCS15_TYPE_CERT_X509, &icert.id, obj_id, &prvkey_id);
|
rv = awp_update_container(p15card, profile, SC_PKCS15_TYPE_CERT_X509, &icert.id, obj_id, &prvkey_id);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot update container");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "'Create Cert' update DF failed: cannot update container");
|
||||||
|
|
||||||
sc_log(ctx, "PrvKeyID:%04X", prvkey_id);
|
sc_log(ctx, "PrvKeyID:%04X", prvkey_id);
|
||||||
|
|
||||||
if (prvkey_id)
|
if (prvkey_id)
|
||||||
rv = awp_update_key_info(p15card, profile, prvkey_id, &icert);
|
rv = awp_update_key_info(p15card, profile, prvkey_id, &icert);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "'Create Cert' update DF failed: cannot update key info");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "'Create Cert' update DF failed: cannot update key info");
|
||||||
|
|
||||||
awp_free_cert_info(&icert);
|
awp_free_cert_info(&icert);
|
||||||
|
|
||||||
|
@ -1452,13 +1452,13 @@ awp_update_df_create_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
||||||
cc.cert_id = (path.value[path.len-1] & 0xFF) + (path.value[path.len-2] & 0xFF) * 0x100;
|
cc.cert_id = (path.value[path.len-1] & 0xFF) + (path.value[path.len-2] & 0xFF) * 0x100;
|
||||||
|
|
||||||
rv = sc_pkcs15_read_certificate(p15card, cert_info, &p15cert);
|
rv = sc_pkcs15_read_certificate(p15card, cert_info, &p15cert);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: cannot get certificate");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: cannot get certificate");
|
||||||
|
|
||||||
rv = sc_pkcs15_allocate_object_content(ctx, cert_obj, p15cert->data.value, p15cert->data.len);
|
rv = sc_pkcs15_allocate_object_content(ctx, cert_obj, p15cert->data.value, p15cert->data.len);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: cannot allocate content");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: cannot allocate content");
|
||||||
|
|
||||||
rv = awp_encode_cert_info(p15card, cert_obj, &icert);
|
rv = awp_encode_cert_info(p15card, cert_obj, &icert);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: cannot encode cert info");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: cannot encode cert info");
|
||||||
|
|
||||||
sc_pkcs15_free_certificate(p15cert);
|
sc_pkcs15_free_certificate(p15cert);
|
||||||
p15cert = NULL;
|
p15cert = NULL;
|
||||||
|
@ -1471,25 +1471,25 @@ awp_update_df_create_prvkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = awp_new_file(p15card, profile, key_obj->type, cc.prkey_id & 0xFF, &info_file, NULL);
|
rv = awp_new_file(p15card, profile, key_obj->type, cc.prkey_id & 0xFF, &info_file, NULL);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "New private key info file error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "New private key info file error");
|
||||||
|
|
||||||
pubkey.algorithm = SC_ALGORITHM_RSA;
|
pubkey.algorithm = SC_ALGORITHM_RSA;
|
||||||
sc_log(ctx,
|
sc_log(ctx,
|
||||||
"PrKey Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
|
"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_VERBOSE, rv, "AWP 'update private key' DF failed: decode public key error");
|
||||||
|
|
||||||
rv = awp_encode_key_info(p15card, key_obj, &pubkey.u.rsa, &ikey);
|
rv = awp_encode_key_info(p15card, key_obj, &pubkey.u.rsa, &ikey);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: encode info error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: encode info error");
|
||||||
|
|
||||||
rv = awp_set_key_info(p15card, profile, info_file, &ikey, cert_obj ? &icert : NULL);
|
rv = awp_set_key_info(p15card, profile, info_file, &ikey, cert_obj ? &icert : NULL);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: set info error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: set info error");
|
||||||
|
|
||||||
rv = awp_update_object_list(p15card, profile, key_obj->type, cc.prkey_id & 0xFF);
|
rv = awp_update_object_list(p15card, profile, key_obj->type, cc.prkey_id & 0xFF);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: update object list error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: update object list error");
|
||||||
|
|
||||||
rv = awp_create_container(p15card, profile, key_obj->type, &ikey.id, &cc);
|
rv = awp_create_container(p15card, profile, key_obj->type, &ikey.id, &cc);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update private key' DF failed: update container error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update private key' DF failed: update container error");
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (p15cert)
|
if (p15cert)
|
||||||
|
@ -1526,25 +1526,25 @@ awp_update_df_create_pubkey(struct sc_pkcs15_card *p15card, struct sc_profile *p
|
||||||
memset(&ikey, 0, sizeof(ikey));
|
memset(&ikey, 0, sizeof(ikey));
|
||||||
|
|
||||||
rv = awp_new_file(p15card, profile, obj->type, index, &info_file, NULL);
|
rv = awp_new_file(p15card, profile, obj->type, index, &info_file, NULL);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "New public key info file error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "New public key info file error");
|
||||||
|
|
||||||
pubkey.algorithm = SC_ALGORITHM_RSA;
|
pubkey.algorithm = SC_ALGORITHM_RSA;
|
||||||
sc_log(ctx,
|
sc_log(ctx,
|
||||||
"PrKey Der(%p,%"SC_FORMAT_LEN_SIZE_T"u)", der.value, der.len);
|
"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_VERBOSE, rv, "AWP 'update public key' DF failed: decode public key error");
|
||||||
|
|
||||||
rv = awp_encode_key_info(p15card, obj, &pubkey.u.rsa, &ikey);
|
rv = awp_encode_key_info(p15card, obj, &pubkey.u.rsa, &ikey);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update public key' DF failed: encode info error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update public key' DF failed: encode info error");
|
||||||
|
|
||||||
rv = awp_set_key_info(p15card, profile, info_file, &ikey, NULL);
|
rv = awp_set_key_info(p15card, profile, info_file, &ikey, NULL);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update public key' DF failed: set info error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update public key' DF failed: set info error");
|
||||||
|
|
||||||
rv = awp_update_object_list(p15card, profile, obj->type, index);
|
rv = awp_update_object_list(p15card, profile, obj->type, index);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update public key' DF failed: update object list error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update public key' DF failed: update object list error");
|
||||||
|
|
||||||
rv = awp_update_container(p15card, profile, obj->type, &ikey.id, obj_id, NULL);
|
rv = awp_update_container(p15card, profile, obj->type, &ikey.id, obj_id, NULL);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "AWP 'update public key' DF failed: update container error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "AWP 'update public key' DF failed: update container error");
|
||||||
|
|
||||||
err:
|
err:
|
||||||
awp_free_key_info(&ikey);
|
awp_free_key_info(&ikey);
|
||||||
|
|
|
@ -73,18 +73,18 @@ cosm_write_tokeninfo (struct sc_pkcs15_card *p15card, struct sc_profile *profile
|
||||||
sc_log(ctx, "cosm_write_tokeninfo() label '%s'; flags 0x%X", label, flags);
|
sc_log(ctx, "cosm_write_tokeninfo() label '%s'; flags 0x%X", label, flags);
|
||||||
if (sc_profile_get_file(profile, COSM_TITLE"-token-info", &file)) {
|
if (sc_profile_get_file(profile, COSM_TITLE"-token-info", &file)) {
|
||||||
rv = SC_ERROR_INCONSISTENT_PROFILE;
|
rv = SC_ERROR_INCONSISTENT_PROFILE;
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Cannot find "COSM_TITLE"-token-info");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Cannot find "COSM_TITLE"-token-info");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->size < 16) {
|
if (file->size < 16) {
|
||||||
rv = SC_ERROR_INCONSISTENT_PROFILE;
|
rv = SC_ERROR_INCONSISTENT_PROFILE;
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Insufficient size of the "COSM_TITLE"-token-info file");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Insufficient size of the "COSM_TITLE"-token-info file");
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = calloc(1, file->size);
|
buffer = calloc(1, file->size);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
rv = SC_ERROR_OUT_OF_MEMORY;
|
rv = SC_ERROR_OUT_OF_MEMORY;
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Allocation error in cosm_write_tokeninfo()");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Allocation error in cosm_write_tokeninfo()");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (label)
|
if (label)
|
||||||
|
@ -705,14 +705,14 @@ cosm_create_key(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
rv = sc_select_file(p15card->card, &file->path, NULL);
|
rv = sc_select_file(p15card->card, &file->path, NULL);
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
rv = cosm_delete_file(p15card, profile, file);
|
rv = cosm_delete_file(p15card, profile, file);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to delete private key file");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Failed to delete private key file");
|
||||||
}
|
}
|
||||||
else if (rv != SC_ERROR_FILE_NOT_FOUND) {
|
else if (rv != SC_ERROR_FILE_NOT_FOUND) {
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Select private key file error");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Select private key file error");
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = sc_pkcs15init_create_file(profile, p15card, file);
|
rv = sc_pkcs15init_create_file(profile, p15card, file);
|
||||||
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_NORMAL, rv, "Failed to create private key file");
|
SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Failed to create private key file");
|
||||||
|
|
||||||
key_info->key_reference = file->path.value[file->path.len - 1];
|
key_info->key_reference = file->path.value[file->path.len - 1];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue