aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 1b8e6172a..c98c9752e 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -322,6 +322,8 @@ pct_expando(const char *string,struct expando_args *args)
if(args->sk)
keyid_from_sk(args->sk,sk_keyid);
+ /* This is used so that %k works in photoid command strings in
+ --list-secret-keys (which of course has a sk, but no pk). */
if(!args->pk && args->sk)
keyid_from_sk(args->sk,pk_keyid);
@@ -383,16 +385,38 @@ pct_expando(const char *string,struct expando_args *args)
}
break;
- case 'f': /* fingerprint */
+ case 'p': /* primary pk fingerprint of a sk */
+ case 'f': /* pk fingerprint */
+ case 'g': /* sk fingerprint */
{
byte array[MAX_FINGERPRINT_LEN];
size_t len;
int i;
- if(args->pk)
+ if((*(ch+1))=='p' && args->sk)
+ {
+ if(args->sk->is_primary)
+ fingerprint_from_sk(args->sk,array,&len);
+ else if(args->sk->main_keyid[0] || args->sk->main_keyid[1])
+ {
+ PKT_public_key *pk=
+ m_alloc_clear(sizeof(PKT_public_key));
+
+ if(get_pubkey_fast(pk,args->sk->main_keyid)==0)
+ fingerprint_from_pk(pk,array,&len);
+ else
+ memset(array,0,(len=MAX_FINGERPRINT_LEN));
+ free_public_key(pk);
+ }
+ else
+ memset(array,0,(len=MAX_FINGERPRINT_LEN));
+ }
+ else if((*(ch+1))=='f' && args->pk)
fingerprint_from_pk(args->pk,array,&len);
+ else if((*(ch+1))=='g' && args->sk)
+ fingerprint_from_sk(args->sk,array,&len);
else
- memset(array,0, (len=MAX_FINGERPRINT_LEN));
+ memset(array,0,(len=MAX_FINGERPRINT_LEN));
if(idx+(len*2)<maxlen)
{