[svn] GnuPG - r4748 - in branches/STABLE-BRANCH-1-4: cipher g10 include

svn author dshaw cvs at cvs.gnupg.org
Thu Apr 17 19:40:32 CEST 2008


Author: dshaw
Date: 2008-04-17 19:40:30 +0200 (Thu, 17 Apr 2008)
New Revision: 4748

Modified:
   branches/STABLE-BRANCH-1-4/cipher/ChangeLog
   branches/STABLE-BRANCH-1-4/cipher/camellia-glue.c
   branches/STABLE-BRANCH-1-4/cipher/cipher.c
   branches/STABLE-BRANCH-1-4/g10/ChangeLog
   branches/STABLE-BRANCH-1-4/g10/parse-packet.c
   branches/STABLE-BRANCH-1-4/include/ChangeLog
   branches/STABLE-BRANCH-1-4/include/cipher.h
Log:
Add Camellia-192.


Modified: branches/STABLE-BRANCH-1-4/cipher/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/cipher/ChangeLog	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/cipher/ChangeLog	2008-04-17 17:40:30 UTC (rev 4748)
@@ -1,3 +1,8 @@
+2008-04-17  David Shaw  <dshaw at jabberwocky.com>
+
+	* camellia-glue.c (selftest, camellia_get_info), cipher.c
+	(setup_cipher_table): Add Camellia-192.
+
 2008-03-22  Werner Koch  <wk at g10code.com>
 
 	* cipher.c (struct cipher_handle_s): Make sure IV is u32

Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/ChangeLog	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/g10/ChangeLog	2008-04-17 17:40:30 UTC (rev 4748)
@@ -1,3 +1,7 @@
+2008-04-17  David Shaw  <dshaw at jabberwocky.com>
+
+	* parse-packet.c (parse_key): Add constant for Camellia-192.
+
 2008-04-12  David Shaw  <dshaw at jabberwocky.com>
 
 	* getkey.c (merge_selfsigs_subkey): If there are multiple 0x19

Modified: branches/STABLE-BRANCH-1-4/include/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/include/ChangeLog	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/include/ChangeLog	2008-04-17 17:40:30 UTC (rev 4748)
@@ -1,3 +1,7 @@
+2008-04-17  David Shaw  <dshaw at jabberwocky.com>
+
+	* cipher.h: Add the 192-bit variant of Camellia.
+
 2007-11-29  David Shaw  <dshaw at jabberwocky.com>
 
 	* cipher.h: Add the 128-bit variant of Camellia.

Modified: branches/STABLE-BRANCH-1-4/cipher/camellia-glue.c
===================================================================
--- branches/STABLE-BRANCH-1-4/cipher/camellia-glue.c	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/cipher/camellia-glue.c	2008-04-17 17:40:30 UTC (rev 4748)
@@ -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 @@
   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 @@
       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 @@
   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 @@
       *keylen = 128;
       return "CAMELLIA128";
     }
+  else if(algo==CIPHER_ALGO_CAMELLIA192)
+    {
+      *keylen = 192;
+      return "CAMELLIA192";
+    }
   else if(algo==CIPHER_ALGO_CAMELLIA256)
     {
       *keylen = 256;

Modified: branches/STABLE-BRANCH-1-4/cipher/cipher.c
===================================================================
--- branches/STABLE-BRANCH-1-4/cipher/cipher.c	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/cipher/cipher.c	2008-04-17 17:40:30 UTC (rev 4748)
@@ -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 @@
     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,

Modified: branches/STABLE-BRANCH-1-4/g10/parse-packet.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/parse-packet.c	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/g10/parse-packet.c	2008-04-17 17:40:30 UTC (rev 4748)
@@ -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 @@
 	    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:

Modified: branches/STABLE-BRANCH-1-4/include/cipher.h
===================================================================
--- branches/STABLE-BRANCH-1-4/include/cipher.h	2008-04-16 16:11:41 UTC (rev 4747)
+++ branches/STABLE-BRANCH-1-4/include/cipher.h	2008-04-17 17:40:30 UTC (rev 4748)
@@ -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 */
 




More information about the Gnupg-commits mailing list