00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _MTPRNG_H
00029 #define _MTPRNG_H
00030
00031 #include "beecrypt.h"
00032
00033 #if WIN32
00034 # include <windows.h>
00035 # include <winbase.h>
00036 #else
00037 # if HAVE_THREAD_H && HAVE_SYNCH_H
00038 # include <synch.h>
00039 # elif HAVE_PTHREAD_H
00040 # include <pthread.h>
00041 # else
00042 # error need locking mechanism
00043 # endif
00044 #endif
00045
00046 #define N 624
00047 #define M 397
00048 #define K 0x9908B0DF
00049
00052 typedef struct
00053 {
00054 #ifdef _REENTRANT
00055 # if WIN32
00056 HANDLE lock;
00057 # else
00058 # if HAVE_THREAD_H && HAVE_SYNCH_H
00059 mutex_t lock;
00060 # elif HAVE_PTHREAD_H
00061 pthread_mutex_t lock;
00062 # else
00063 # error need locking mechanism
00064 # endif
00065 # endif
00066 #endif
00067 uint32 state[N+1];
00068 uint32 left;
00069 uint32* nextw;
00070 } mtprngParam;
00071
00072 #ifdef __cplusplus
00073 extern "C" {
00074 #endif
00075
00078
00079 extern BEECRYPTAPI const randomGenerator mtprng;
00080
00083
00084 BEECRYPTAPI
00085 int mtprngSetup (mtprngParam* mp)
00086 ;
00087
00088
00091
00092 BEECRYPTAPI
00093 int mtprngSeed (mtprngParam* mp, const uint32* data, int size)
00094 ;
00095
00096
00099
00100 BEECRYPTAPI
00101 int mtprngNext (mtprngParam* mp, uint32* data, int size)
00102 ;
00103
00104
00107
00108 BEECRYPTAPI
00109 int mtprngCleanup(mtprngParam* mp)
00110 ;
00111
00112
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116
00117 #endif