shishi-commit
[Top][All Lists]
Advanced

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

shishi lib/crypto-des.c lib/crypto-rc4.c lib/cr...


From: shishi-commit
Subject: shishi lib/crypto-des.c lib/crypto-rc4.c lib/cr...
Date: Thu, 18 Sep 2003 17:54:10 -0400

CVSROOT:        /cvsroot/shishi
Module name:    shishi
Branch:         
Changes by:     Simon Josefsson <address@hidden>        03/09/18 17:54:09

Modified files:
        lib            : crypto-des.c crypto-rc4.c crypto.c kdcreq.c 
                         key.c libgcrypt.c nettle.c shishi.h.in 
        src            : shishi.c 

Log message:
        (shishi_randomize): Add 'strong' parameter.
        Fix callers.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/crypto-des.c.diff?tr1=1.51&tr2=1.52&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/crypto-rc4.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/crypto.c.diff?tr1=1.83&tr2=1.84&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/kdcreq.c.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/key.c.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/libgcrypt.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.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/lib/shishi.h.in.diff?tr1=1.171&tr2=1.172&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/src/shishi.c.diff?tr1=1.65&tr2=1.66&r1=text&r2=text

Patches:
Index: shishi/lib/crypto-des.c
diff -u shishi/lib/crypto-des.c:1.51 shishi/lib/crypto-des.c:1.52
--- shishi/lib/crypto-des.c:1.51        Mon Sep  8 19:27:20 2003
+++ shishi/lib/crypto-des.c     Thu Sep 18 17:54:09 2003
@@ -34,7 +34,7 @@
   int hlen = 16;
   int rc;
 
-  rc = shishi_randomize (handle, out, blen);
+  rc = shishi_randomize (handle, 0, out, blen);
   if (rc != SHISHI_OK)
     return rc;
 
@@ -78,7 +78,7 @@
   int hlen = 16;
   int rc;
 
-  rc = shishi_randomize (handle, out, blen);
+  rc = shishi_randomize (handle, 0, out, blen);
   if (rc != SHISHI_OK)
     return rc;
 
Index: shishi/lib/crypto-rc4.c
diff -u shishi/lib/crypto-rc4.c:1.7 shishi/lib/crypto-rc4.c:1.8
--- shishi/lib/crypto-rc4.c:1.7 Sat Sep 13 20:59:51 2003
+++ shishi/lib/crypto-rc4.c     Thu Sep 18 17:54:09 2003
@@ -121,7 +121,7 @@
   pt = xmalloc (16 + 8 + inlen);
 
   memset (pt, 0, 16);
-  err = shishi_randomize (handle, pt + 16, 8);
+  err = shishi_randomize (handle, 0, pt + 16, 8);
   if (err)
     goto done;
   memcpy (pt + 16 + 8, in, inlen);
@@ -196,7 +196,7 @@
   pt = xmalloc (16 + 8 + inlen);
 
   memset (pt, 0, 16);
-  err = shishi_randomize (handle, pt + 16, 8);
+  err = shishi_randomize (handle, 0, pt + 16, 8);
   if (err)
     goto done;
   memcpy (pt + 16 + 8, in, inlen);
Index: shishi/lib/crypto.c
diff -u shishi/lib/crypto.c:1.83 shishi/lib/crypto.c:1.84
--- shishi/lib/crypto.c:1.83    Sat Sep 13 20:59:51 2003
+++ shishi/lib/crypto.c Thu Sep 18 17:54:09 2003
@@ -307,7 +307,7 @@
       ptlen = inlen + blen + padzerolen;
       pt = xmalloc (ptlen);
 
-      res = shishi_randomize (handle, pt, blen);
+      res = shishi_randomize (handle, 0, pt, blen);
       if (res != SHISHI_OK)
        goto done;
 
Index: shishi/lib/kdcreq.c
diff -u shishi/lib/kdcreq.c:1.49 shishi/lib/kdcreq.c:1.50
--- shishi/lib/kdcreq.c:1.49    Mon Sep  8 12:19:27 2003
+++ shishi/lib/kdcreq.c Thu Sep 18 17:54:09 2003
@@ -105,7 +105,7 @@
   if (res != SHISHI_OK)
     goto error;
 
-  shishi_randomize (handle, &noncebuf[0], sizeof (noncebuf));
+  shishi_randomize (handle, 0, &noncebuf[0], sizeof (noncebuf));
   res = shishi_asn1_write (handle, node, "req-body.nonce", noncebuf,
                           sizeof (noncebuf));
   if (res != SHISHI_OK)
Index: shishi/lib/key.c
diff -u shishi/lib/key.c:1.21 shishi/lib/key.c:1.22
--- shishi/lib/key.c:1.21       Sat Sep  6 15:57:16 2003
+++ shishi/lib/key.c    Thu Sep 18 17:54:09 2003
@@ -356,7 +356,7 @@
   if (rc != SHISHI_OK)
     return rc;
 
-  rc = shishi_randomize (handle, buf, len);
+  rc = shishi_randomize (handle, 1, buf, len);
   if (rc != SHISHI_OK)
     return rc;
 
Index: shishi/lib/libgcrypt.c
diff -u shishi/lib/libgcrypt.c:1.11 shishi/lib/libgcrypt.c:1.12
--- shishi/lib/libgcrypt.c:1.11 Sat Sep 13 20:21:43 2003
+++ shishi/lib/libgcrypt.c      Thu Sep 18 17:54:09 2003
@@ -63,9 +63,12 @@
 }
 
 int
-shishi_randomize (Shishi * handle, char *data, size_t datalen)
+shishi_randomize (Shishi * handle, int strong, char *data, size_t datalen)
 {
-  gcry_randomize (data, datalen, GCRY_STRONG_RANDOM);
+  if (strong)
+    gcry_randomize (data, datalen, GCRY_STRONG_RANDOM);
+  else
+    gcry_randomize (data, datalen, GCRY_VERY_STRONG_RANDOM);
   return SHISHI_OK;
 }
 
Index: shishi/lib/nettle.c
diff -u shishi/lib/nettle.c:1.9 shishi/lib/nettle.c:1.10
--- shishi/lib/nettle.c:1.9     Sun Sep 14 10:47:46 2003
+++ shishi/lib/nettle.c Thu Sep 18 17:54:09 2003
@@ -40,28 +40,32 @@
 /**
  * shishi_randomize:
  * @handle: shishi handle as allocated by shishi_init().
+ * @strong: 0 iff operation should not block, non-0 for very strong randomness.
  * @data: output array to be filled with random data.
  * @datalen: size of output array.
  *
- * Store cryptographically strong random data of given size in the
- * provided buffer.
+ * Store cryptographically random data of given size in the provided
+ * buffer.
  *
  * Return value: Returns %SHISHI_OK iff successful.
  **/
 int
-shishi_randomize (Shishi * handle, char *data, size_t datalen)
+shishi_randomize (Shishi * handle, int strong, char *data, size_t datalen)
 {
   int fd;
   char *device;
   size_t len = 0;
   int rc;
 
-  device = "/dev/random";
+  if (strong)
+    device = "/dev/random";
+  else
+    device = "/dev/urandom";
 
   fd = open (device, O_RDONLY);
   if (fd < 0)
     {
-      shishi_error_printf (handle, "Could not open random device: %s",
+      shishi_error_printf (handle, "Could not open %s: %s", device,
                           strerror (errno));
       return SHISHI_FILE_ERROR;
     }
@@ -74,23 +78,22 @@
 
       if (tmp < 0)
        {
-         shishi_error_printf (handle, "Could not read from random device: %s",
-                              strerror (errno));
+         shishi_error_printf (handle, "Could not read from %s: %s",
+                              device, strerror (errno));
          return SHISHI_FILE_ERROR;
        }
 
       len += tmp;
 
       if (len < datalen)
-       shishi_error_printf (handle, "Short read from random device: %d < %d",
-                            len, datalen);
+       shishi_error_printf (handle, "Short read from %s: %d < %d",
+                            device, len, datalen);
     }
   while (len < datalen);
 
   rc = close (fd);
   if (rc < 0)
-    shishi_warn (handle, "Could not close random device: %s",
-                strerror (errno));
+    shishi_warn (handle, "Could not close %s: %s", device, strerror (errno));
 
   return SHISHI_OK;
 }
Index: shishi/lib/shishi.h.in
diff -u shishi/lib/shishi.h.in:1.171 shishi/lib/shishi.h.in:1.172
--- shishi/lib/shishi.h.in:1.171        Sat Sep 13 20:21:43 2003
+++ shishi/lib/shishi.h.in      Thu Sep 18 17:54:09 2003
@@ -1260,7 +1260,8 @@
                        const char *field, char **time);
 
 /* nettle.c, libgcrypt.c, ... */
-extern int shishi_randomize (Shishi * handle, char *data, size_t datalen);
+extern int shishi_randomize (Shishi * handle, int strong,
+                            char *data, size_t datalen);
 extern int shishi_md4 (Shishi * handle, const char *in, size_t inlen,
                       char *out[16]);
 extern int shishi_md5 (Shishi * handle, const char *in, size_t inlen,
Index: shishi/src/shishi.c
diff -u shishi/src/shishi.c:1.65 shishi/src/shishi.c:1.66
--- shishi/src/shishi.c:1.65    Mon Sep  8 13:56:02 2003
+++ shishi/src/shishi.c Thu Sep 18 17:54:09 2003
@@ -304,7 +304,7 @@
     {
       char buf[BUFSIZ];
 
-      rc = shishi_randomize (handle, buf,
+      rc = shishi_randomize (handle, 1, buf,
                             shishi_cipher_randomlen (arg.algorithm));
       if (rc != SHISHI_OK)
        return rc;




reply via email to

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