Key import segfault in libgcrypt

NIIBE Yutaka gniibe at fsij.org
Wed Apr 9 08:54:42 CEST 2014


On 2014-04-07 at 00:26 -0400, Daniel Kahn Gillmor wrote:
> On 04/02/2014 04:41 AM, Hanno Böck wrote:
> 
> > On my system if I try to import this key
> > http://pgp.mit.edu/pks/lookup?op=get&search=0x98EEB6F7D87171CF
> > with gnupg it segfaults.
> > 
> > Backtrace (see below) indicates that the crash happens somewhere in
> > libgcrypt, so I'm posting it here.
> > 
> > My libgcrypt version is 1.6.1, gnupg is 2.0.22.
> 
> I can reproduce with packages from debian, gnupg2 v2.0.22-3 and
> libgcrypt11 v1.5.3.

I think that the problem is the algorithm ID 3.  pgpdump says:

    Old: Public Key Packet(tag 6)(269 bytes)
            Ver 4 - new
            Public key creation time - Tue Jan  7 18:10:15 JST 2014
            Pub alg - RSA Sign-Only(pub 3)
                      ^^^^^^^^^^^^^^^^^^^^

I don't know where to be fixed, GnuPG or libgcrypt.  If it's GnuPG,
it's something like:

diff --git a/g10/misc.c b/g10/misc.c
index 9b7c8ab..975ff4e 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1359,6 +1359,8 @@ pubkey_get_npkey( int algo )
 
   if (algo == GCRY_PK_ELG_E)
     algo = GCRY_PK_ELG;
+  else if (algo == PUBKEY_ALGO_RSA_E || algo == PUBKEY_ALGO_RSA_S)
+    algo = PUBKEY_ALGO_RSA;
   if (gcry_pk_algo_info (map_pk_openpgp_to_gcry (algo),
                          GCRYCTL_GET_ALGO_NPKEY, NULL, &n))
     n = 0;
@@ -1379,6 +1381,8 @@ pubkey_get_nskey( int algo )
 
   if (algo == GCRY_PK_ELG_E)
     algo = GCRY_PK_ELG;
+  else if (algo == PUBKEY_ALGO_RSA_E || algo == PUBKEY_ALGO_RSA_S)
+    algo = PUBKEY_ALGO_RSA;
   if (gcry_pk_algo_info (map_pk_openpgp_to_gcry (algo),
                          GCRYCTL_GET_ALGO_NSKEY, NULL, &n ))
     n = 0;
@@ -1399,6 +1403,8 @@ pubkey_get_nsig( int algo )
 
   if (algo == GCRY_PK_ELG_E)
     algo = GCRY_PK_ELG;
+  else if (algo == PUBKEY_ALGO_RSA_E || algo == PUBKEY_ALGO_RSA_S)
+    algo = PUBKEY_ALGO_RSA;
   if (gcry_pk_algo_info (map_pk_openpgp_to_gcry (algo),
                          GCRYCTL_GET_ALGO_NSIGN, NULL, &n))
     n = 0;
-- 





More information about the Gcrypt-devel mailing list