diff options
author | David Shaw <[email protected]> | 2004-09-15 18:41:36 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2004-09-15 18:41:36 +0000 |
commit | a46e83b8e31db620ec23dd0cb245a648d2f822a1 (patch) | |
tree | a53e5753d04e4e897946996e2fe0d1437ae64736 /g10/misc.c | |
parent | * configure.ac: Give warning when using capabilities. Check for (diff) | |
download | gnupg-a46e83b8e31db620ec23dd0cb245a648d2f822a1.tar.gz gnupg-a46e83b8e31db620ec23dd0cb245a648d2f822a1.zip |
* gpgv.c (agent_scd_getattr): Stub.
* misc.c (get_signature_count): New. Get the signature count from a
smartcard. (pct_expando): Call it here so the %c expando becomes the
number of signatures issued. This allows for notations or the like with
an automatic signature count.
* ccid-driver.c (usb_get_string_simple): Replacement function to work with
older libusb.
Diffstat (limited to 'g10/misc.c')
-rw-r--r-- | g10/misc.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c index c2dfe3515..c47459ba6 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -39,6 +39,7 @@ #include "photoid.h" #include "options.h" #include "i18n.h" +#include "cardglue.h" #if defined(__linux__) && defined(__alpha__) && __GLIBC__ < 2 static int @@ -287,6 +288,22 @@ idea_cipher_warn(int show) } #endif +static unsigned long get_signature_count(PKT_secret_key *sk) +{ +#ifdef ENABLE_CARD_SUPPORT + if(sk && sk->is_protected && sk->protect.s2k.mode==1002) + { + struct agent_card_info_s info; + if(agent_scd_getattr("SIG-COUNTER",&info)==0) + return info.sig_counter; + } +#endif + + /* How to do this without a card? */ + + return 0; +} + /* Expand %-strings. Returns a string which must be m_freed. Returns NULL if the string cannot be expanded (too large). */ char * @@ -366,6 +383,15 @@ pct_expando(const char *string,struct expando_args *args) } break; + case 'c': /* signature count from card, if any. */ + if(idx+10<maxlen) + { + sprintf(&ret[idx],"%lu",get_signature_count(args->sk)); + idx+=strlen(&ret[idx]); + done=1; + } + break; + case 'p': /* primary pk fingerprint of a sk */ case 'f': /* pk fingerprint */ case 'g': /* sk fingerprint */ |