aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2012-01-11 19:15:47 +0000
committerWerner Koch <[email protected]>2012-01-11 19:15:47 +0000
commit30ec869b8c63f1edcc58110ed20b83b0e77248f8 (patch)
tree8aec2a09d13ee5702a8d0470a4420e68b4bf40a3 /g10/misc.c
parentestream: Avoid printing leading zeroes by %p on 32 bit systems. (diff)
downloadgnupg-30ec869b8c63f1edcc58110ed20b83b0e77248f8.tar.gz
gnupg-30ec869b8c63f1edcc58110ed20b83b0e77248f8.zip
gpg: Fix segv with RSA_S keys.
* g10/misc.c (pubkey_get_npkey, pubkey_get_nskey) (pubkey_get_nsig, pubkey_get_nenc): Map all RSA algo ids to GCRY_PK_RSA. -- The problem is that Libgcrypt has no more support for the alternate RSA ids and thus if asking for the number of parameters, they will return zero. Now, this leads to packing the key parameters into an opaque MPI but because the algorithm id is actually known to GPG, it assumes valid RSA parameters. An example key with RSA_S is 0x5434509D.
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/g10/misc.c b/g10/misc.c
index e0c57a145..c49945a6f 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1377,6 +1377,8 @@ pubkey_get_npkey (int algo)
/* All other algorithms match those of Libgcrypt. */
if (algo == GCRY_PK_ELG_E)
algo = GCRY_PK_ELG;
+ else if (is_RSA (algo))
+ algo = GCRY_PK_RSA;
if (gcry_pk_algo_info (algo, GCRYCTL_GET_ALGO_NPKEY, NULL, &n))
n = 0;
@@ -1399,6 +1401,8 @@ pubkey_get_nskey (int algo)
/* All other algorithms match those of Libgcrypt. */
if (algo == GCRY_PK_ELG_E)
algo = GCRY_PK_ELG;
+ else if (is_RSA (algo))
+ algo = GCRY_PK_RSA;
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSKEY, NULL, &n ))
n = 0;
@@ -1419,6 +1423,8 @@ pubkey_get_nsig (int algo)
if (algo == GCRY_PK_ELG_E)
algo = GCRY_PK_ELG;
+ else if (is_RSA (algo))
+ algo = GCRY_PK_RSA;
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NSIGN, NULL, &n))
n = 0;
@@ -1440,6 +1446,8 @@ pubkey_get_nenc (int algo)
if (algo == GCRY_PK_ELG_E)
algo = GCRY_PK_ELG;
+ else if (is_RSA (algo))
+ algo = GCRY_PK_RSA;
if (gcry_pk_algo_info( algo, GCRYCTL_GET_ALGO_NENCR, NULL, &n ))
n = 0;