diff options
author | Werner Koch <wk@gnupg.org> | 2008-04-18 11:20:25 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2008-04-18 11:20:25 +0200 |
commit | 4896f5f47c1a58a4ee81c1ce1ef879fd3156bbe7 (patch) | |
tree | fb2741341342ef10c52ef1f345eef45eda8defe0 /g10/misc.c | |
parent | Test commit (diff) | |
download | gnupg2-4896f5f47c1a58a4ee81c1ce1ef879fd3156bbe7.tar.xz gnupg2-4896f5f47c1a58a4ee81c1ce1ef879fd3156bbe7.zip |
Adjust for the changed Camellia draft.
W32 gettext changes.
Comment and typo fixes.
Diffstat (limited to 'g10/misc.c')
-rw-r--r-- | g10/misc.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/g10/misc.c b/g10/misc.c index 233c40264..2e2c70722 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -1,6 +1,6 @@ /* misc.c - miscellaneous functions - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, - * 2005, 2006, 2007 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, + * 2005, 2006, 2007, 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -338,6 +338,7 @@ map_cipher_openpgp_to_gcry (int algo) switch (algo) { case CIPHER_ALGO_CAMELLIA128: return 310; + case CIPHER_ALGO_CAMELLIA192: return 311; case CIPHER_ALGO_CAMELLIA256: return 312; default: return algo; } @@ -350,11 +351,36 @@ map_cipher_gcry_to_openpgp (int algo) switch (algo) { case 310: return CIPHER_ALGO_CAMELLIA128; + case 311: return CIPHER_ALGO_CAMELLIA192; case 312: return CIPHER_ALGO_CAMELLIA256; default: return algo; } } + +/* Return the block length of an OpenPGP cipher algorithm. */ +int +openpgp_cipher_blocklen (int 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 + for unknown algorithms (for which we assume 8 due to tradition). + + NOTE: If you change the the returned blocklen above 16, check + the callers because they may use a fixed size buffer of that + size. */ + switch (algo) + { + case 7: case 8: case 9: /* AES */ + case 10: /* Twofish */ + case 11: case 12: case 13: /* Camellia */ + return 16; + + default: + return 8; + } +} + /**************** * Wrapper around the libgcrypt function with additonal checks on * the OpenPGP contraints for the algo ID. @@ -370,7 +396,8 @@ openpgp_cipher_test_algo( int algo ) requested. */ #ifndef USE_CAMELLIA if (algo == CIPHER_ALGO_CAMELLIA128 - || algo == CIPHER_ALGO_CAMELLIA256) + || algo == CIPHER_ALGO_CAMELLIA192 + || algo == CIPHER_ALGO_CAMELLIA256) return gpg_error (GPG_ERR_CIPHER_ALGO); #endif @@ -386,8 +413,6 @@ openpgp_cipher_algo_name (int algo) return gcry_cipher_algo_name (map_cipher_openpgp_to_gcry (algo)); } - - int openpgp_pk_test_algo( int algo ) { |