return s;
}
+/* Returns the fingerprint if available, otherwise
+ * returns the long keyid.
+ */
+static const char *crypt_fpr_or_lkeyid(crypt_key_t *k)
+{
+ const char *s = "????????????????";
+
+ if (k->kobj && k->kobj->subkeys)
+ {
+ if (k->kobj->subkeys->fpr)
+ s = k->kobj->subkeys->fpr;
+ else
+ s = k->kobj->subkeys->keyid;
+ }
+
+ return s;
+}
+
/* Parse FLAGS and return a statically allocated(!) string with them. */
static char *crypt_key_abilities (int flags)
{
if ((r = mutt_strcasecmp ((*s)->uid, (*t)->uid)))
return r > 0;
else
- return mutt_strcasecmp (crypt_keyid (*s), crypt_keyid (*t)) > 0;
+ return mutt_strcasecmp (crypt_fpr_or_lkeyid (*s), crypt_fpr_or_lkeyid (*t)) > 0;
}
static int crypt_compare_address (const void *a, const void *b)
crypt_key_t **t = (crypt_key_t **) b;
int r;
- if ((r = mutt_strcasecmp (crypt_keyid (*s), crypt_keyid (*t))))
+ if ((r = mutt_strcasecmp (crypt_fpr_or_lkeyid (*s), crypt_fpr_or_lkeyid (*t))))
return r > 0;
else
return mutt_strcasecmp ((*s)->uid, (*t)->uid) > 0;
if ((r = mutt_strcasecmp ((*s)->uid, (*t)->uid)))
return r > 0;
- return (mutt_strcasecmp (crypt_keyid ((*s)), crypt_keyid ((*t)))) > 0;
+ return (mutt_strcasecmp (crypt_fpr_or_lkeyid ((*s)), crypt_fpr_or_lkeyid ((*t)))) > 0;
}
static int crypt_compare_trust (const void *a, const void *b)
}
- keyID = crypt_fpr (k_info);
+ keyID = crypt_fpr_or_lkeyid (k_info);
#if 0
if (k_info->flags & KEYFLAG_ISX509)
is_smime? APPLICATION_SMIME:APPLICATION_PGP,
NULL)))
{
- snprintf (input_signas, sizeof (input_signas), "0x%s", crypt_keyid (p));
+ snprintf (input_signas, sizeof (input_signas), "0x%s",
+ crypt_fpr_or_lkeyid (p));
mutt_str_replace (is_smime? &SmimeDefaultKey : &PgpSignAs, input_signas);
crypt_free_key (&p);
<para>
The meaning of <emphasis>keyid</emphasis> is to be taken broadly in this
-context: You can either put a numerical key ID here, an e-mail address,
-or even just a real name.
+context: You can either put a numerical key ID or fingerprint here, an
+e-mail address, or even just a real name.
</para>
</sect1>
** .dt %s .dd Expands to the name of a file containing the signature part
** . of a \fCmultipart/signed\fP attachment when verifying it.
** .dt %a .dd The value of $$pgp_sign_as.
- ** .dt %r .dd One or more key IDs.
+ ** .dt %r .dd One or more key IDs (or fingerprints if available).
** .de
** .pp
** For examples on how to configure these formats for the various versions
** This command is used to list the public key ring's contents. The
** output format must be analogous to the one used by
** .ts
- ** gpg --list-keys --with-colons
+ ** gpg --list-keys --with-colons --with-fingerprint
** .te
** .pp
** This format is also generated by the \fCpgpring\fP utility which comes
** This command is used to list the secret key ring's contents. The
** output format must be analogous to the one used by:
** .ts
- ** gpg --list-keys --with-colons
+ ** gpg --list-keys --with-colons --with-fingerprint
** .te
** .pp
** This format is also generated by the \fCpgpring\fP utility which comes
** possible \fCprintf(3)\fP-like sequences.
** (PGP only)
*/
- { "pgp_long_ids", DT_BOOL, R_NONE, OPTPGPLONGIDS, 0 },
+ { "pgp_long_ids", DT_BOOL, R_NONE, OPTPGPLONGIDS, 1 },
/*
** .pp
** If \fIset\fP, use 64 bit PGP key IDs, if \fIunset\fP use the normal 32 bit key IDs.
+ ** NOTE: Internally, Mutt has transitioned to using fingerprints (or long key IDs
+ ** as a fallback). This option now only controls the display of key IDs
+ ** in the key selection menu and a few other places.
** (PGP only)
*/
{ "pgp_mime_auto", DT_QUAD, R_NONE, OPT_PGPMIMEAUTO, M_ASKYES },
/*
** .pp
** This is the key used to encrypt postponed messages. It should be in
- ** keyid form (e.g. 0x00112233 for PGP or the hash-value that OpenSSL
- ** generates for S/MIME).
+ ** keyid or fingerprint form (e.g. 0x00112233 for PGP or the
+ ** hash-value that OpenSSL generates for S/MIME).
** (Crypto only)
*/
#ifdef USE_SOCKET
return (k->keyid + 8);
}
+char *pgp_fingerprint(pgp_key_t k)
+{
+ k = _pgp_parent(k);
+
+ return k->fingerprint;
+}
+
+/* Grab the longest key identifier available: fingerprint or else
+ * the long keyid.
+ *
+ * The longest available should be used for internally identifying
+ * the key and for invoking pgp commands.
+ */
+char *pgp_fpr_or_lkeyid(pgp_key_t k)
+{
+ char *fingerprint;
+
+ fingerprint = pgp_fingerprint (k);
+ return fingerprint ? fingerprint : pgp_long_keyid (k);
+}
+
/* ----------------------------------------------------------------------------
* Routines for handing PGP input.
*/
return NULL;
}
- keyID = pgp_keyid (k_info);
+ keyID = pgp_fpr_or_lkeyid (k_info);
bypass_selection:
keylist_size += mutt_strlen (keyID) + 4;
if ((p = pgp_ask_for_key (_("Sign as: "), NULL, 0, PGP_SECRING)))
{
snprintf (input_signas, sizeof (input_signas), "0x%s",
- pgp_keyid (p));
+ pgp_fpr_or_lkeyid (p));
mutt_str_replace (&PgpSignAs, input_signas);
pgp_free_key (&p);
char *pgp_keyid (pgp_key_t);
char *pgp_short_keyid (pgp_key_t);
char *pgp_long_keyid (pgp_key_t);
+char *pgp_fingerprint (pgp_key_t k);
+char *pgp_fpr_or_lkeyid (pgp_key_t k);
int mutt_check_pgp (HEADER * h);
if ((r = mutt_strcasecmp ((*s)->addr, (*t)->addr)))
return r > 0;
else
- return (mutt_strcasecmp (_pgp_keyid ((*s)->parent),
- _pgp_keyid ((*t)->parent)) > 0);
+ return (mutt_strcasecmp (pgp_fpr_or_lkeyid ((*s)->parent),
+ pgp_fpr_or_lkeyid ((*t)->parent)) > 0);
}
static int pgp_compare_address (const void *a, const void *b)
pgp_uid_t **s = (pgp_uid_t **) a;
pgp_uid_t **t = (pgp_uid_t **) b;
- if ((r = mutt_strcasecmp (_pgp_keyid ((*s)->parent),
- _pgp_keyid ((*t)->parent))))
+ if ((r = mutt_strcasecmp (pgp_fpr_or_lkeyid ((*s)->parent),
+ pgp_fpr_or_lkeyid ((*t)->parent))))
return r > 0;
else
return (mutt_strcasecmp ((*s)->addr, (*t)->addr)) > 0;
return r < 0;
if ((r = mutt_strcasecmp ((*s)->addr, (*t)->addr)))
return r > 0;
- return (mutt_strcasecmp (_pgp_keyid ((*s)->parent),
- _pgp_keyid ((*t)->parent))) > 0;
+ return (mutt_strcasecmp (pgp_fpr_or_lkeyid ((*s)->parent),
+ pgp_fpr_or_lkeyid ((*t)->parent))) > 0;
}
static int pgp_compare_trust (const void *a, const void *b)
mutt_message _("Invoking PGP...");
- snprintf (tmpbuf, sizeof (tmpbuf), "0x%s", pgp_keyid (pgp_principal_key (KeyTable[menu->current]->parent)));
+ snprintf (tmpbuf, sizeof (tmpbuf), "0x%s",
+ pgp_fpr_or_lkeyid (pgp_principal_key (KeyTable[menu->current]->parent)));
if ((thepid = pgp_invoke_verify_key (NULL, NULL, NULL, -1,
fileno (fp), fileno (devnull), tmpbuf)) == -1)
if (!key) return NULL;
- snprintf (tmp, sizeof (tmp), "0x%s", pgp_keyid (pgp_principal_key (key)));
+ snprintf (tmp, sizeof (tmp), "0x%s", pgp_fpr_or_lkeyid (pgp_principal_key (key)));
pgp_free_key (&key);
if (!tempf)