Commit 24b0713a authored by Niels Möller's avatar Niels Möller
Browse files

Deleted all classes but randomness. New method


Rev: src/randomness.h:1.14
parent 05031382
......@@ -30,6 +30,26 @@
#include "exception.h"
enum random_source_type
/* Trivial data such as timing info and pids. */
/* Remote end padding. */
/* Data occasionally read from /dev/random or similar. */
/* Data that is secret but not terribly random, such as user
* passwords or private keys. */
/* For reread seed files. */
/* Randomness that is for "pad only" should be used only for iv:s and
* random padding. */
enum randomness_quality { RANDOM_GOOD, RANDOM_PAD_ONLY };
#include "randomness.h.x"
......@@ -38,60 +58,30 @@
(name randomness)
(quality . int)
(random method void "UINT32 length" "UINT8 *dst")))
#define RANDOM(r, length, dst) ((r)->random((r), length, dst))
/* A class polling the environment for randomness. Following Peter
* Gutmann's ideas, there are two methods for a slow more thorough
* poll done at startup, and a faster poll performed from time to time
* as a generator is used. */
/* GABA:
(name random_poll)
; Both functions return an entropy estimate, and adds the
; randomness to the given hash instance.
(slow method unsigned "struct hash_instance *")
(fast method unsigned "struct hash_instance *")
(background method void)))
(quality . "enum randomness_quality")
(random method void "UINT32 length" "UINT8 *dst")
; To be used only for SOURCE_REMOTE and SOURCE_SECRET
(add method void "enum random_source_type"
"UINT32 length" "const UINT8 *data")))
#define RANDOM_POLL_SLOW(p, h) ((p)->slow((p), (h)))
#define RANDOM_POLL_FAST(p, h) ((p)->fast((p), (h)))
#define RANDOM_POLL_BACKGROUND(p) ((p)->background((p)))
/* GABA:
(name randomness_with_poll)
(super randomness)
; Object that gets randomness from the environment
(poller object random_poll)))
/* Consumes the init string (which may be NULL). */
struct randomness *make_poor_random(struct hash_algorithm *hash,
struct lsh_string *init);
struct randomness *make_bad_random(void);
#define RANDOM(r, length, dst) ((r)->random((r), (length), (dst)))
#define RANDOM_ADD(r, t, length, data) ((r)->add((r), (t), (length), (dst)))
struct randomness *make_device_random(const char *device);
struct randomness *make_reasonably_random(void);
/* This is not really a constructor, as the randomness collector uses
* global state. */
struct randomness *
random_init(struct lsh_string *seed_file_name);
struct randomness_with_poll *
make_arcfour_random(struct random_poll *poller,
struct hash_algorithm *hash,
struct exception_handler *e);
/* Creates a more efficient but less secure generator by buffering
* another generator. */
struct randomness *
make_buffered_random(struct randomness *);
struct randomness_with_poll *
make_default_random(struct reap *reaper,
struct exception_handler *e);
struct randomness *
make_user_random(const char *home);
struct random_poll *
make_unix_random(struct reap *reaper);
struct randomness *
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment