diff options
author | Werner Koch <wk@gnupg.org> | 2007-02-22 18:25:27 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2007-02-22 18:25:27 +0000 |
commit | 1cfac9fd5f628c2d505b6c01d2cc0657840299ed (patch) | |
tree | c6ceb5f8ac489a844041fb21d6d0cf296d78d694 /cipher | |
parent | 6cb0bbb9494b908be000d331d0e7068bb6ae9ee7 (diff) | |
download | libgcrypt-1cfac9fd5f628c2d505b6c01d2cc0657840299ed.tar.gz |
Fixed bug#596 adn minor cleanups
Diffstat (limited to 'cipher')
-rw-r--r-- | cipher/ChangeLog | 3 | ||||
-rw-r--r-- | cipher/md.c | 2 | ||||
-rw-r--r-- | cipher/pubkey.c | 24 |
3 files changed, 26 insertions, 3 deletions
diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 645d9ebb..b8ff7c5a 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,5 +1,8 @@ 2007-02-22 Werner Koch <wk@g10code.com> + * pubkey.c (sexp_data_to_mpi): Handle dynamically allocated + algorithms. Suggested by Neil Dunbar. Fixes bug#596. + * rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void. * cipher.c (gcry_cipher_algo_name): Simplified. diff --git a/cipher/md.c b/cipher/md.c index 706d2744..28860135 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -303,7 +303,7 @@ gcry_md_map_name (const char *string) ret = search_oid (string, &algorithm, NULL); if (! ret) { - /* Not found, search for an acording diget name. */ + /* Not found, search a matching digest name. */ digest = gcry_md_lookup_name (string); if (digest) { diff --git a/cipher/pubkey.c b/cipher/pubkey.c index 228b0d04..a833c3dd 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -1325,12 +1325,32 @@ sexp_data_to_mpi (gcry_sexp_t input, unsigned int nbits, gcry_mpi_t *ret_mpi, && !memcmp (hashnames[i].name, s, n)) break; } + if (hashnames[i].name) + algo = hashnames[i].algo; + else + { + /* In case of not listed or dynamically allocated hash + algorithm we fall back to this somewhat slower + method. Further, it also allows to use OIDs as + algorithm names. */ + char *tmpname; + + tmpname = gcry_malloc (n+1); + if (!tmpname) + algo = 0; /* Out of core - silently give up. */ + else + { + memcpy (tmpname, s, n); + tmpname[n] = 0; + algo = gcry_md_map_name (tmpname); + gcry_free (tmpname); + } + } - algo = hashnames[i].algo; asnlen = DIM(asn); dlen = gcry_md_get_algo_dlen (algo); - if (!hashnames[i].name) + if (!algo) rc = GPG_ERR_DIGEST_ALGO; else if ( !(value=gcry_sexp_nth_data (lhash, 2, &valuelen)) || !valuelen ) |