base/asm-common.h (x86), and knock-on: Add macros for full-size regs.
[catacomb] / rand / rand.h
index 3c2fa73..5584c54 100644 (file)
@@ -99,8 +99,9 @@
 
 typedef struct rand_pool {
   octet pool[RAND_POOLSZ];             /* Actual contents of the pool */
-  unsigned i;                          /* Current index into pool */
-  unsigned irot;                       /* Current rotation applied */
+  unsigned gen;                                /* Generation number */
+  unsigned short i;                    /* Current index into pool */
+  unsigned short irot;                 /* Current rotation applied */
   unsigned ibits;                      /* Number of good bits in pool */
   octet buf[RAND_BUFSZ];               /* Random octet output buffer */
   unsigned o;                          /* Current index into buffer */
@@ -132,6 +133,20 @@ typedef struct rand_source {
 
 extern void rand_init(rand_pool */*r*/);
 
+/* --- @rand_generation@ --- *
+ *
+ * Arguments:  ---
+ *
+ * Returns:    A nonzero generation number.
+ *
+ * Use:                Returns a generation number for the current process.  Each
+ *             pool has its own number.  If this matches the process number
+ *             then all is well.  If it doesn't match, then the pool needs
+ *             to be cleaned before its next use.
+ */
+
+extern unsigned rand_generation(void);
+
 /* --- @rand_noisesrc@ --- *
  *
  * Arguments:  @rand_pool *r@ = pointer to a randomness pool
@@ -180,6 +195,19 @@ extern void rand_seed(rand_pool */*r*/, unsigned /*bits*/);
 
 extern void rand_key(rand_pool */*r*/, const void */*k*/, size_t /*sz*/);
 
+/* --- @rand_quick@ --- *
+ *
+ * Arguments:  @rand_pool *r@ = pointer to a randomness pool
+ *
+ * Returns:    Zero on success; @-1@ on failure.
+ *
+ * Use         Attempts to use some machine-specific `quick' source of
+ *             entropy to top up @r@.  This may not do anything at all on
+ *             many systems.
+ */
+
+extern int rand_quick(rand_pool */*r*/);
+
 /* --- @rand_add@ --- *
  *
  * Arguments:  @rand_pool *r@ = pointer to a randomness pool