shishi-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shishi/lib crypto-rc4.c nettle.c


From: shishi-commit
Subject: shishi/lib crypto-rc4.c nettle.c
Date: Sun, 21 Sep 2003 08:58:30 -0400

CVSROOT:        /cvsroot/shishi
Module name:    shishi
Branch:         
Changes by:     Simon Josefsson <address@hidden>        03/09/21 08:58:29

Modified files:
        lib            : crypto-rc4.c nettle.c 

Log message:
        Support ARCFOUR "iv", from Nicolas Pouvesle <address@hidden>.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/crypto-rc4.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/nettle.c.diff?tr1=1.13&tr2=1.14&r1=text&r2=text

Patches:
Index: shishi/lib/crypto-rc4.c
diff -u shishi/lib/crypto-rc4.c:1.11 shishi/lib/crypto-rc4.c:1.12
--- shishi/lib/crypto-rc4.c:1.11        Sat Sep 20 07:06:10 2003
+++ shishi/lib/crypto-rc4.c     Sun Sep 21 08:58:29 2003
@@ -198,7 +198,7 @@
       _shishi_hexprint (K3, 16);
     }
 
-  err = shishi_arcfour (handle, 0, K3, 16, pt, ptlen, &ct);
+  err = shishi_arcfour (handle, 0, K3, 16, iv, ivout, pt, ptlen, &ct);
   if (err)
     goto done;
 
@@ -213,6 +213,10 @@
   memcpy (*out, cksum, 16);
   memcpy (*out + 16, ct, ptlen);
 
+  if (ivoutlen)
+    /* size = sbox[256] + int32_t i + int32_t j */
+    *ivoutlen = 256 + 2*8;
+
   err = SHISHI_OK;
 
  done:
@@ -298,7 +302,7 @@
       _shishi_hexprint (K3, 16);
     }
 
-  err = shishi_arcfour (handle, 1, K3, 16, in + 16, inlen - 16, &pt);
+  err = shishi_arcfour (handle, 1, K3, 16, iv, ivout, in + 16, inlen - 16, 
&pt);
   if (err)
     goto done;
 
@@ -327,6 +331,10 @@
   *out = xmalloc (*outlen);
   memcpy (*out, pt + 8, inlen - 16 - 8);
 
+  if (ivoutlen)
+    /* size = sbox[256] + int32_t i + int32_t j */
+    *ivoutlen = 256 + 2*8;
+
   err = SHISHI_OK;
 
  done:
@@ -490,7 +498,7 @@
 cipherinfo arcfour_hmac_info = {
   SHISHI_ARCFOUR_HMAC,
   "arcfour-hmac",
-  16,
+  1,
   0,
   16,
   16,
@@ -505,7 +513,7 @@
 cipherinfo arcfour_hmac_exp_info = {
   SHISHI_ARCFOUR_HMAC_EXP,
   "arcfour-hmac-exp",
-  16,
+  1,
   0,
   16,
   16,
Index: shishi/lib/nettle.c
diff -u shishi/lib/nettle.c:1.13 shishi/lib/nettle.c:1.14
--- shishi/lib/nettle.c:1.13    Sat Sep 20 07:09:07 2003
+++ shishi/lib/nettle.c Sun Sep 21 08:58:29 2003
@@ -410,6 +410,7 @@
 int
 shishi_arcfour (Shishi * handle, int decryptp,
                const char *key, size_t keylen,
+               const char *iv, char **ivout,
                const char *in, size_t inlen,
                char **out)
 {
@@ -417,8 +418,18 @@
 
   *out = xmalloc (inlen);
 
-  arcfour_set_key (&ctx, keylen, key);
+  if (iv)
+    memcpy (&ctx, iv, sizeof (ctx));
+  else
+    arcfour_set_key (&ctx, keylen, key);
+
   arcfour_crypt (&ctx, inlen, *out, in);
+
+  if (ivout)
+    {
+      *ivout = xmalloc (sizeof (ctx));
+      memcpy (*ivout, &ctx, sizeof (ctx));
+    }
 
   return SHISHI_OK;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]