diff options
author | Werner Koch <wk@gnupg.org> | 2006-05-24 13:12:28 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2006-05-24 13:12:28 +0200 |
commit | b61df862a7c9a8d85412b89965f5f814ab939180 (patch) | |
tree | 00a7b079e758030f618490700e3ae7b84b171776 /g10 | |
parent | g10/ does build again. (diff) | |
download | gnupg2-b61df862a7c9a8d85412b89965f5f814ab939180.tar.xz gnupg2-b61df862a7c9a8d85412b89965f5f814ab939180.zip |
Still making gpg2 work.
At least the keyids are now correctly computed again.
Diffstat (limited to 'g10')
-rw-r--r-- | g10/ChangeLog | 11 | ||||
-rw-r--r-- | g10/gpg.c | 12 | ||||
-rw-r--r-- | g10/gpgv.c | 1 | ||||
-rw-r--r-- | g10/keygen.c | 4 | ||||
-rw-r--r-- | g10/keyid.c | 6 | ||||
-rw-r--r-- | g10/main.h | 3 | ||||
-rw-r--r-- | g10/misc.c | 54 |
7 files changed, 73 insertions, 18 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 6018bbe13..47e9a7328 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,14 @@ +2006-05-24 Werner Koch <wk@g10code.com> + + * keyid.c (hash_public_key): Do not double hash the length bytes, + they are already included by mpi_print. + + * misc.c (openpgp_pk_test_algo2): Get test call right. + + * misc.c (string_to_cipher_algo, string_to_digest_algo): New. + * keygen.c (keygen_set_std_prefs): use them here. + * gpg.c (main): and here. + 2006-05-23 Werner Koch <wk@g10code.com> * card-util.c (generate_card_keys): Removed temporary kludge for @@ -2515,7 +2515,7 @@ main (int argc, char **argv ) case oNoUtf8Strings: utf8_strings = 0; break; case oDisableCipherAlgo: { - int algo = gcry_cipher_map_name (pargs.r.ret_str); + int algo = string_to_cipher_algo (pargs.r.ret_str); gcry_cipher_ctl (NULL, GCRYCTL_DISABLE_ALGO, &algo, sizeof algo); } break; @@ -2859,7 +2859,7 @@ main (int argc, char **argv ) if( def_cipher_string ) { - opt.def_cipher_algo = gcry_cipher_map_name (def_cipher_string); + opt.def_cipher_algo = string_to_cipher_algo (def_cipher_string); if(opt.def_cipher_algo==0 && (ascii_strcasecmp(def_cipher_string,"idea")==0 || ascii_strcasecmp(def_cipher_string,"s1")==0)) @@ -2869,7 +2869,7 @@ main (int argc, char **argv ) log_error(_("selected cipher algorithm is invalid\n")); } if( def_digest_string ) { - opt.def_digest_algo = gcry_md_map_name (def_digest_string); + opt.def_digest_algo = string_to_digest_algo (def_digest_string); xfree(def_digest_string); def_digest_string = NULL; if ( openpgp_md_test_algo (opt.def_digest_algo) ) log_error(_("selected digest algorithm is invalid\n")); @@ -2881,19 +2881,19 @@ main (int argc, char **argv ) log_error(_("selected compression algorithm is invalid\n")); } if( cert_digest_string ) { - opt.cert_digest_algo = gcry_md_map_name (cert_digest_string); + opt.cert_digest_algo = string_to_digest_algo (cert_digest_string); xfree(cert_digest_string); cert_digest_string = NULL; if (openpgp_md_test_algo(opt.cert_digest_algo)) log_error(_("selected certification digest algorithm is invalid\n")); } if( s2k_cipher_string ) { - opt.s2k_cipher_algo = gcry_cipher_map_name (s2k_cipher_string); + opt.s2k_cipher_algo = string_to_cipher_algo (s2k_cipher_string); xfree(s2k_cipher_string); s2k_cipher_string = NULL; if (openpgp_cipher_test_algo (opt.s2k_cipher_algo)) log_error(_("selected cipher algorithm is invalid\n")); } if( s2k_digest_string ) { - opt.s2k_digest_algo = gcry_md_map_name (s2k_digest_string); + opt.s2k_digest_algo = string_to_digest_algo (s2k_digest_string); xfree(s2k_digest_string); s2k_digest_string = NULL; if (openpgp_md_test_algo(opt.s2k_digest_algo)) log_error(_("selected digest algorithm is invalid\n")); diff --git a/g10/gpgv.c b/g10/gpgv.c index 579e58a29..f33c5fc63 100644 --- a/g10/gpgv.c +++ b/g10/gpgv.c @@ -371,7 +371,6 @@ int agent_scd_getattr (const char *name, struct agent_card_info_s *info) {return #endif /* ENABLE_CARD_SUPPORT */ /* Stubs to void linking to ../cipher/cipher.c */ -int string_to_cipher_algo( const char *string ) { return 0; } const char *cipher_algo_to_string( int algo ) { return "?";} void disable_cipher_algo( int algo ) {} int check_cipher_algo( int algo ) { return -1;} diff --git a/g10/keygen.c b/g10/keygen.c index 9c2fd6fb8..f791c6cd0 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -370,12 +370,12 @@ keygen_set_std_prefs (const char *string,int personal) while((tok=strsep(&prefstring," ,"))) { - if((val=gcry_cipher_map_name (tok))) + if((val=string_to_cipher_algo (tok))) { if(set_one_pref(val,1,tok,sym,&nsym)) rc=-1; } - else if((val=gcry_md_map_name (tok))) + else if((val=string_to_digest_algo (tok))) { if(set_one_pref(val,2,tok,hash,&nhash)) rc=-1; diff --git a/g10/keyid.c b/g10/keyid.c index 5eb51c1f4..0012a5604 100644 --- a/g10/keyid.c +++ b/g10/keyid.c @@ -56,7 +56,6 @@ void hash_public_key( gcry_md_hd_t md, PKT_public_key *pk ) { unsigned int n = 6; - unsigned int nb[PUBKEY_MAX_NPKEY]; unsigned int nn[PUBKEY_MAX_NPKEY]; byte *pp[PUBKEY_MAX_NPKEY]; int i; @@ -77,7 +76,6 @@ hash_public_key( gcry_md_hd_t md, PKT_public_key *pk ) else for(i=0; i < npkey; i++ ) { - nb[i] = gcry_mpi_get_nbits (pk->pkey[i]); if (gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, 0, &nbytes, pk->pkey[i])) BUG (); pp[i] = xmalloc (nbytes); @@ -85,7 +83,7 @@ hash_public_key( gcry_md_hd_t md, PKT_public_key *pk ) &nbytes, pk->pkey[i])) BUG (); nn[i] = nbytes; - n += 2 + nn[i]; + n += nn[i]; } gcry_md_putc ( md, 0x99 ); /* ctb */ @@ -119,8 +117,6 @@ hash_public_key( gcry_md_hd_t md, PKT_public_key *pk ) else for(i=0; i < npkey; i++ ) { - gcry_md_putc ( md, nb[i]>>8); - gcry_md_putc ( md, nb[i] ); gcry_md_write ( md, pp[i], nn[i] ); xfree(pp[i]); } diff --git a/g10/main.h b/g10/main.h index 18d11b567..c6c0b29b1 100644 --- a/g10/main.h +++ b/g10/main.h @@ -106,6 +106,9 @@ void deprecated_warning(const char *configname,unsigned int configlineno, const char *option,const char *repl1,const char *repl2); void deprecated_command (const char *name); +int string_to_cipher_algo (const char *string); +int string_to_digest_algo (const char *string); + const char *compress_algo_to_string(int algo); int string_to_compress_algo(const char *string); int check_compress_algo(int algo); diff --git a/g10/misc.c b/g10/misc.c index 12aa6c689..de0a029a4 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -429,7 +429,6 @@ int openpgp_pk_test_algo2( int algo, unsigned int use ) { int use_buf = use; - size_t sizeof_use_buf = sizeof (use_buf); if (algo == GCRY_PK_ELG_E) algo = GCRY_PK_ELG; @@ -437,8 +436,7 @@ openpgp_pk_test_algo2( int algo, unsigned int use ) if (algo < 0 || algo > 110) return gpg_error (GPG_ERR_PUBKEY_ALGO); - return gcry_pk_algo_info (algo, GCRYCTL_TEST_ALGO, - &use_buf, &sizeof_use_buf); + return gcry_pk_algo_info (algo, GCRYCTL_TEST_ALGO, NULL, &use_buf); } int @@ -739,6 +737,54 @@ deprecated_command (const char *name) } +/* + * Wrapper around gcry_cipher_map_name to provide a fallback using the + * "Sn" syntax as used by the preference strings. + */ +int +string_to_cipher_algo (const char *string) +{ + int val; + + val = gcry_cipher_map_name (string); + if (!val && string && (string[0]=='S' || string[0]=='s')) + { + char *endptr; + + string++; + val = strtol (string, &endptr, 10); + if (!*string || *endptr || openpgp_cipher_test_algo (val)) + val = 0; + } + + return val; +} + +/* + * Wrapper around gcry_md_map_name to provide a fallback using the + * "Hn" syntax as used by the preference strings. + */ +int +string_to_digest_algo (const char *string) +{ + int val; + + val = gcry_md_map_name (string); + if (!val && string && (string[0]=='H' || string[0]=='h')) + { + char *endptr; + + string++; + val = strtol (string, &endptr, 10); + if (!*string || *endptr || openpgp_md_test_algo (val)) + val = 0; + } + + return val; +} + + + const char * compress_algo_to_string(int algo) { @@ -771,7 +817,7 @@ compress_algo_to_string(int algo) int string_to_compress_algo(const char *string) { - /* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */ + /* TRANSLATORS: See doc/TRANSLATE about this string. */ if(match_multistr(_("uncompressed|none"),string)) return 0; else if(ascii_strcasecmp(string,"uncompressed")==0) |