From bd76165319b8b1fa8883e6dd5fe6eae07fb7ed1f Mon Sep 17 00:00:00 2001 From: sth Date: Wed, 24 Aug 2005 09:50:48 +0000 Subject: [PATCH] Have the option not to update the ODF (the lastUpdate field), this is usefull for cards that don't have an ODF that is un-writable or too small git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2515 c6295689-39f2-0310-b995-f0e70906c6a9 --- src/pkcs15init/pkcs15-lib.c | 2 +- src/pkcs15init/pkcs15.profile | 2 ++ src/pkcs15init/profile.c | 9 +++++++++ src/pkcs15init/profile.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pkcs15init/pkcs15-lib.c b/src/pkcs15init/pkcs15-lib.c index 25e2f007..14de3016 100644 --- a/src/pkcs15init/pkcs15-lib.c +++ b/src/pkcs15init/pkcs15-lib.c @@ -354,7 +354,7 @@ sc_pkcs15init_unbind(struct sc_profile *profile) int r; struct sc_context *ctx = profile->card->ctx; - if (profile->dirty != 0 && profile->p15_data != NULL) { + if (profile->dirty != 0 && profile->p15_data != NULL && profile->pkcs15.odf_last_update) { r = sc_pkcs15init_update_tokeninfo(profile->p15_data, profile); if (r < 0) sc_error(ctx, "Failed to update TokenInfo: %s\n", sc_strerror(r)); diff --git a/src/pkcs15init/pkcs15.profile b/src/pkcs15init/pkcs15.profile index a1efa23e..b5d11455 100644 --- a/src/pkcs15init/pkcs15.profile +++ b/src/pkcs15init/pkcs15.profile @@ -20,6 +20,8 @@ pkcs15 { direct-certificates = no; # Put the DF length into the ODF file? encode-df-length = no; + # Have a lastUpdate field in the ODF? + odf-last-update = yes; } # Default settings. diff --git a/src/pkcs15init/profile.c b/src/pkcs15init/profile.c index 656ae662..1f0082e4 100644 --- a/src/pkcs15init/profile.c +++ b/src/pkcs15init/profile.c @@ -255,6 +255,8 @@ sc_profile_new(void) return NULL; pro->p15_spec = p15card = sc_pkcs15_card_new(); + pro->pkcs15.odf_last_update = 1; + /* Set up EF(TokenInfo) and EF(ODF) */ p15card->file_tokeninfo = init_file(SC_FILE_TYPE_WORKING_EF); p15card->file_odf = init_file(SC_FILE_TYPE_WORKING_EF); @@ -749,6 +751,12 @@ do_encode_df_length(struct state *cur, int argc, char **argv) return get_bool(cur, argv[0], &cur->profile->pkcs15.encode_df_length); } +static int +do_encode_odf_update_field(struct state *cur, int argc, char **argv) +{ + return get_bool(cur, argv[0], &cur->profile->pkcs15.odf_last_update); +} + /* * Process an option block */ @@ -1489,6 +1497,7 @@ static struct command pi_commands[] = { static struct command p15_commands[] = { { "direct-certificates", 1, 1, do_direct_certificates }, { "encode-df-length", 1, 1, do_encode_df_length }, + { "odf-last-update", 1, 1, do_encode_odf_update_field }, { NULL, 0, 0, NULL } }; diff --git a/src/pkcs15init/profile.h b/src/pkcs15init/profile.h index 8870217e..0359d1ae 100644 --- a/src/pkcs15init/profile.h +++ b/src/pkcs15init/profile.h @@ -110,6 +110,7 @@ struct sc_profile { struct { unsigned int direct_certificates; unsigned int encode_df_length; + unsigned int odf_last_update; } pkcs15; /* PKCS15 information */