pkcs15init: for the EC key put the EC specific data into the 'params' member of 'key-info' data ...
; more of debug messages; git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5414 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
5e50a14b3f
commit
1e59a09dbd
|
@ -164,6 +164,9 @@ static struct sc_pkcs15init_callbacks callbacks = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void sc_pkcs15init_empty_callback(void *ptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the application callbacks
|
* 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->gostr3411 = keyargs->params.gost.gostr3411;
|
||||||
keyinfo_gostparams->gost28147 = keyargs->params.gost.gost28147;
|
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);
|
r = select_object_path(p15card, profile, object, &key_info->path);
|
||||||
LOG_TEST_RET(ctx, r, "Failed to select private key object 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);
|
r = select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_PUBKEY, &iid, &pubkey_args.key);
|
||||||
LOG_TEST_RET(ctx, r, "Select intrinsic ID error");
|
LOG_TEST_RET(ctx, r, "Select intrinsic ID error");
|
||||||
|
|
||||||
if (iid.len) {
|
if (iid.len)
|
||||||
key_info->id = iid;
|
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);
|
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");
|
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)
|
if (info->key_length != keybits)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return SC_SUCCESS;
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
|
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.
|
* Add an object to one of the pkcs15 directory files.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card,
|
sc_pkcs15init_add_object(struct sc_pkcs15_card *p15card, struct sc_profile *profile,
|
||||||
struct sc_profile *profile,
|
unsigned int df_type, struct sc_pkcs15_object *object)
|
||||||
unsigned int df_type,
|
|
||||||
struct sc_pkcs15_object *object)
|
|
||||||
{
|
{
|
||||||
struct sc_context *ctx = p15card->card->ctx;
|
struct sc_context *ctx = p15card->card->ctx;
|
||||||
struct sc_pkcs15_df *df;
|
struct sc_pkcs15_df *df;
|
||||||
|
@ -2653,13 +2659,10 @@ sc_pkcs15init_new_object(int type, const char *label, struct sc_pkcs15_id *auth_
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card,
|
sc_pkcs15init_change_attrib(struct sc_pkcs15_card *p15card, struct sc_profile *profile, struct sc_pkcs15_object *object,
|
||||||
struct sc_profile *profile,
|
int new_attrib_type, void *new_value, int new_len)
|
||||||
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;
|
struct sc_card *card = p15card->card;
|
||||||
unsigned char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
size_t bufsize;
|
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;
|
((struct sc_pkcs15_cert_info *) object->data)->id = new_id;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return SC_ERROR_NOT_SUPPORTED;
|
LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Cannot change ID attribute");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
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) {
|
if (profile->ops->emu_update_any_df) {
|
||||||
r = profile->ops->emu_update_any_df(profile, p15card, SC_AC_OP_CREATE, object);
|
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 {
|
else {
|
||||||
r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize);
|
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;
|
struct sc_file *file = NULL;
|
||||||
|
|
||||||
r = sc_profile_get_file_by_path(profile, &df->path, &file);
|
r = sc_profile_get_file_by_path(profile, &df->path, &file);
|
||||||
if(r < 0)
|
LOG_TEST_RET(ctx, r, "Cannot instantiate file by path");
|
||||||
return r;
|
|
||||||
|
|
||||||
r = sc_pkcs15init_update_file(profile, p15card, file, buf, bufsize);
|
r = sc_pkcs15init_update_file(profile, p15card, file, buf, bufsize);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
Loading…
Reference in New Issue