Code auditing weekend results and fixes committing.
[silc.git] / lib / silccrypt / silcrng.c
index 9470fb034e0bd0b81d3adf608ef085a3c89ca6e5..9da70dd93f9449a03398dfba3fbf2f3147b8ced0 100644 (file)
@@ -17,6 +17,7 @@
   GNU General Public License for more details.
 
 */
+/* $Id$ */
 /*
  * Created: Sun Mar  9 00:09:18 1997
  *
  */
 /* XXX: Some operations block resulting slow initialization.
  * XXX: I have some pending changes to make this better. */
-/*
- * $Id$
- * $Log$
- * Revision 1.2  2000/07/05 06:08:43  priikone
- *     Global cosmetic change.
- *
- * Revision 1.1.1.1  2000/06/27 11:36:55  priikone
- *     Imported from internal CVS/Added Log headers.
- *
- *
- */
 
 #include "silcincludes.h"
 
@@ -161,10 +151,6 @@ void silc_rng_init(SilcRng rng)
       (i * (sizeof(rng->pool) / SILC_RNG_STATE_NUM));
     next->pos =
       (i * (sizeof(rng->pool) / SILC_RNG_STATE_NUM)) + 8;
-#if 0
-    next->pos = sizeof(rng->pool) - 
-      ((i * (sizeof(rng->pool) / SILC_RNG_STATE_NUM))) + 8;
-#endif
     next->next = rng->state;
     rng->state = next;
   }
@@ -429,3 +415,18 @@ unsigned char *silc_rng_get_rn_string(SilcRng rng, unsigned int len)
 
   return string;
 }
+
+/* Returns random number binary data. */
+
+unsigned char *silc_rng_get_rn_data(SilcRng rng, unsigned int len)
+{
+  int i;
+  unsigned char *data;
+
+  data = silc_calloc(len + 1, sizeof(*data));
+
+  for (i = 0; i < len; i++)
+    data[i] = silc_rng_get_byte(rng);
+
+  return data;
+}