aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-03-19 12:43:46 +0000
committerWerner Koch <[email protected]>2021-03-19 12:43:46 +0000
commitd5fb5983232cf4d60cf6aa00d0ae5a16cf948e19 (patch)
tree009880730440394e3070fe97bffe6156a42c41cb
parentscd:p15: Allow to use an auth object label with cmd CHECKPIN. (diff)
downloadgnupg-d5fb5983232cf4d60cf6aa00d0ae5a16cf948e19.tar.gz
gnupg-d5fb5983232cf4d60cf6aa00d0ae5a16cf948e19.zip
scd:openpgp: Small speedup reading card properties.
* scd/app-openpgp.c (struct app_local_s): Add new flag. (get_cached_data): Force chace use if flag is set. (app_select_openpgp): Avoid reading DO 6E multiple times. -- The do not cache property of 6E was introduced so that we can change for example key attributes without getting into with the cache. However, for initial reading the cache makes a lot of sense and thus we now use this hack to only temporary cache. A better strategy would be to clear the cache when we change card data but that is more error prone. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--scd/app-openpgp.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c
index 7060e36d2..9fe200c61 100644
--- a/scd/app-openpgp.c
+++ b/scd/app-openpgp.c
@@ -218,6 +218,11 @@ struct app_local_s {
unsigned int def_chv2:1; /* Use 123456 for CHV2. */
} flags;
+ /* Flags used to override certain behavior. */
+ struct
+ {
+ unsigned int cache_6e:1;
+ } override;
/* Keep track on whether we cache a certain PIN so that we get it
* from the cache only if we know we cached it. This inhibits the
@@ -405,6 +410,9 @@ get_cached_data (app_t app, int tag,
*result = NULL;
*resultlen = 0;
+ if (tag == 0x6E && app->app_local->override.cache_6e)
+ get_immediate = 0;
+
if (!get_immediate)
{
for (c=app->app_local->cache; c; c = c->next)
@@ -6138,6 +6146,9 @@ app_select_openpgp (app_t app)
goto leave;
}
+ /* We want to temporary cache the DO 6E. */
+ app->app_local->override.cache_6e = 1;
+
app->app_local->manufacturer = manufacturer;
if (app->appversion >= 0x0200)
@@ -6216,8 +6227,10 @@ app_select_openpgp (app_t app)
/* Check optional DO of "General Feature Management" for button. */
relptr = get_one_do (app, 0x7f74, &buffer, &buflen, NULL);
if (relptr)
- /* It must be: 03 81 01 20 */
- app->app_local->extcap.has_button = 1;
+ {
+ /* It must be: 03 81 01 20 */
+ app->app_local->extcap.has_button = 1;
+ }
parse_login_data (app);
@@ -6231,6 +6244,9 @@ app_select_openpgp (app_t app)
if (opt.verbose > 1)
dump_all_do (slot);
+ app->app_local->override.cache_6e = 0;
+ flush_cache_item (app, 0x6E);
+
app->fnc.deinit = do_deinit;
app->fnc.prep_reselect = do_prep_reselect;
app->fnc.reselect = do_reselect;