cipher: Add support for 128-bit keys in RC2
authorPeter Wu <lekensteyn@gmail.com>
Thu, 26 Sep 2013 21:20:32 +0000 (23:20 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 1 Oct 2013 12:01:01 +0000 (14:01 +0200)
* cipher/rfc2268.c (oids_rfc2268_128): New
(_gcry_cipher_spec_rfc2268_128): New.
* cipher/cipher.c (cipher_table_entry): Add GCRY_CIPHER_RFC2268_128.
--

This patch adds support for decrypting (and encrypting) using 128-bit
keys using the RC2 algorithm.

Signed-off-by: Peter Wu <lekensteyn@gmail.com>
Actually this is merely enabling that extra ID for 128 bit RFC2268.
We should have used one id for that algorithm only, because a second
identifier merely for having the OID in the code is a bad idea.  My
initial fault and thus I better apply this patch to make the id not
entirely useless.  -wk

cipher/cipher.c
cipher/rfc2268.c
src/cipher.h

index a17ca9b..23cb99c 100644 (file)
@@ -87,6 +87,8 @@ static struct cipher_table_entry
 #if USE_RFC2268
     { &_gcry_cipher_spec_rfc2268_40,
       &dummy_extra_spec,                  GCRY_CIPHER_RFC2268_40 },
+    { &_gcry_cipher_spec_rfc2268_128,
+      &dummy_extra_spec,                  GCRY_CIPHER_RFC2268_128 },
 #endif
 #if USE_SEED
     { &_gcry_cipher_spec_seed,
index 130be9b..da0b9f4 100644 (file)
@@ -351,8 +351,21 @@ static gcry_cipher_oid_spec_t oids_rfc2268_40[] =
     { NULL }
   };
 
+static gcry_cipher_oid_spec_t oids_rfc2268_128[] =
+  {
+    /* pbeWithSHAAnd128BitRC2_CBC */
+    { "1.2.840.113549.1.12.1.5", GCRY_CIPHER_MODE_CBC },
+    { NULL }
+  };
+
 gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40 = {
   "RFC2268_40", NULL, oids_rfc2268_40,
   RFC2268_BLOCKSIZE, 40, sizeof(RFC2268_context),
   do_setkey, encrypt_block, decrypt_block
 };
+
+gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_128 = {
+  "RFC2268_128", NULL, oids_rfc2268_128,
+  RFC2268_BLOCKSIZE, 128, sizeof(RFC2268_context),
+  do_setkey, encrypt_block, decrypt_block
+};
index ea7a141..70b46fe 100644 (file)
@@ -194,6 +194,7 @@ extern gcry_cipher_spec_t _gcry_cipher_spec_serpent128;
 extern gcry_cipher_spec_t _gcry_cipher_spec_serpent192;
 extern gcry_cipher_spec_t _gcry_cipher_spec_serpent256;
 extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40;
+extern gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_128;
 extern gcry_cipher_spec_t _gcry_cipher_spec_seed;
 extern gcry_cipher_spec_t _gcry_cipher_spec_camellia128;
 extern gcry_cipher_spec_t _gcry_cipher_spec_camellia192;