gpg: Show AEAD preferences

* g10/packet.h (preftype_t): Add PREFTYPE_AEAD.
* g10/keyedit.c (show_prefs): Print AEAD preferences.
* g10/getkey.c (fixup_uidnode): Set AEAD flags.
(merge_selfsigs): Ditto.
--

Although we are not able to create such keys we should be abale to
show them.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-04-16 08:27:51 +02:00
parent 1dfe71c62b
commit ab7a0b0702
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 49 additions and 5 deletions

View File

@ -2414,8 +2414,8 @@ fixup_uidnode (KBNODE uidnode, KBNODE signode, u32 keycreated)
{ {
PKT_user_id *uid = uidnode->pkt->pkt.user_id; PKT_user_id *uid = uidnode->pkt->pkt.user_id;
PKT_signature *sig = signode->pkt->pkt.signature; PKT_signature *sig = signode->pkt->pkt.signature;
const byte *p, *sym, *hash, *zip; const byte *p, *sym, *aead, *hash, *zip;
size_t n, nsym, nhash, nzip; size_t n, nsym, naead, nhash, nzip;
sig->flags.chosen_selfsig = 1;/* We chose this one. */ sig->flags.chosen_selfsig = 1;/* We chose this one. */
uid->created = 0; /* Not created == invalid. */ uid->created = 0; /* Not created == invalid. */
@ -2470,6 +2470,9 @@ fixup_uidnode (KBNODE uidnode, KBNODE signode, u32 keycreated)
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_SYM, &n); p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_SYM, &n);
sym = p; sym = p;
nsym = p ? n : 0; nsym = p ? n : 0;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_AEAD, &n);
aead = p;
naead = p ? n : 0;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_HASH, &n); p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_HASH, &n);
hash = p; hash = p;
nhash = p ? n : 0; nhash = p ? n : 0;
@ -2490,6 +2493,11 @@ fixup_uidnode (KBNODE uidnode, KBNODE signode, u32 keycreated)
uid->prefs[n].type = PREFTYPE_SYM; uid->prefs[n].type = PREFTYPE_SYM;
uid->prefs[n].value = *sym++; uid->prefs[n].value = *sym++;
} }
for (; naead; naead--, n++)
{
uid->prefs[n].type = PREFTYPE_AEAD;
uid->prefs[n].value = *aead++;
}
for (; nhash; nhash--, n++) for (; nhash; nhash--, n++)
{ {
uid->prefs[n].type = PREFTYPE_HASH; uid->prefs[n].type = PREFTYPE_HASH;
@ -2510,6 +2518,12 @@ fixup_uidnode (KBNODE uidnode, KBNODE signode, u32 keycreated)
if (p && n && (p[0] & 0x01)) if (p && n && (p[0] & 0x01))
uid->flags.mdc = 1; uid->flags.mdc = 1;
/* See whether we have the AEAD feature. */
uid->flags.aead = 0;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES, &n);
if (p && n && (p[0] & 0x02))
uid->flags.aead = 1;
/* And the keyserver modify flag. */ /* And the keyserver modify flag. */
uid->flags.ks_modify = 1; uid->flags.ks_modify = 1;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KS_FLAGS, &n); p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KS_FLAGS, &n);
@ -3332,6 +3346,7 @@ merge_selfsigs (ctrl_t ctrl, kbnode_t keyblock)
PKT_public_key *main_pk; PKT_public_key *main_pk;
prefitem_t *prefs; prefitem_t *prefs;
unsigned int mdc_feature; unsigned int mdc_feature;
unsigned int aead_feature;
if (keyblock->pkt->pkttype != PKT_PUBLIC_KEY) if (keyblock->pkt->pkttype != PKT_PUBLIC_KEY)
{ {
@ -3393,7 +3408,7 @@ merge_selfsigs (ctrl_t ctrl, kbnode_t keyblock)
* all preferences. * all preferences.
* Do a similar thing for the MDC feature flag. */ * Do a similar thing for the MDC feature flag. */
prefs = NULL; prefs = NULL;
mdc_feature = 0; mdc_feature = aead_feature = 0;
for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) for (k = keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next)
{ {
if (k->pkt->pkttype == PKT_USER_ID if (k->pkt->pkttype == PKT_USER_ID
@ -3402,6 +3417,7 @@ merge_selfsigs (ctrl_t ctrl, kbnode_t keyblock)
{ {
prefs = k->pkt->pkt.user_id->prefs; prefs = k->pkt->pkt.user_id->prefs;
mdc_feature = k->pkt->pkt.user_id->flags.mdc; mdc_feature = k->pkt->pkt.user_id->flags.mdc;
aead_feature = k->pkt->pkt.user_id->flags.aead;
break; break;
} }
} }
@ -3415,6 +3431,7 @@ merge_selfsigs (ctrl_t ctrl, kbnode_t keyblock)
xfree (pk->prefs); xfree (pk->prefs);
pk->prefs = copy_prefs (prefs); pk->prefs = copy_prefs (prefs);
pk->flags.mdc = mdc_feature; pk->flags.mdc = mdc_feature;
pk->flags.aead = aead_feature;
} }
} }
} }

View File

@ -3069,6 +3069,23 @@ show_prefs (PKT_user_id * uid, PKT_signature * selfsig, int verbose)
tty_printf ("%s", openpgp_cipher_algo_name (CIPHER_ALGO_3DES)); tty_printf ("%s", openpgp_cipher_algo_name (CIPHER_ALGO_3DES));
} }
tty_printf ("\n "); tty_printf ("\n ");
tty_printf (_("AEAD: "));
for (i = any = 0; prefs[i].type; i++)
{
if (prefs[i].type == PREFTYPE_AEAD)
{
if (any)
tty_printf (", ");
any = 1;
/* We don't want to display strings for experimental algos */
if (!openpgp_aead_test_algo (prefs[i].value)
&& prefs[i].value < 100)
tty_printf ("%s", openpgp_aead_algo_name (prefs[i].value));
else
tty_printf ("[%d]", prefs[i].value);
}
}
tty_printf ("\n ");
tty_printf (_("Digest: ")); tty_printf (_("Digest: "));
for (i = any = 0; prefs[i].type; i++) for (i = any = 0; prefs[i].type; i++)
{ {
@ -3123,7 +3140,7 @@ show_prefs (PKT_user_id * uid, PKT_signature * selfsig, int verbose)
} }
tty_printf ("%s", compress_algo_to_string (COMPRESS_ALGO_NONE)); tty_printf ("%s", compress_algo_to_string (COMPRESS_ALGO_NONE));
} }
if (uid->flags.mdc || !uid->flags.ks_modify) if (uid->flags.mdc || uid->flags.aead || !uid->flags.ks_modify)
{ {
tty_printf ("\n "); tty_printf ("\n ");
tty_printf (_("Features: ")); tty_printf (_("Features: "));
@ -3133,6 +3150,12 @@ show_prefs (PKT_user_id * uid, PKT_signature * selfsig, int verbose)
tty_printf ("MDC"); tty_printf ("MDC");
any = 1; any = 1;
} }
if (!uid->flags.aead)
{
if (any)
tty_printf (", ");
tty_printf ("AEAD");
}
if (!uid->flags.ks_modify) if (!uid->flags.ks_modify)
{ {
if (any) if (any)
@ -3171,12 +3194,15 @@ show_prefs (PKT_user_id * uid, PKT_signature * selfsig, int verbose)
for (i = 0; prefs[i].type; i++) for (i = 0; prefs[i].type; i++)
{ {
tty_printf (" %c%d", prefs[i].type == PREFTYPE_SYM ? 'S' : tty_printf (" %c%d", prefs[i].type == PREFTYPE_SYM ? 'S' :
prefs[i].type == PREFTYPE_AEAD ? 'A' :
prefs[i].type == PREFTYPE_HASH ? 'H' : prefs[i].type == PREFTYPE_HASH ? 'H' :
prefs[i].type == PREFTYPE_ZIP ? 'Z' : '?', prefs[i].type == PREFTYPE_ZIP ? 'Z' : '?',
prefs[i].value); prefs[i].value);
} }
if (uid->flags.mdc) if (uid->flags.mdc)
tty_printf (" [mdc]"); tty_printf (" [mdc]");
if (uid->flags.aead)
tty_printf (" [aead]");
if (!uid->flags.ks_modify) if (!uid->flags.ks_modify)
tty_printf (" [no-ks-modify]"); tty_printf (" [no-ks-modify]");
tty_printf ("\n"); tty_printf ("\n");

View File

@ -77,7 +77,8 @@ typedef enum {
PREFTYPE_NONE = 0, PREFTYPE_NONE = 0,
PREFTYPE_SYM = 1, PREFTYPE_SYM = 1,
PREFTYPE_HASH = 2, PREFTYPE_HASH = 2,
PREFTYPE_ZIP = 3 PREFTYPE_ZIP = 3,
PREFTYPE_AEAD = 4
} preftype_t; } preftype_t;
typedef struct { typedef struct {