monotone

monotone Mtn Source Tree

Root/botan/rng.cpp

1/*************************************************
2* Global RNG Source File *
3* (C) 1999-2007 The Botan Project *
4*************************************************/
5
6#include <botan/rng.h>
7#include <botan/libstate.h>
8
9namespace Botan {
10
11namespace Global_RNG {
12
13/*************************************************
14* Get random bits from the global RNG *
15*************************************************/
16void randomize(byte output[], u32bit size)
17 {
18 global_state().randomize(output, size);
19 }
20
21/*************************************************
22* Get random bits from the global RNG *
23*************************************************/
24byte random()
25 {
26 byte ret = 0;
27 randomize(&ret, 1);
28 return ret;
29 }
30
31/*************************************************
32* Add entropy to the global RNG *
33*************************************************/
34void add_entropy(const byte entropy[], u32bit size)
35 {
36 global_state().add_entropy(entropy, size);
37 }
38
39/*************************************************
40* Add entropy to the global RNG *
41*************************************************/
42void add_entropy(EntropySource& src, bool slow_poll)
43 {
44 global_state().add_entropy(src, slow_poll);
45 }
46
47/*************************************************
48* Add an EntropySource to the RNG seed list *
49*************************************************/
50void add_es(EntropySource* src, bool last)
51 {
52 global_state().add_entropy_source(src, last);
53 }
54
55/*************************************************
56* Seed the global RNG *
57*************************************************/
58u32bit seed(bool slow_poll, u32bit bits_to_get)
59 {
60 return global_state().seed_prng(slow_poll, bits_to_get);
61 }
62
63}
64
65}

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status