1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-01 16:33:02 +01:00

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 <wk@gnupg.org>
(cherry picked from commit d5fb5983232cf4d60cf6aa00d0ae5a16cf948e19)
This commit is contained in:
Werner Koch 2021-03-19 13:43:46 +01:00
parent 57bfad2c39
commit 9e3b7e26a9
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -213,6 +213,12 @@ 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;
/* Pinpad request specified on card. */
struct
{
@ -359,6 +365,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)
@ -5742,6 +5751,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)
@ -5822,8 +5834,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);
@ -5841,6 +5855,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.learn_status = do_learn_status;
app->fnc.readcert = do_readcert;