[PATCH libksba] Add flags to Ed25519 and X25519 public keys.

David Seifert soap at gentoo.org
Tue Nov 17 00:21:18 CET 2026


* src/keyinfo.c (_ksba_keyinfo_to_sexp): Add (flags eddsa) for
Ed25519 and (flags djb-tweak) for X25519 keys.

--

Without flags, Libgcrypt takes a point starting with 0x02 or 0x03 for
a compressed one when computing the keygrip and tries to uncompress
it, which fails for these curves. Thus the keygrip of about 1 in 128
Ed25519 and X25519 certificate keys could not be computed, and gpgsm
said "can't calculate keygrip" for such a certificate. With the
flags, Libgcrypt uses the point as given. The keygrips of other keys
do not change because the flags are not part of the keygrip.

Tested with certificates whose key starts with 0x02: gpgsm imports
the Ed25519 one, which includes checking its self-signature, and
lists its keygrip. For both keys the keygrip now matches the one of
the 0x40 prefixed form used by gpg-agent. The keygrips of keys
starting with other bytes are unchanged.

Signed-off-by: David Seifert <soap at gentoo.org>
---
 src/keyinfo.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/keyinfo.c b/src/keyinfo.c
index e54f9d8..6b8a51c 100644
--- a/src/keyinfo.c
+++ b/src/keyinfo.c
@@ -1094,6 +1094,13 @@ _ksba_keyinfo_to_sexp (const unsigned char *der, size_t derlen,
           put_stringbuf_sexp (&sb, "curve");
           put_stringbuf_sexp (&sb, pk_algo_table[algoidx].oidstring);
           put_stringbuf (&sb, ")");
+          /* Without these flags Libgcrypt takes a point starting with
+           * 0x02 or 0x03 for a compressed one and fails to compute the
+           * keygrip.  */
+          if (pk_algo_table[algoidx].pkalgo == PKALGO_ED25519)
+            put_stringbuf (&sb, "(5:flags5:eddsa)");
+          else if (pk_algo_table[algoidx].pkalgo == PKALGO_X25519)
+            put_stringbuf (&sb, "(5:flags9:djb-tweak)");
         }
     }
 
-- 
2.56.1



More information about the Gnupg-devel mailing list