aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2025-11-03 15:30:00 +0000
committerWerner Koch <[email protected]>2025-11-03 15:30:00 +0000
commit8b44256a55496d598f5b903377ccc0100bc87812 (patch)
tree10a3d33655131dafc38658a47480141814efc42a
parentgpg: Do not use a default when asking for another output filename. (diff)
downloadgnupg-8b44256a55496d598f5b903377ccc0100bc87812.tar.gz
gnupg-8b44256a55496d598f5b903377ccc0100bc87812.zip
gpg: Print new "pfc" record in --with-colons key listings.
* g10/keylist.c (show_preferences): Add new mode 2 to print pfc records. (list_keyblock_colon): Call it with mode 2. -- GnuPG-bug-id: 7897
-rw-r--r--doc/DETAILS14
-rw-r--r--g10/keylist.c44
2 files changed, 56 insertions, 2 deletions
diff --git a/doc/DETAILS b/doc/DETAILS
index 246c4227d..a39d400d0 100644
--- a/doc/DETAILS
+++ b/doc/DETAILS
@@ -57,6 +57,7 @@ described here.
- ssb :: Secret subkey (secondary key)
- uid :: User id
- uat :: User attribute (same as user id except for field 10).
+ - pfc :: preference record [*]
- sig :: Signature
- rev :: Revocation signature
- rvs :: Revocation signature (standalone) [since 2.2.9]
@@ -305,6 +306,19 @@ described here.
** Special fields
+*** PFC - Preferences on User ID
+
+ - Field 1 :: "pfc"
+ - Field 2 :: RFU
+ - Field 3 :: Symmetric algo preferences (decimal, comma delimited)
+ - Field 4 :: Digest algo preferences (decimal, comma delimited)
+ - Field 5 :: Compress algo preferences (decimal, comma delimited)
+ - Field 6 :: AEAD algo preferences (decimal, comma delimited)
+ - Field 7 :: RFU
+ - Field 8 :: RFU
+ - Field 9 :: Comma delimited flags. For example:
+ "mdc", "aead", "no-ks-modify
+
*** PKD - Public key data
If field 1 has the tag "pkd", a listing looks like this:
diff --git a/g10/keylist.c b/g10/keylist.c
index 42e9f65f5..e45471e87 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -367,11 +367,12 @@ print_card_key_info (estream_t fp, kbnode_t keyblock)
* -1 - print to the TTY
* 0 - print to stdout.
* 1 - use log_info
+ * 2 - print colon delimited pfc record to stdout.
*/
void
show_preferences (PKT_user_id *uid, int indent, int mode, int verbose)
{
- estream_t fp = mode < 0? NULL : mode ? log_get_stream () : es_stdout;
+ estream_t fp;
const prefitem_t fake = { 0, 0 };
const prefitem_t *prefs;
int i;
@@ -386,7 +387,44 @@ show_preferences (PKT_user_id *uid, int indent, int mode, int verbose)
else
return;
- if (verbose)
+ if (mode < 0 )
+ fp = NULL;
+ else if (mode == 1)
+ fp = log_get_stream ();
+ else /* Mode 0 or 2 */
+ fp = es_stdout;
+
+ if (mode == 2) /* Print preference record. */
+ {
+ static char ptypes[] = { PREFTYPE_SYM, PREFTYPE_HASH,
+ PREFTYPE_ZIP, PREFTYPE_AEAD };
+ int t, any;
+
+ es_fputs ("pfc::", fp); /* Second field is RFU */
+ for (t=0; t < DIM (ptypes); t++)
+ {
+ any = 0;
+ for (i = 0; prefs[i].type; i++)
+ if (prefs[i].type == ptypes[t])
+ {
+ es_fprintf (fp, "%s%d", any? ",":"", prefs[i].value);
+ any = 1;
+ }
+ es_putc (':', fp);
+ }
+ es_putc (':', fp); /* Two more reserved fields. */
+ es_putc (':', fp);
+ any = 0;
+ if (uid->flags.mdc)
+ { es_fprintf (fp, "mdc"); any = 1; }
+ if (uid->flags.aead)
+ { es_fprintf (fp, "%saead", any?",":""); any = 1; };
+ if (!uid->flags.ks_modify)
+ { es_fprintf (fp, "%sno-ks-modify", any?",":""); }
+ es_putc (':', fp); /* One final colon for easier reading. */
+ es_putc ('\n', fp);
+ }
+ else if (verbose)
{
int any, des_seen = 0, sha1_seen = 0, uncomp_seen = 0;
@@ -2197,6 +2235,8 @@ list_keyblock_colon (ctrl_t ctrl, kbnode_t keyblock,
":", NULL);
es_putc (':', es_stdout); /* End of field 20 (origin). */
es_putc ('\n', es_stdout);
+ if ((opt.list_options & (LIST_SHOW_PREF|LIST_SHOW_PREF_VERBOSE)))
+ show_preferences (uid, 0, 2, 0);
#ifdef USE_TOFU
if (!uid->attrib_data && opt.with_tofu_info
&& (opt.trust_model == TM_TOFU || opt.trust_model == TM_TOFU_PGP))