[svn] GnuPG - r4146 - in branches/GNUPG-1-9-BRANCH: . g10

svn author wk cvs at cvs.gnupg.org
Wed May 24 13:12:29 CEST 2006


Author: wk
Date: 2006-05-24 13:12:28 +0200 (Wed, 24 May 2006)
New Revision: 4146

Modified:
   branches/GNUPG-1-9-BRANCH/ChangeLog
   branches/GNUPG-1-9-BRANCH/configure.ac
   branches/GNUPG-1-9-BRANCH/g10/ChangeLog
   branches/GNUPG-1-9-BRANCH/g10/gpg.c
   branches/GNUPG-1-9-BRANCH/g10/gpgv.c
   branches/GNUPG-1-9-BRANCH/g10/keygen.c
   branches/GNUPG-1-9-BRANCH/g10/keyid.c
   branches/GNUPG-1-9-BRANCH/g10/main.h
   branches/GNUPG-1-9-BRANCH/g10/misc.c
Log:
Still making gpg2 work.
At least the keyids are now correctly computed again.


Modified: branches/GNUPG-1-9-BRANCH/ChangeLog
===================================================================
--- branches/GNUPG-1-9-BRANCH/ChangeLog	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/ChangeLog	2006-05-24 11:12:28 UTC (rev 4146)
@@ -1,3 +1,7 @@
+2006-05-24  Werner Koch  <wk at g10code.com>
+
+	* configure.ac: New option --disable-optimization taked from 1.4.3.
+
 2006-05-23  Werner Koch  <wk at g10code.com>
 
 	* configure.ac (ZLIBS): New for zlib link commands. Add bzip2

Modified: branches/GNUPG-1-9-BRANCH/configure.ac
===================================================================
--- branches/GNUPG-1-9-BRANCH/configure.ac	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/configure.ac	2006-05-24 11:12:28 UTC (rev 4146)
@@ -1080,6 +1080,20 @@
     fi
 fi
 
+#
+# This is handy for debugging so the compiler doesn't rearrange
+# things and eliminate variables.
+#
+AC_ARG_ENABLE(optimization,
+   AC_HELP_STRING([--disable-optimization],
+                  [disable compiler optimization]),
+                  [if test $enableval = no ; then
+                      CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
+                   fi])
+
+
+
+
 AC_SUBST(NETLIBS)
 AC_SUBST(W32LIBS)
 

Modified: branches/GNUPG-1-9-BRANCH/g10/ChangeLog
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/ChangeLog	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/ChangeLog	2006-05-24 11:12:28 UTC (rev 4146)
@@ -1,3 +1,14 @@
+2006-05-24  Werner Koch  <wk at 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 at g10code.com>
 
 	* card-util.c (generate_card_keys): Removed temporary kludge for

Modified: branches/GNUPG-1-9-BRANCH/g10/gpg.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/gpg.c	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/gpg.c	2006-05-24 11:12:28 UTC (rev 4146)
@@ -2515,7 +2515,7 @@
 	  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 @@
 
 
     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 @@
 	    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 @@
           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"));

Modified: branches/GNUPG-1-9-BRANCH/g10/gpgv.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/gpgv.c	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/gpgv.c	2006-05-24 11:12:28 UTC (rev 4146)
@@ -371,7 +371,6 @@
 #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;}

Modified: branches/GNUPG-1-9-BRANCH/g10/keygen.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/keygen.c	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/keygen.c	2006-05-24 11:12:28 UTC (rev 4146)
@@ -370,12 +370,12 @@
 
 	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;

Modified: branches/GNUPG-1-9-BRANCH/g10/keyid.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/keyid.c	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/keyid.c	2006-05-24 11:12:28 UTC (rev 4146)
@@ -56,7 +56,6 @@
 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 @@
   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 @@
                             &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 @@
   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]);
       }

Modified: branches/GNUPG-1-9-BRANCH/g10/main.h
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/main.h	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/main.h	2006-05-24 11:12:28 UTC (rev 4146)
@@ -106,6 +106,9 @@
 			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);

Modified: branches/GNUPG-1-9-BRANCH/g10/misc.c
===================================================================
--- branches/GNUPG-1-9-BRANCH/g10/misc.c	2006-05-23 22:48:21 UTC (rev 4145)
+++ branches/GNUPG-1-9-BRANCH/g10/misc.c	2006-05-24 11:12:28 UTC (rev 4146)
@@ -429,7 +429,6 @@
 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 @@
   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 @@
 }
 
 
+/*
+ * 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 @@
 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)




More information about the Gnupg-commits mailing list