diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/aesGladman/prng.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/aesGladman/prng.h | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/prng.h b/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/prng.h index a81ed8e..b92c899 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/prng.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/prng.h | |||
@@ -1,74 +1,74 @@ | |||
1 | /* | 1 | /* |
2 | --------------------------------------------------------------------------- | 2 | --------------------------------------------------------------------------- |
3 | Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. | 3 | Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. |
4 | All rights reserved. | 4 | All rights reserved. |
5 | 5 | ||
6 | LICENSE TERMS | 6 | LICENSE TERMS |
7 | 7 | ||
8 | The free distribution and use of this software in both source and binary | 8 | The free distribution and use of this software in both source and binary |
9 | form is allowed (with or without changes) provided that: | 9 | form is allowed (with or without changes) provided that: |
10 | 10 | ||
11 | 1. distributions of this source code include the above copyright | 11 | 1. distributions of this source code include the above copyright |
12 | notice, this list of conditions and the following disclaimer; | 12 | notice, this list of conditions and the following disclaimer; |
13 | 13 | ||
14 | 2. distributions in binary form include the above copyright | 14 | 2. distributions in binary form include the above copyright |
15 | notice, this list of conditions and the following disclaimer | 15 | notice, this list of conditions and the following disclaimer |
16 | in the documentation and/or other associated materials; | 16 | in the documentation and/or other associated materials; |
17 | 17 | ||
18 | 3. the copyright holder's name is not used to endorse products | 18 | 3. the copyright holder's name is not used to endorse products |
19 | built using this software without specific written permission. | 19 | built using this software without specific written permission. |
20 | 20 | ||
21 | ALTERNATIVELY, provided that this notice is retained in full, this product | 21 | ALTERNATIVELY, provided that this notice is retained in full, this product |
22 | may be distributed under the terms of the GNU General Public License (GPL), | 22 | may be distributed under the terms of the GNU General Public License (GPL), |
23 | in which case the provisions of the GPL apply INSTEAD OF those given above. | 23 | in which case the provisions of the GPL apply INSTEAD OF those given above. |
24 | 24 | ||
25 | DISCLAIMER | 25 | DISCLAIMER |
26 | 26 | ||
27 | This software is provided 'as is' with no explicit or implied warranties | 27 | This software is provided 'as is' with no explicit or implied warranties |
28 | in respect of its properties, including, but not limited to, correctness | 28 | in respect of its properties, including, but not limited to, correctness |
29 | and/or fitness for purpose. | 29 | and/or fitness for purpose. |
30 | --------------------------------------------------------------------------- | 30 | --------------------------------------------------------------------------- |
31 | Issue Date: 24/01/2003 | 31 | Issue Date: 24/01/2003 |
32 | 32 | ||
33 | This is the header file for an implementation of a random data pool based on | 33 | This is the header file for an implementation of a random data pool based on |
34 | the use of an external entropy function (inspired by Peter Gutmann's work). | 34 | the use of an external entropy function (inspired by Peter Gutmann's work). |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #ifndef _PRNG_H | 37 | #ifndef _PRNG_H |
38 | #define _PRNG_H | 38 | #define _PRNG_H |
39 | 39 | ||
40 | #include "sha1.h" | 40 | #include "sha1.h" |
41 | 41 | ||
42 | #define PRNG_POOL_LEN 256 /* minimum random pool size */ | 42 | #define PRNG_POOL_LEN 256 /* minimum random pool size */ |
43 | #define PRNG_MIN_MIX 20 /* min initial pool mixing iterations */ | 43 | #define PRNG_MIN_MIX 20 /* min initial pool mixing iterations */ |
44 | 44 | ||
45 | /* ensure that pool length is a multiple of the SHA1 digest size */ | 45 | /* ensure that pool length is a multiple of the SHA1 digest size */ |
46 | 46 | ||
47 | #define PRNG_POOL_SIZE (SHA1_DIGEST_SIZE * (1 + (PRNG_POOL_LEN - 1) / SHA1_DIGEST_SIZE)) | 47 | #define PRNG_POOL_SIZE (SHA1_DIGEST_SIZE * (1 + (PRNG_POOL_LEN - 1) / SHA1_DIGEST_SIZE)) |
48 | 48 | ||
49 | /* A function for providing entropy is a parameter in the prng_init() */ | 49 | /* A function for providing entropy is a parameter in the prng_init() */ |
50 | /* call. This function has the following form and returns a maximum */ | 50 | /* call. This function has the following form and returns a maximum */ |
51 | /* of 'len' bytes of pseudo random data in the buffer 'buf'. It can */ | 51 | /* of 'len' bytes of pseudo random data in the buffer 'buf'. It can */ |
52 | /* return less than 'len' bytes but will be repeatedly called for more */ | 52 | /* return less than 'len' bytes but will be repeatedly called for more */ |
53 | /* data in this case. */ | 53 | /* data in this case. */ |
54 | 54 | ||
55 | typedef int (*prng_entropy_fn)(unsigned char buf[], unsigned int len); | 55 | typedef int (*prng_entropy_fn)(unsigned char buf[], unsigned int len); |
56 | 56 | ||
57 | typedef struct | 57 | typedef struct |
58 | { unsigned char rbuf[PRNG_POOL_SIZE]; /* the random pool */ | 58 | { unsigned char rbuf[PRNG_POOL_SIZE]; /* the random pool */ |
59 | unsigned char obuf[PRNG_POOL_SIZE]; /* pool output buffer */ | 59 | unsigned char obuf[PRNG_POOL_SIZE]; /* pool output buffer */ |
60 | unsigned int pos; /* output buffer position */ | 60 | unsigned int pos; /* output buffer position */ |
61 | prng_entropy_fn entropy; /* entropy function pointer */ | 61 | prng_entropy_fn entropy; /* entropy function pointer */ |
62 | } prng_ctx; | 62 | } prng_ctx; |
63 | 63 | ||
64 | /* initialise the random stream generator */ | 64 | /* initialise the random stream generator */ |
65 | void prng_init(prng_entropy_fn fun, prng_ctx ctx[1]); | 65 | void prng_init(prng_entropy_fn fun, prng_ctx ctx[1]); |
66 | 66 | ||
67 | /* obtain random bytes from the generator */ | 67 | /* obtain random bytes from the generator */ |
68 | void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1]); | 68 | void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1]); |
69 | 69 | ||
70 | /* close the random stream generator */ | 70 | /* close the random stream generator */ |
71 | void prng_end(prng_ctx ctx[1]); | 71 | void prng_end(prng_ctx ctx[1]); |
72 | 72 | ||
73 | #endif | 73 | #endif |
74 | 74 | ||