[git] GCRYPT - branch, LIBGCRYPT-1-5-BRANCH, updated. libgcrypt-1.5.0-3-g674f10d

by Werner Koch cvs at cvs.gnupg.org
Wed Jun 29 16:14:40 CEST 2011


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 crypto library".

The branch, LIBGCRYPT-1-5-BRANCH has been updated
       via  674f10dba527f8c50af028c97cf046e16bc4e6fb (commit)
      from  09d718069ad4438d665f9a176a702a84b9abb290 (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 674f10dba527f8c50af028c97cf046e16bc4e6fb
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jun 29 15:26:22 2011 +0200

    Fixed a bug in the gcry_cipher_get_algo_keylen and gcry_cipher_get_algo_blklen
    
    Contrary to the documentation those functions aborted if an invalid
    algorithm was passed.  The same happened for the corresponding
    subcommands of gcry_cipher_algo_info.

diff --git a/cipher/ChangeLog b/cipher/ChangeLog
index 16632f0..f061d01 100644
--- a/cipher/ChangeLog
+++ b/cipher/ChangeLog
@@ -1,3 +1,8 @@
+2011-06-29  Werner Koch  <wk at g10code.com>
+
+	* cipher.c (cipher_get_keylen): Return zero for an invalid algorithm.
+	(cipher_get_blocksize): Ditto.
+
 2011-06-13  Werner Koch  <wk at g10code.com>
 
 	* dsa.c (selftest_sign_1024): Use the raw and not the pkcs1 flag.
diff --git a/cipher/cipher.c b/cipher/cipher.c
index b0a532a..b99ab41 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -1,6 +1,6 @@
 /* cipher.c  -	cipher dispatcher
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
- *               2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+ *               2005, 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
  *
  * This file is part of Libgcrypt.
  *
@@ -610,10 +610,8 @@ check_cipher_algo (int algorithm)
 }
 
 
-/* Return the standard length of the key for the cipher algorithm with
-   the identifier ALGORITHM.  This function expects a valid algorithm
-   and will abort if the algorithm is not available or the length of
-   the key is not known. */
+/* Return the standard length in bits of the key for the cipher
+   algorithm with the identifier ALGORITHM.  */
 static unsigned int
 cipher_get_keylen (int algorithm)
 {
@@ -631,17 +629,13 @@ cipher_get_keylen (int algorithm)
 	log_bug ("cipher %d w/o key length\n", algorithm);
       _gcry_module_release (cipher);
     }
-  else
-    log_bug ("cipher %d not found\n", algorithm);
   ath_mutex_unlock (&ciphers_registered_lock);
 
   return len;
 }
 
 /* Return the block length of the cipher algorithm with the identifier
-   ALGORITHM.  This function expects a valid algorithm and will abort
-   if the algorithm is not available or the length of the key is not
-   known. */
+   ALGORITHM.  This function return 0 for an invalid algorithm.  */
 static unsigned int
 cipher_get_blocksize (int algorithm)
 {
@@ -659,8 +653,6 @@ cipher_get_blocksize (int algorithm)
 	  log_bug ("cipher %d w/o blocksize\n", algorithm);
       _gcry_module_release (cipher);
     }
-  else
-    log_bug ("cipher %d not found\n", algorithm);
   ath_mutex_unlock (&ciphers_registered_lock);
 
   return len;
@@ -2084,8 +2076,7 @@ gcry_cipher_algo_info (int algo, int what, void *buffer, size_t *nbytes)
 	  if ((ui > 0) && (ui <= 512))
 	    *nbytes = (size_t) ui / 8;
 	  else
-	    /* The only reason is an invalid algo or a strange
-	       blocksize.  */
+	    /* The only reason for an error is an invalid algo.  */
 	    err = GPG_ERR_CIPHER_ALGO;
 	}
       break;
diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi
index e172ca8..1f5e6e1 100644
--- a/doc/gcrypt.texi
+++ b/doc/gcrypt.texi
@@ -1891,11 +1891,15 @@ Here is a list of supported codes for @var{what}:
 Return the length of the key. If the algorithm supports multiple key
 lengths, the maximum supported value is returned.  The length is
 returned as number of octets (bytes) and not as number of bits in
- at var{nbytes}; @var{buffer} must be zero.
+ at var{nbytes}; @var{buffer} must be zero.  Note that it is usually
+better to use the convenience function
+ at code{gcry_cipher_get_algo_keylen}.
 
 @item GCRYCTL_GET_BLKLEN:
 Return the block length of the algorithm.  The length is returned as a
-number of octets in @var{nbytes}; @var{buffer} must be zero.
+number of octets in @var{nbytes}; @var{buffer} must be zero.  Note
+that it is usually better to use the convenience function
+ at code{gcry_cipher_get_algo_blklen}.
 
 @item GCRYCTL_TEST_ALGO:
 Returns @code{0} when the specified algorithm is available for use.
@@ -1907,6 +1911,31 @@ Returns @code{0} when the specified algorithm is available for use.
 @end deftypefun
 @c end gcry_cipher_algo_info
 
+ at deftypefun size_t gcry_cipher_get_algo_keylen (@var{algo})
+
+This function returns length of the key for algorithm @var{algo}.  If
+the algorithm supports multiple key lengths, the maximum supported key
+length is returned.  On error @code{0} is returned.  The key length is
+returned as number of octets.
+
+This is a convenience functions which should be preferred over
+ at code{gcry_cipher_algo_info} because it allows for proper type
+checking.
+ at end deftypefun
+ at c end gcry_cipher_get_algo_keylen
+
+ at deftypefun size_t gcry_cipher_get_algo_blklen (int @var{algo})
+
+This functions returns the blocklength of the algorithm @var{algo}
+counted in octets.  On error @code{0} is returned.
+
+This is a convenience functions which should be preferred over
+ at code{gcry_cipher_algo_info} because it allows for proper type
+checking.
+ at end deftypefun
+ at c end gcry_cipher_get_algo_blklen
+
+
 @deftypefun {const char *} gcry_cipher_algo_name (int @var{algo})
 
 @code{gcry_cipher_algo_name} returns a string with the name of the
diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in
index f67c19a..63f71c0 100644
--- a/src/gcrypt.h.in
+++ b/src/gcrypt.h.in
@@ -941,7 +941,7 @@ gcry_error_t gcry_cipher_setiv (gcry_cipher_hd_t hd,
 gpg_error_t gcry_cipher_setctr (gcry_cipher_hd_t hd,
                                 const void *ctr, size_t ctrlen);
 
-/* Retrieved the key length in bytes used with algorithm A. */
+/* Retrieve the key length in bytes used with algorithm A. */
 size_t gcry_cipher_get_algo_keylen (int algo);
 
 /* Retrieve the block length in bytes used with algorithm A. */

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

Summary of changes:
 cipher/ChangeLog |    5 +++++
 cipher/cipher.c  |   19 +++++--------------
 doc/gcrypt.texi  |   33 +++++++++++++++++++++++++++++++--
 src/gcrypt.h.in  |    2 +-
 4 files changed, 42 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org




More information about the Gnupg-commits mailing list