From a7962eeed6a4acf91dd2dbfc671e7a5d566a6ed7 Mon Sep 17 00:00:00 2001 From: okir Date: Thu, 3 Apr 2003 09:46:26 +0000 Subject: [PATCH] - stubs for "synthetic" pkcs15 tokens git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@970 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/libopensc/pkcs15.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/libopensc/pkcs15.c b/src/libopensc/pkcs15.c index 7ddc8a24..541e3c88 100644 --- a/src/libopensc/pkcs15.c +++ b/src/libopensc/pkcs15.c @@ -27,6 +27,9 @@ #include #include + +static int sc_pkcs15_bind_synthetic(struct sc_pkcs15_card *); + void sc_pkcs15_print_card(const struct sc_pkcs15_card *card) { const char *flags[] = { @@ -506,6 +509,19 @@ int sc_pkcs15_bind(struct sc_card *card, parse_ddo(p15card, info->ddo, info->ddo_len); } } + + /* Check if pkcs15 directory exists */ + i = ctx->log_errors; + ctx->log_errors = 0; + err = sc_select_file(card, &p15card->file_app->path, NULL); + ctx->log_errors = 1; + if (err < 0) { + err = sc_pkcs15_bind_synthetic(p15card); + if (err < 0) + goto error; + goto done; + } + if (p15card->file_odf == NULL) { tmppath = p15card->file_app->path; sc_append_path_id(&tmppath, (const u8 *) "\x50\x31", 2); @@ -558,6 +574,7 @@ int sc_pkcs15_bind(struct sc_card *card, } parse_tokeninfo(p15card, buf, err); +done: *p15card_out = p15card; sc_unlock(card); return 0; @@ -567,6 +584,12 @@ error: SC_FUNC_RETURN(ctx, 1, err); } +int sc_pkcs15_bind_synthetic(struct sc_pkcs15_card *p15card) +{ + /* Code to bind non pkcs15 cards as read-only will go here */ + return SC_ERROR_PKCS15_APP_NOT_FOUND; +} + int sc_pkcs15_detect(struct sc_card *card) { int r;