diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c index b9d8bc52..6ec3b241 100644 --- a/src/pkcs15init/pkcs15-lib.c +++ b/src/pkcs15init/pkcs15-lib.c @@ -164,6 +164,9 @@ static struct sc_pkcs15init_callbacks callbacks = { NULL, }; +void sc_pkcs15init_empty_callback(void *ptr) +{ +} /* * Set the application callbacks @@ -1140,6 +1143,12 @@ sc_pkcs15init_init_prkdf(struct sc_pkcs15_card *p15card, keyinfo_gostparams->gostr3411 = keyargs->params.gost.gostr3411; keyinfo_gostparams->gost28147 = keyargs->params.gost.gost28147; } + else if (key->algorithm == SC_ALGORITHM_EC) { + struct sc_pkcs15_ec_parameters *ecparams = &keyargs->params.ec; + key_info->params.data = &keyargs->params.ec; + key_info->params.free_params = sc_pkcs15init_empty_callback; + key_info->field_length = ecparams->field_length; + } r = select_object_path(p15card, profile, object, &key_info->path); LOG_TEST_RET(ctx, r, "Failed to select private key object path"); @@ -1239,12 +1248,11 @@ sc_pkcs15init_generate_key(struct sc_pkcs15_card *p15card, struct sc_profile *pr r = select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_PUBKEY, &iid, &pubkey_args.key); LOG_TEST_RET(ctx, r, "Select intrinsic ID error"); - if (iid.len) { + if (iid.len) key_info->id = iid; - pubkey_args.id = iid; - } } + pubkey_args.id = key_info->id; r = sc_pkcs15_encode_pubkey(ctx, &pubkey_args.key, &object->content.value, &object->content.len); LOG_TEST_RET(ctx, r, "Failed to encode public key"); @@ -1854,7 +1862,7 @@ check_keygen_params_consistency(struct sc_card *card, struct sc_pkcs15init_keyge if (info->key_length != keybits) continue; - return SC_SUCCESS; + LOG_FUNC_RETURN(ctx, SC_SUCCESS); } LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED); @@ -2546,10 +2554,8 @@ sc_pkcs15init_update_any_df(struct sc_pkcs15_card *p15card, * Add an object to one of the pkcs15 directory files. */ int -sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card, - struct sc_profile *profile, - unsigned int df_type, - struct sc_pkcs15_object *object) +sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card, struct sc_profile *profile, + unsigned int df_type, struct sc_pkcs15_object *object) { struct sc_context *ctx = p15card->card->ctx; struct sc_pkcs15_df *df; @@ -2653,13 +2659,10 @@ sc_pkcs15init_new_object(int type, const char *label, struct sc_pkcs15_id *auth_ int -sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card, - struct sc_profile *profile, - struct sc_pkcs15_object *object, - int new_attrib_type, - void *new_value, - int new_len) +sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card, struct sc_profile *profile, struct sc_pkcs15_object *object, + int new_attrib_type, void *new_value, int new_len) { + struct sc_context *ctx = p15card->card->ctx; struct sc_card *card = p15card->card; unsigned char *buf = NULL; size_t bufsize; @@ -2697,16 +2700,16 @@ sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card, ((struct sc_pkcs15_cert_info *) object->data)->id = new_id; break; default: - return SC_ERROR_NOT_SUPPORTED; + LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Cannot change ID attribute"); } break; default: - return SC_ERROR_NOT_SUPPORTED; + LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Only 'LABEL' or 'ID' attributes can be changed"); } if (profile->ops->emu_update_any_df) { r = profile->ops->emu_update_any_df(profile, p15card, SC_AC_OP_CREATE, object); - LOG_TEST_RET(card->ctx, r, "Card specific DF update failed"); + LOG_TEST_RET(ctx, r, "Card specific DF update failed"); } else { r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize); @@ -2714,8 +2717,7 @@ sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card, struct sc_file *file = NULL; r = sc_profile_get_file_by_path(profile, &df->path, &file); - if(r < 0) - return r; + LOG_TEST_RET(ctx, r, "Cannot instantiate file by path"); r = sc_pkcs15init_update_file(profile, p15card, file, buf, bufsize); free(buf);