diff options
author | Werner Koch <wk@gnupg.org> | 2011-06-29 15:26:22 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2011-06-29 15:26:22 +0200 |
commit | 7cae9fdfc9e322941545a3a2128a5ead1010a6cf (patch) | |
tree | 81ffb01412c1ca2516444725336f0ad69f4a75cd /cipher/cipher.c | |
parent | ea2b4d6653b7e3f483582ee5bf1dc7de2cb0a3f9 (diff) | |
download | libgcrypt-7cae9fdfc9e322941545a3a2128a5ead1010a6cf.tar.gz |
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.
Diffstat (limited to 'cipher/cipher.c')
-rw-r--r-- | cipher/cipher.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/cipher/cipher.c b/cipher/cipher.c index b0a532af..b99ab41b 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; |