pkcs15init: function to finalize profile when binding to the application of the multi-application PKCS#15 card.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5100 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
51ab68db83
commit
4c183b2b38
|
@ -285,6 +285,7 @@ sc_pkcs15init_update_certificate
|
||||||
sc_pkcs15init_update_file
|
sc_pkcs15init_update_file
|
||||||
sc_pkcs15init_verify_secret
|
sc_pkcs15init_verify_secret
|
||||||
sc_pkcs15init_sanity_check
|
sc_pkcs15init_sanity_check
|
||||||
|
sc_pkcs15init_finalize_profile
|
||||||
sc_card_find_rsa_alg
|
sc_card_find_rsa_alg
|
||||||
sc_print_cache
|
sc_print_cache
|
||||||
sc_find_app
|
sc_find_app
|
||||||
|
|
|
@ -368,6 +368,9 @@ extern int sc_pkcs15init_get_pin_reference(struct sc_pkcs15_card *,
|
||||||
|
|
||||||
extern int sc_pkcs15init_sanity_check(struct sc_pkcs15_card *, struct sc_profile *);
|
extern int sc_pkcs15init_sanity_check(struct sc_pkcs15_card *, struct sc_profile *);
|
||||||
|
|
||||||
|
extern int sc_pkcs15init_finalize_profile(struct sc_card *card, struct sc_profile *profile,
|
||||||
|
struct sc_aid *aid);
|
||||||
|
|
||||||
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_gpk_ops(void);
|
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_gpk_ops(void);
|
||||||
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_miocos_ops(void);
|
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_miocos_ops(void);
|
||||||
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_cryptoflex_ops(void);
|
extern struct sc_pkcs15init_operations *sc_pkcs15init_get_cryptoflex_ops(void);
|
||||||
|
|
|
@ -652,6 +652,36 @@ sc_pkcs15init_finalize_card(struct sc_card *card, struct sc_profile *profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
sc_pkcs15init_finalize_profile(struct sc_card *card, struct sc_profile *profile,
|
||||||
|
struct sc_aid *aid)
|
||||||
|
{
|
||||||
|
struct sc_context *ctx = card->ctx;
|
||||||
|
const struct sc_app_info *app = NULL;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
LOG_FUNC_CALLED(ctx);
|
||||||
|
if (!aid || !aid->len)
|
||||||
|
LOG_FUNC_RETURN(ctx, SC_SUCCESS);
|
||||||
|
|
||||||
|
if (card->app_count < 0)
|
||||||
|
sc_enum_apps(card);
|
||||||
|
|
||||||
|
sc_log(ctx, "finalize profile for AID %s", sc_dump_hex(aid->value, aid->len));
|
||||||
|
app = sc_find_app(card, aid);
|
||||||
|
if (!app) {
|
||||||
|
sc_log(ctx, "Cannot find oncard application");
|
||||||
|
LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
sc_log(ctx, "Finalize profile with application '%s'", app->label);
|
||||||
|
rv = sc_profile_finish(profile, app);
|
||||||
|
|
||||||
|
sc_log(ctx, "sc_pkcs15init_finalize_profile() returns %i", rv);
|
||||||
|
LOG_FUNC_RETURN(ctx, rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the PKCS#15 application
|
* Initialize the PKCS#15 application
|
||||||
*/
|
*/
|
||||||
|
@ -3174,7 +3204,7 @@ do_select_parent(struct sc_profile *profile, struct sc_pkcs15_card *p15card,
|
||||||
path = file->path;
|
path = file->path;
|
||||||
if (path.len >= 2)
|
if (path.len >= 2)
|
||||||
path.len -= 2;
|
path.len -= 2;
|
||||||
if (path.len == 0)
|
if (!path.len && !path.aid.len)
|
||||||
sc_format_path("3F00", &path);
|
sc_format_path("3F00", &path);
|
||||||
|
|
||||||
/* Select the parent DF. */
|
/* Select the parent DF. */
|
||||||
|
|
|
@ -462,6 +462,13 @@ main(int argc, char **argv)
|
||||||
fprintf(stderr, "Invalid AID value: '%s'\n", opt_bind_to_aid);
|
fprintf(stderr, "Invalid AID value: '%s'\n", opt_bind_to_aid);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = sc_pkcs15init_finalize_profile(card, profile, &aid);
|
||||||
|
if (r < 0) {
|
||||||
|
fprintf(stderr, "Finalize profile error %s\n", sc_strerror(r));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
r = sc_pkcs15_bind(card, &aid, &p15card);
|
r = sc_pkcs15_bind(card, &aid, &p15card);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in New Issue