[git] GnuPG - branch, master, updated. gnupg-2.1.0beta3-296-g71540d4

by Werner Koch cvs at cvs.gnupg.org
Fri Jan 31 15:56:45 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  71540d40414dc8b304b45dc476e5e5650a2db20a (commit)
       via  bf50604a0d50b974c1d4b8ccf5d774489f996cae (commit)
       via  16a6311adefff0139056714521214f845315b7f8 (commit)
      from  b7f8dec6325f1c80640f878ed3080bbc194fbc78 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 71540d40414dc8b304b45dc476e5e5650a2db20a
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 31 15:55:04 2014 +0100

    gpg: Improve --version algo info output.
    
    * g10/misc.c (openpgp_pk_algo_name): Return a different string for
    each ECC algorithm.
    * g10/gpg.c (build_list_pk_test_algo): New wrapper to cope with the
    different algo type enums.
    (build_list_pk_algo_name): Ditto.
    (build_list_cipher_test_algo): Ditto.
    (build_list_cipher_algo_name): Ditto.
    (build_list_md_test_algo): Ditto.
    (build_list_md_algo_name): Ditto.
    (my_strusage): Use them.
    (list_config): Ditto. Add "pubkeyname".
    (build_list): Add letter==1 hack.

diff --git a/g10/gpg.c b/g10/gpg.c
index a770d74..5b33105 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -811,6 +811,43 @@ make_libversion (const char *libname, const char *(*getfnc)(const char*))
 }
 
 
+static int
+build_list_pk_test_algo (int algo)
+{
+  return openpgp_pk_test_algo (algo);
+}
+
+static const char *
+build_list_pk_algo_name (int algo)
+{
+  return openpgp_pk_algo_name (algo);
+}
+
+static int
+build_list_cipher_test_algo (int algo)
+{
+  return openpgp_cipher_test_algo (algo);
+}
+
+static const char *
+build_list_cipher_algo_name (int algo)
+{
+  return openpgp_cipher_algo_name (algo);
+}
+
+static int
+build_list_md_test_algo (int algo)
+{
+  return openpgp_md_test_algo (algo);
+}
+
+static const char *
+build_list_md_algo_name (int algo)
+{
+  return openpgp_md_algo_name (algo);
+}
+
+
 static const char *
 my_strusage( int level )
 {
@@ -861,23 +898,23 @@ my_strusage( int level )
       case 33: p = _("\nSupported algorithms:\n"); break;
       case 34:
 	if (!pubkeys)
-            pubkeys = build_list (_("Pubkey: "), 0,
-                                  openpgp_pk_algo_name,
-                                  openpgp_pk_test_algo );
+            pubkeys = build_list (_("Pubkey: "), 1,
+                                  build_list_pk_algo_name,
+                                  build_list_pk_test_algo );
 	p = pubkeys;
 	break;
       case 35:
 	if( !ciphers )
 	    ciphers = build_list(_("Cipher: "), 'S',
-                                 openpgp_cipher_algo_name,
-                                 openpgp_cipher_test_algo );
+                                 build_list_cipher_algo_name,
+                                 build_list_cipher_test_algo );
 	p = ciphers;
 	break;
       case 36:
 	if( !digests )
 	    digests = build_list(_("Hash: "), 'H',
-                                 gcry_md_algo_name,
-                                 openpgp_md_test_algo );
+                                 build_list_md_algo_name,
+                                 build_list_md_test_algo );
 	p = digests;
 	break;
       case 37:
@@ -931,7 +968,10 @@ build_list (const char *text, char letter,
           if (opt.verbose && letter)
             {
               char num[20];
-              snprintf (num, sizeof num, " (%c%d)", letter, i);
+              if (letter == 1)
+                snprintf (num, sizeof num, " (%d)", i);
+              else
+                snprintf (num, sizeof num, " (%c%d)", letter, i);
               put_membuf_str (&mb, num);
             }
 	}
@@ -1533,7 +1573,16 @@ list_config(char *items)
       if(show_all || ascii_strcasecmp(name,"pubkey")==0)
 	{
 	  es_printf ("cfg:pubkey:");
-	  print_algo_numbers (openpgp_pk_test_algo);
+	  print_algo_numbers (build_list_pk_test_algo);
+	  es_printf ("\n");
+	  any=1;
+	}
+
+      if(show_all || ascii_strcasecmp(name,"pubkeyname")==0)
+	{
+	  es_printf ("cfg:pubkeyname:");
+	  print_algo_names (build_list_pk_test_algo,
+                            build_list_pk_algo_name);
 	  es_printf ("\n");
 	  any=1;
 	}
@@ -1541,7 +1590,7 @@ list_config(char *items)
       if(show_all || ascii_strcasecmp(name,"cipher")==0)
 	{
 	  es_printf ("cfg:cipher:");
-	  print_algo_numbers(openpgp_cipher_test_algo);
+	  print_algo_numbers (build_list_cipher_test_algo);
 	  es_printf ("\n");
 	  any=1;
 	}
@@ -1549,7 +1598,8 @@ list_config(char *items)
       if (show_all || !ascii_strcasecmp (name,"ciphername"))
 	{
 	  es_printf ("cfg:ciphername:");
-	  print_algo_names (openpgp_cipher_test_algo,openpgp_cipher_algo_name);
+	  print_algo_names (build_list_cipher_test_algo,
+                            build_list_cipher_algo_name);
 	  es_printf ("\n");
 	  any = 1;
 	}
@@ -1559,7 +1609,7 @@ list_config(char *items)
 	 || ascii_strcasecmp(name,"hash")==0)
 	{
 	  es_printf ("cfg:digest:");
-	  print_algo_numbers(openpgp_md_test_algo);
+	  print_algo_numbers (build_list_md_test_algo);
 	  es_printf ("\n");
 	  any=1;
 	}
@@ -1569,7 +1619,8 @@ list_config(char *items)
           || !ascii_strcasecmp(name,"hashname"))
 	{
 	  es_printf ("cfg:digestname:");
-	  print_algo_names (openpgp_md_test_algo, gcry_md_algo_name);
+	  print_algo_names (build_list_md_test_algo,
+                            build_list_md_algo_name);
 	  es_printf ("\n");
 	  any=1;
 	}
diff --git a/g10/misc.c b/g10/misc.c
index 06d0b8f..6d3a7b8 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -572,9 +572,9 @@ openpgp_pk_algo_name (pubkey_algo_t algo)
     case PUBKEY_ALGO_ELGAMAL:
     case PUBKEY_ALGO_ELGAMAL_E: return "ELG";
     case PUBKEY_ALGO_DSA:       return "DSA";
-    case PUBKEY_ALGO_ECDH:
-    case PUBKEY_ALGO_ECDSA:
-    case PUBKEY_ALGO_EDDSA:     return "ECC";
+    case PUBKEY_ALGO_ECDH:      return "ECDH";
+    case PUBKEY_ALGO_ECDSA:     return "ECDSA";
+    case PUBKEY_ALGO_EDDSA:     return "EDDSA";
     }
   return "?";
 }

commit bf50604a0d50b974c1d4b8ccf5d774489f996cae
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 31 15:33:03 2014 +0100

    gpg: Start using OpenPGP digest algo ids.
    
    * g10/misc.c (print_pubkey_algo_note): Use enum typedef for the arg.
    (print_cipher_algo_note): Ditto.
    (print_digest_algo_note): Ditto.
    (map_md_openpgp_to_gcry): New.
    (openpgp_md_test_algo): Rewrite.
    (openpgp_md_algo_name): Rewrite to do without Libgcrypt.
    * g10/cpr.c (write_status_begin_signing): Remove hardwired list of
    algo ranges.

diff --git a/g10/cpr.c b/g10/cpr.c
index 8d2262e..99c8eec 100644
--- a/g10/cpr.c
+++ b/g10/cpr.c
@@ -307,24 +307,19 @@ write_status_begin_signing (gcry_md_hd_t md)
     {
       char buf[100];
       size_t buflen;
-      int i;
-
-      /* We use a hard coded list of possible algorithms.  Using other
-         algorithms than specified by OpenPGP does not make sense
-         anyway.  We do this out of performance reasons: Walking all
-         the 110 allowed Ids is not a good idea given the way the
-         check is implemented in libgcrypt.  Recall that the only use
-         of this status code is to create the micalg algorithm for
-         PGP/MIME. */
+      int i, ga;
+
       buflen = 0;
-      for (i=1; i <= 11; i++)
-        if (i < 4 || i > 7)
-          if (gcry_md_is_enabled (md, i) && buflen < DIM(buf))
+      for (i=1; i <= 110; i++)
+        {
+          ga = map_md_openpgp_to_gcry (i);
+          if (ga && gcry_md_is_enabled (md, ga) && buflen+10 < DIM(buf))
             {
               snprintf (buf+buflen, DIM(buf) - buflen - 1,
                         "%sH%d", buflen? " ":"",i);
               buflen += strlen (buf+buflen);
             }
+        }
       write_status_text (STATUS_BEGIN_SIGNING, buf);
     }
   else
diff --git a/g10/main.h b/g10/main.h
index 1ee563e..28115ca 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -71,9 +71,9 @@ extern int g10_errors_seen;
 #else
   void g10_exit(int rc);
 #endif
-void print_pubkey_algo_note( int algo );
-void print_cipher_algo_note( int algo );
-void print_digest_algo_note( int algo );
+void print_pubkey_algo_note (pubkey_algo_t algo);
+void print_cipher_algo_note (cipher_algo_t algo);
+void print_digest_algo_note (digest_algo_t algo);
 
 /*-- armor.c --*/
 char *make_radix64_string( const byte *data, size_t len );
@@ -108,7 +108,8 @@ int openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use);
 int openpgp_pk_algo_usage ( int algo );
 const char *openpgp_pk_algo_name (pubkey_algo_t algo);
 
-int openpgp_md_test_algo( int algo );
+enum gcry_md_algos map_md_openpgp_to_gcry (digest_algo_t algo);
+int openpgp_md_test_algo (digest_algo_t algo);
 const char *openpgp_md_algo_name (int algo);
 
 struct expando_args
diff --git a/g10/misc.c b/g10/misc.c
index 1626b21..06d0b8f 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1,6 +1,7 @@
 /* misc.c - miscellaneous functions
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
  *               2008, 2009, 2010 Free Software Foundation, Inc.
+ * Copyright (C) 2014 Werner Koch
  *
  * This file is part of GnuPG.
  *
@@ -286,7 +287,7 @@ buffer_to_u32( const byte *buffer )
 }
 
 void
-print_pubkey_algo_note( int algo )
+print_pubkey_algo_note (pubkey_algo_t algo)
 {
   if(algo >= 100 && algo <= 110)
     {
@@ -305,7 +306,7 @@ print_pubkey_algo_note( int algo )
 }
 
 void
-print_cipher_algo_note( int algo )
+print_cipher_algo_note (cipher_algo_t algo)
 {
   if(algo >= 100 && algo <= 110)
     {
@@ -320,7 +321,7 @@ print_cipher_algo_note( int algo )
 }
 
 void
-print_digest_algo_note( int algo )
+print_digest_algo_note (digest_algo_t algo)
 {
   if(algo >= 100 && algo <= 110)
     {
@@ -579,17 +580,43 @@ openpgp_pk_algo_name (pubkey_algo_t algo)
 }
 
 
+/* Explicit mapping of OpenPGP digest algos to Libgcrypt.  */
+/* FIXME: We do not yes use it everywhere.  */
+enum gcry_md_algos
+map_md_openpgp_to_gcry (digest_algo_t algo)
+{
+  switch (algo)
+    {
+    case DIGEST_ALGO_MD5:    return GCRY_MD_MD5;
+    case DIGEST_ALGO_SHA1:   return GCRY_MD_SHA1;
+    case DIGEST_ALGO_RMD160: return GCRY_MD_RMD160;
+    case DIGEST_ALGO_SHA224: return GCRY_MD_SHA224;
+    case DIGEST_ALGO_SHA256: return GCRY_MD_SHA256;
+    case DIGEST_ALGO_SHA384: return GCRY_MD_SHA384;
+    case DIGEST_ALGO_SHA512: return GCRY_MD_SHA512;
+    }
+  return 0;
+}
+
+
+/* Return 0 if ALGO is suitable and implemented OpenPGP hash
+   algorithm.  Note: To only test for a valid OpenPGP hash algorithm,
+   it is better to use map_md_openpgp_to_gcry. */
 int
-openpgp_md_test_algo( int algo )
+openpgp_md_test_algo (digest_algo_t algo)
 {
-  /* Note: If the list of actual supported OpenPGP algorithms changes,
-     make sure that our hard coded values at
-     print_status_begin_signing() gets updated. */
-  /* 4, 5, 6, 7 are defined by rfc2440 but will be removed from the
-     next revision of the standard.  */
-  if (algo < 0 || algo > 110 || (algo >= 4 && algo <= 7))
+  enum gcry_md_algos ga;
+
+  ga = map_md_openpgp_to_gcry (algo);
+  switch (algo)
+    {
+    default:
+      break;
+    }
+  if (!ga)
     return gpg_error (GPG_ERR_DIGEST_ALGO);
-  return gcry_md_test_algo (algo);
+
+  return gcry_md_test_algo (ga);
 }
 
 
@@ -599,9 +626,17 @@ openpgp_md_test_algo( int algo )
 const char *
 openpgp_md_algo_name (int algo)
 {
-  if (algo < 0 || algo > 110)
-    return "?";
-  return gcry_md_algo_name (algo);
+  switch (algo)
+    {
+    case DIGEST_ALGO_MD5:    return "MD5";
+    case DIGEST_ALGO_SHA1:   return "SHA1";
+    case DIGEST_ALGO_RMD160: return "RIPEMD160";
+    case DIGEST_ALGO_SHA256: return "SHA256";
+    case DIGEST_ALGO_SHA384: return "SHA384";
+    case DIGEST_ALGO_SHA512: return "SHA512";
+    case DIGEST_ALGO_SHA224: return "SHA224";
+    }
+  return "?";
 }
 
 
@@ -920,6 +955,8 @@ string_to_digest_algo (const char *string)
 {
   int val;
 
+  /* FIXME: We should make use of our wrapper fucntion and not assume
+     that there is a 1 to 1 mapping between OpenPGP and Libgcrypt.  */
   val = gcry_md_map_name (string);
   if (!val && string && (string[0]=='H' || string[0]=='h'))
     {

commit 16a6311adefff0139056714521214f845315b7f8
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jan 31 14:35:49 2014 +0100

    gpg: Use only OpenPGP cipher algo ids.
    
    * g10/misc.c (map_cipher_openpgp_to_gcry): Use explicit mapping and
    use enums for the arg and return value.
    (map_cipher_gcry_to_openpgp): Ditto.
    (openpgp_cipher_blocklen): Use constant macros.
    (openpgp_cipher_test_algo): Use mapping function and prepare to
    disable algorithms.
    (openpgp_cipher_algo_name): Do not use Libgcrypt.
    
    * g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Replace
    CGRY_CIPHER_* by CIPHER_ALGO_*.
    
    * common/openpgpdefs.h (cipher_algo_t): Remove unused
    CIPHER_ALGO_DUMMY.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/common/openpgpdefs.h b/common/openpgpdefs.h
index 0a58442..ac1af37 100644
--- a/common/openpgpdefs.h
+++ b/common/openpgpdefs.h
@@ -107,9 +107,7 @@ typedef enum
     CIPHER_ALGO_TWOFISH	    = 10, /* 256 bit */
     CIPHER_ALGO_CAMELLIA128 = 11,
     CIPHER_ALGO_CAMELLIA192 = 12,
-    CIPHER_ALGO_CAMELLIA256 = 13,
-
-    CIPHER_ALGO_DUMMY      = 110 /* No encryption at all (private). */
+    CIPHER_ALGO_CAMELLIA256 = 13
   }
 cipher_algo_t;
 
diff --git a/g10/ecdh.c b/g10/ecdh.c
index 752181e..0b06239 100644
--- a/g10/ecdh.c
+++ b/g10/ecdh.c
@@ -183,9 +183,9 @@ pk_ecdh_encrypt_with_shared_point (int is_encrypt, gcry_mpi_t shared_mpi,
       xfree (secret_x);
       return gpg_error (GPG_ERR_BAD_PUBKEY);
     }
-  if (kdf_encr_algo != GCRY_CIPHER_AES128
-      && kdf_encr_algo != GCRY_CIPHER_AES192
-      && kdf_encr_algo != GCRY_CIPHER_AES256)
+  if (kdf_encr_algo != CIPHER_ALGO_AES
+      && kdf_encr_algo != CIPHER_ALGO_AES192
+      && kdf_encr_algo != CIPHER_ALGO_AES256)
     {
       xfree (secret_x);
       return gpg_error (GPG_ERR_BAD_PUBKEY);
diff --git a/g10/main.h b/g10/main.h
index 26283a7..1ee563e 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -90,22 +90,25 @@ u16 checksum( byte *p, unsigned n );
 u16 checksum_mpi( gcry_mpi_t a );
 u32 buffer_to_u32( const byte *buffer );
 const byte *get_session_marker( size_t *rlen );
-int map_cipher_openpgp_to_gcry (int algo);
+
+enum gcry_cipher_algos map_cipher_openpgp_to_gcry (cipher_algo_t algo);
 #define openpgp_cipher_open(_a,_b,_c,_d) \
   gcry_cipher_open((_a),map_cipher_openpgp_to_gcry((_b)),(_c),(_d))
 #define openpgp_cipher_get_algo_keylen(_a) \
   gcry_cipher_get_algo_keylen(map_cipher_openpgp_to_gcry((_a)))
 #define openpgp_cipher_get_algo_blklen(_a) \
   gcry_cipher_get_algo_blklen(map_cipher_openpgp_to_gcry((_a)))
-int openpgp_cipher_blocklen (int algo);
-int openpgp_cipher_test_algo( int algo );
-const char *openpgp_cipher_algo_name (int algo);
-int map_pk_gcry_to_openpgp (enum gcry_pk_algos algo);
+int openpgp_cipher_blocklen (cipher_algo_t algo);
+int openpgp_cipher_test_algo(cipher_algo_t algo);
+const char *openpgp_cipher_algo_name (cipher_algo_t algo);
+
+pubkey_algo_t map_pk_gcry_to_openpgp (enum gcry_pk_algos algo);
 int openpgp_pk_test_algo (pubkey_algo_t algo);
 int openpgp_pk_test_algo2 (pubkey_algo_t algo, unsigned int use);
 int openpgp_pk_algo_usage ( int algo );
-int openpgp_md_test_algo( int algo );
 const char *openpgp_pk_algo_name (pubkey_algo_t algo);
+
+int openpgp_md_test_algo( int algo );
 const char *openpgp_md_algo_name (int algo);
 
 struct expando_args
diff --git a/g10/misc.c b/g10/misc.c
index 1ac5430..1626b21 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -341,35 +341,53 @@ print_digest_algo_note( int algo )
 /* Map OpenPGP algo numbers to those used by Libgcrypt.  We need to do
    this for algorithms we implemented in Libgcrypt after they become
    part of OpenPGP.  */
-int
-map_cipher_openpgp_to_gcry (int algo)
+enum gcry_cipher_algos
+map_cipher_openpgp_to_gcry (cipher_algo_t algo)
 {
   switch (algo)
     {
-    case CIPHER_ALGO_CAMELLIA128: return 310;
-    case CIPHER_ALGO_CAMELLIA192: return 311;
-    case CIPHER_ALGO_CAMELLIA256: return 312;
-    default: return algo;
+    case CIPHER_ALGO_NONE:        return GCRY_CIPHER_NONE;
+    case CIPHER_ALGO_IDEA:        return GCRY_CIPHER_IDEA;
+    case CIPHER_ALGO_3DES:	  return GCRY_CIPHER_3DES;
+    case CIPHER_ALGO_CAST5:	  return GCRY_CIPHER_CAST5;
+    case CIPHER_ALGO_BLOWFISH:    return GCRY_CIPHER_BLOWFISH;
+    case CIPHER_ALGO_AES:         return GCRY_CIPHER_AES;
+    case CIPHER_ALGO_AES192:      return GCRY_CIPHER_AES192;
+    case CIPHER_ALGO_AES256:      return GCRY_CIPHER_AES256;
+    case CIPHER_ALGO_TWOFISH:     return GCRY_CIPHER_TWOFISH;
+    case CIPHER_ALGO_CAMELLIA128: return GCRY_CIPHER_CAMELLIA128;
+    case CIPHER_ALGO_CAMELLIA192: return GCRY_CIPHER_CAMELLIA192;
+    case CIPHER_ALGO_CAMELLIA256: return GCRY_CIPHER_CAMELLIA256;
     }
+  return 0;
 }
 
-/* The inverse fucntion of above.  */
-static int
-map_cipher_gcry_to_openpgp (int algo)
+/* The inverse function of above.  */
+static cipher_algo_t
+map_cipher_gcry_to_openpgp (enum gcry_cipher_algos algo)
 {
   switch (algo)
     {
-    case 310: return CIPHER_ALGO_CAMELLIA128;
-    case 311: return CIPHER_ALGO_CAMELLIA192;
-    case 312: return CIPHER_ALGO_CAMELLIA256;
-    default: return algo;
+    case GCRY_CIPHER_NONE:        return CIPHER_ALGO_NONE;
+    case GCRY_CIPHER_IDEA:        return CIPHER_ALGO_IDEA;
+    case GCRY_CIPHER_3DES:        return CIPHER_ALGO_3DES;
+    case GCRY_CIPHER_CAST5:       return CIPHER_ALGO_CAST5;
+    case GCRY_CIPHER_BLOWFISH:    return CIPHER_ALGO_BLOWFISH;
+    case GCRY_CIPHER_AES:         return CIPHER_ALGO_AES;
+    case GCRY_CIPHER_AES192:      return CIPHER_ALGO_AES192;
+    case GCRY_CIPHER_AES256:      return CIPHER_ALGO_AES256;
+    case GCRY_CIPHER_TWOFISH:     return CIPHER_ALGO_TWOFISH;
+    case GCRY_CIPHER_CAMELLIA128: return CIPHER_ALGO_CAMELLIA128;
+    case GCRY_CIPHER_CAMELLIA192: return CIPHER_ALGO_CAMELLIA192;
+    case GCRY_CIPHER_CAMELLIA256: return CIPHER_ALGO_CAMELLIA256;
+    default: return 0;
     }
 }
 
 /* Map Gcrypt public key algorithm numbers to those used by OpenPGP.
    FIXME: This mapping is used at only two places - we should get rid
    of it.  */
-int
+pubkey_algo_t
 map_pk_gcry_to_openpgp (enum gcry_pk_algos algo)
 {
   switch (algo)
@@ -383,7 +401,7 @@ map_pk_gcry_to_openpgp (enum gcry_pk_algos algo)
 
 /* Return the block length of an OpenPGP cipher algorithm.  */
 int
-openpgp_cipher_blocklen (int algo)
+openpgp_cipher_blocklen (cipher_algo_t algo)
 {
   /* We use the numbers from OpenPGP to be sure that we get the right
      block length.  This is so that the packet parsing code works even
@@ -394,9 +412,13 @@ openpgp_cipher_blocklen (int algo)
      size. */
   switch (algo)
     {
-    case 7: case 8: case 9: /* AES */
-    case 10: /* Twofish */
-    case 11: case 12: case 13: /* Camellia */
+    case CIPHER_ALGO_AES:
+    case CIPHER_ALGO_AES192:
+    case CIPHER_ALGO_AES256:
+    case CIPHER_ALGO_TWOFISH:
+    case CIPHER_ALGO_CAMELLIA128:
+    case CIPHER_ALGO_CAMELLIA192:
+    case CIPHER_ALGO_CAMELLIA256:
       return 16;
 
     default:
@@ -409,22 +431,50 @@ openpgp_cipher_blocklen (int algo)
  * the OpenPGP contraints for the algo ID.
  */
 int
-openpgp_cipher_test_algo( int algo )
+openpgp_cipher_test_algo (cipher_algo_t algo)
 {
-  /* (5 and 6 are marked reserved by rfc4880.)  */
-  if ( algo < 0 || algo > 110 || algo == 5 || algo == 6 )
+  enum gcry_cipher_algos ga;
+
+  ga = map_cipher_openpgp_to_gcry (algo);
+
+  /* Use this explicit list to disable certain algorithms. */
+  switch (algo)
+    {
+    /* case CIPHER_ALGO_IDEA:         */
+    /*   ga = 0; */
+    /*   break; */
+    default:
+      break;
+    }
+
+  if (!ga)
     return gpg_error (GPG_ERR_CIPHER_ALGO);
 
-  return gcry_cipher_test_algo (map_cipher_openpgp_to_gcry (algo));
+  return gcry_cipher_test_algo (ga);
 }
 
 /* Map the OpenPGP cipher algorithm whose ID is contained in ALGORITHM to a
    string representation of the algorithm name.  For unknown algorithm
    IDs this function returns "?".  */
 const char *
-openpgp_cipher_algo_name (int algo)
+openpgp_cipher_algo_name (cipher_algo_t algo)
 {
-  return gnupg_cipher_algo_name (map_cipher_openpgp_to_gcry (algo));
+  switch (algo)
+    {
+    case CIPHER_ALGO_NONE:        break;
+    case CIPHER_ALGO_IDEA:        return "IDEA";
+    case CIPHER_ALGO_3DES:	  return "3DES";
+    case CIPHER_ALGO_CAST5:	  return "CAST5";
+    case CIPHER_ALGO_BLOWFISH:    return "BLOWFISH";
+    case CIPHER_ALGO_AES:         return "AES";
+    case CIPHER_ALGO_AES192:      return "AES192";
+    case CIPHER_ALGO_AES256:      return "AES256";
+    case CIPHER_ALGO_TWOFISH:     return "TWOFISH";
+    case CIPHER_ALGO_CAMELLIA128: return "CAMELLIA128";
+    case CIPHER_ALGO_CAMELLIA192: return "CAMELLIA192";
+    case CIPHER_ALGO_CAMELLIA256: return "CAMELLIA256";
+    }
+  return "?";
 }
 
 

-----------------------------------------------------------------------

Summary of changes:
 common/openpgpdefs.h |    4 +-
 g10/cpr.c            |   19 +++---
 g10/ecdh.c           |    6 +-
 g10/gpg.c            |   77 +++++++++++++++++++----
 g10/main.h           |   22 ++++---
 g10/misc.c           |  169 ++++++++++++++++++++++++++++++++++++++------------
 6 files changed, 216 insertions(+), 81 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list