diff --git a/cipher/ChangeLog b/cipher/ChangeLog index ce3f04349..f4371b80a 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,8 @@ +2008-04-17 David Shaw + + * camellia-glue.c (selftest, camellia_get_info), cipher.c + (setup_cipher_table): Add Camellia-192. + 2008-03-22 Werner Koch * cipher.c (struct cipher_handle_s): Make sure IV is u32 diff --git a/cipher/camellia-glue.c b/cipher/camellia-glue.c index aeaa722a5..72f3ad808 100644 --- a/cipher/camellia-glue.c +++ b/cipher/camellia-glue.c @@ -1,5 +1,5 @@ /* camellia-glue.c - Glue for the Camellia cipher - * Copyright (C) 2007 Free Software Foundation, Inc. + * Copyright (C) 2007, 2008 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -58,7 +58,7 @@ camellia_setkey(void *c, const byte *key, unsigned keylen) static int initialized=0; static const char *selftest_failed=NULL; - if(keylen!=16 && keylen!=32) + if(keylen!=16 && keylen!=24 && keylen!=32) return G10ERR_WRONG_KEYLEN; if(!initialized) @@ -133,6 +133,16 @@ selftest(void) 0x67,0x67,0x31,0x38,0x54,0x96,0x69,0x73, 0x08,0x57,0x06,0x56,0x48,0xea,0xbe,0x43 }; + const byte key_192[]= + { + 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba,0x98, + 0x76,0x54,0x32,0x10,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77 + }; + const byte ciphertext_192[]= + { + 0xb4,0x99,0x34,0x01,0xb3,0xe9,0x96,0xf8, + 0x4e,0xe5,0xce,0xe7,0xd7,0x9b,0x09,0xb9 + }; const byte key_256[]= { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,0xfe,0xdc,0xba, @@ -154,6 +164,14 @@ selftest(void) if(memcmp(scratch,plaintext,sizeof(scratch))!=0) return "CAMELLIA128 test decryption failed."; + camellia_setkey(&ctx,key_192,sizeof(key_192)); + camellia_encrypt(&ctx,scratch,plaintext); + if(memcmp(scratch,ciphertext_192,sizeof(scratch))!=0) + return "CAMELLIA192 test encryption failed."; + camellia_decrypt(&ctx,scratch,scratch); + if(memcmp(scratch,plaintext,sizeof(scratch))!=0) + return "CAMELLIA192 test decryption failed."; + camellia_setkey(&ctx,key_256,sizeof(key_256)); camellia_encrypt(&ctx,scratch,plaintext); if(memcmp(scratch,ciphertext_256,sizeof(scratch))!=0) @@ -185,6 +203,11 @@ camellia_get_info(int algo, size_t *keylen, *keylen = 128; return "CAMELLIA128"; } + else if(algo==CIPHER_ALGO_CAMELLIA192) + { + *keylen = 192; + return "CAMELLIA192"; + } else if(algo==CIPHER_ALGO_CAMELLIA256) { *keylen = 256; diff --git a/cipher/cipher.c b/cipher/cipher.c index 9d9c82293..4ef0d817a 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, 2004, 2005 - * 2007, 2008 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, + * 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -198,6 +198,17 @@ setup_cipher_table(void) if( !cipher_table[i].name ) BUG(); i++; + cipher_table[i].algo = CIPHER_ALGO_CAMELLIA192; + cipher_table[i].name = camellia_get_info( cipher_table[i].algo, + &cipher_table[i].keylen, + &cipher_table[i].blocksize, + &cipher_table[i].contextsize, + &cipher_table[i].setkey, + &cipher_table[i].encrypt, + &cipher_table[i].decrypt ); + if( !cipher_table[i].name ) + BUG(); + i++; cipher_table[i].algo = CIPHER_ALGO_CAMELLIA256; cipher_table[i].name = camellia_get_info( cipher_table[i].algo, &cipher_table[i].keylen, diff --git a/g10/ChangeLog b/g10/ChangeLog index d00a58ac0..4d380a70d 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,7 @@ +2008-04-17 David Shaw + + * parse-packet.c (parse_key): Add constant for Camellia-192. + 2008-04-12 David Shaw * getkey.c (merge_selfsigs_subkey): If there are multiple 0x19 diff --git a/g10/parse-packet.c b/g10/parse-packet.c index e0c068167..61c289cf8 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -1,6 +1,6 @@ /* parse-packet.c - read packets - * 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. * @@ -1856,7 +1856,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen, switch( sk->protect.algo ) { case 7: case 8: case 9: /* AES */ case 10: /* Twofish */ - case 11: case 12: /* Camellia */ + case 11: case 12: case 13: /* Camellia */ sk->protect.ivlen = 16; break; default: diff --git a/include/ChangeLog b/include/ChangeLog index 4cfd4b8bf..cb55c965c 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2008-04-17 David Shaw + + * cipher.h: Add the 192-bit variant of Camellia. + 2007-11-29 David Shaw * cipher.h: Add the 128-bit variant of Camellia. diff --git a/include/cipher.h b/include/cipher.h index 73db8fde4..2bc57d6e1 100644 --- a/include/cipher.h +++ b/include/cipher.h @@ -1,6 +1,6 @@ /* cipher.h - * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, - * 2007 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, + * 2008 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -37,7 +37,8 @@ #define CIPHER_ALGO_AES256 9 #define CIPHER_ALGO_TWOFISH 10 /* twofish 256 bit */ #define CIPHER_ALGO_CAMELLIA128 11 -#define CIPHER_ALGO_CAMELLIA256 12 +#define CIPHER_ALGO_CAMELLIA192 12 +#define CIPHER_ALGO_CAMELLIA256 13 #define CIPHER_ALGO_DUMMY 110 /* no encryption at all */