00001 /* 00002 * Copyright (c) 1998, 1999, 2000, 2003 X-Way Rights BV 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 */ 00019 00026 #ifndef _MTPRNG_H 00027 #define _MTPRNG_H 00028 00029 #include "beecrypt/beecrypt.h" 00030 00031 #ifdef _REENTRANT 00032 # if WIN32 00033 # include <windows.h> 00034 # include <winbase.h> 00035 # endif 00036 #endif 00037 00038 #define N 624 00039 #define M 397 00040 #define K 0x9908B0DFU 00041 00042 /* 00043 */ 00044 #ifdef __cplusplus 00045 struct BEECRYPTAPI mtprngParam 00046 #else 00047 struct _mtprngParam 00048 #endif 00049 { 00050 #ifdef _REENTRANT 00051 bc_mutex_t lock; 00052 #endif 00053 uint32_t state[N+1]; 00054 uint32_t left; 00055 uint32_t* nextw; 00056 }; 00057 00058 #ifndef __cplusplus 00059 typedef struct _mtprngParam mtprngParam; 00060 #endif 00061 00062 #ifdef __cplusplus 00063 extern "C" { 00064 #endif 00065 00066 /* 00067 */ 00068 extern BEECRYPTAPI const randomGenerator mtprng; 00069 00070 /* 00071 */ 00072 BEECRYPTAPI 00073 int mtprngSetup (mtprngParam* mp); 00074 00075 /* 00076 */ 00077 BEECRYPTAPI 00078 int mtprngSeed (mtprngParam* mp, const byte* data, size_t size); 00079 00080 /* 00081 */ 00082 BEECRYPTAPI 00083 int mtprngNext (mtprngParam* mp, byte* data, size_t size); 00084 00085 /* 00086 */ 00087 BEECRYPTAPI 00088 int mtprngCleanup(mtprngParam* mp); 00089 00090 #ifdef __cplusplus 00091 } 00092 #endif 00093 00094 #endif