New source file added to maintain a randomness pool.
[become] / src / rand.h
diff --git a/src/rand.h b/src/rand.h
new file mode 100644 (file)
index 0000000..bbd0fff
--- /dev/null
@@ -0,0 +1,141 @@
+/* -*-c-*-
+ *
+ * $Id: rand.h,v 1.1 1997/08/07 09:46:05 mdw Exp $
+ *
+ * Random number generation
+ *
+ * (c) 1997 EBI
+ */
+
+/*----- Licencing notice --------------------------------------------------*
+ *
+ * This file is part of Become.
+ *
+ * Become is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Become is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Become; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/*----- Revision history --------------------------------------------------*
+ *
+ * $Log: rand.h,v $
+ * Revision 1.1  1997/08/07 09:46:05  mdw
+ * New source file added to maintain a randomness pool.
+ *
+ */
+
+#ifndef RAND_H
+#define RAND_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Required headers --------------------------------------------------*/
+
+#include <stdio.h>
+
+#ifndef ICRYPT_H
+#  include "icrypt.h"
+#endif
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @rand_read@ --- *
+ *
+ * Arguments:  @FILE *fp@ = pointer to file to read from
+ *
+ * Returns:    ---
+ *
+ * Use:                Reads a random number seed from the stream.
+ */
+
+extern void rand_read(FILE */*fp*/);
+
+/* --- @rand_write@ --- *
+ *
+ * Arguments:  @FILE *fp@ = pointer to file to write on
+ *
+ * Returns:    ---
+ *
+ * Use:                Writes a random number seed back to the stream.
+ */
+
+extern void rand_write(FILE */*fp*/);
+
+/* --- @rand_clear@ --- *
+ *
+ * Arguments:  ---
+ *
+ * Returns:    ---
+ *
+ * Use:                Clears the random number pool.
+ */
+
+extern void rand_clear(void);
+
+/* --- @rand_encrypt@ --- *
+ *
+ * Arguments:  @icrypt_job *j@ = pointer to an encryption job to apply
+ *
+ * Returns:    ---
+ *
+ * Use:                Encrypts the randomness pool with a given key.  This should
+ *             be done before use, in case the pool gets compromised.
+ */
+
+extern void rand_encrypt(icrypt_job */*j*/);
+
+/* --- @rand_add@ --- *
+ *
+ * Arguments:  @const void *p@ = pointer to some data
+ *             @size_t sz@ = size of the data in bytes
+ *
+ * Returns:    ---
+ *
+ * Use:                Adds entropy to the pool.
+ */
+
+extern void rand_add(const void */*p*/, size_t /*sz*/);
+
+/* --- @rand_extract@ --- *
+ *
+ * Arguments:  @unsigned char *b@ = pointer to output buffer
+ *             @size_t sz@ = number of bytes wanted
+ *
+ * Returns:    ---
+ *
+ * Use:                Produces a number of random bytes.
+ */
+
+extern void rand_extract(unsigned char */*b*/, size_t /*sz*/);
+
+/* --- @rand_churn@ --- *
+ *
+ * Arguments:  ---
+ *
+ * Returns:    ---
+ *
+ * Use:                Churns the randomness pool completely.  The pool is replaced
+ *             by repeated MD5-ings of itself.
+ */
+
+extern void rand_churn(void);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif