diff options
Diffstat (limited to 'cipher')
-rw-r--r-- | cipher/ChangeLog | 5 | ||||
-rw-r--r-- | cipher/camellia-glue.c | 27 | ||||
-rw-r--r-- | cipher/cipher.c | 15 |
3 files changed, 43 insertions, 4 deletions
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 <[email protected]> + + * camellia-glue.c (selftest, camellia_get_info), cipher.c + (setup_cipher_table): Add Camellia-192. + 2008-03-22 Werner Koch <[email protected]> * 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, |