BeeCrypt  4.2.1
mtprng.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1998, 1999, 2000, 2003 X-Way Rights BV
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
26 #ifndef _MTPRNG_H
27 #define _MTPRNG_H
28 
29 #include "beecrypt/beecrypt.h"
30 
31 #ifdef _REENTRANT
32 # if WIN32
33 # include <windows.h>
34 # include <winbase.h>
35 # endif
36 #endif
37 
38 #define N 624
39 #define M 397
40 #define K 0x9908B0DFU
41 
42 /*
43  */
44 #ifdef __cplusplus
46 #else
47 struct _mtprngParam
48 #endif
49 {
50  #ifdef _REENTRANT
51  bc_mutex_t lock;
52  #endif
53  uint32_t state[N+1];
54  uint32_t left;
55  uint32_t* nextw;
56 };
57 
58 #ifndef __cplusplus
59 typedef struct _mtprngParam mtprngParam;
60 #endif
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 /*
67  */
69 
70 /*
71  */
73 int mtprngSetup (mtprngParam* mp);
74 
75 /*
76  */
78 int mtprngSeed (mtprngParam* mp, const byte* data, size_t size);
79 
80 /*
81  */
83 int mtprngNext (mtprngParam* mp, byte* data, size_t size);
84 
85 /*
86  */
88 int mtprngCleanup(mtprngParam* mp);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif