Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

beecrypt/mtprng.h

Go to the documentation of this file.
00001 
00007 /*
00008  * Copyright (c) 1998, 1999, 2000 Virtual Unlimited B.V.
00009  *
00010  * Author: Bob Deblier <bob@virtualunlimited.com>
00011  *
00012  * This library is free software; you can redistribute it and/or
00013  * modify it under the terms of the GNU Lesser General Public
00014  * License as published by the Free Software Foundation; either
00015  * version 2.1 of the License, or (at your option) any later version.
00016  *
00017  * This library is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  * Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this library; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 /*@kept@*/ uint32*      nextw;
00070 } mtprngParam;
00071 
00072 #ifdef __cplusplus
00073 extern "C" {
00074 #endif
00075 
00078 /*@observer@*/ /*@checked@*/
00079 extern BEECRYPTAPI const randomGenerator mtprng;
00080 
00083 /*@-exportlocal@*/
00084 BEECRYPTAPI
00085 int mtprngSetup  (mtprngParam* mp)
00086         /*@modifies mp @*/;
00087 /*@=exportlocal@*/
00088 
00091 /*@-exportlocal@*/
00092 BEECRYPTAPI
00093 int mtprngSeed   (mtprngParam* mp, const uint32* data, int size)
00094         /*@modifies mp @*/;
00095 /*@=exportlocal@*/
00096 
00099 /*@-exportlocal@*/
00100 BEECRYPTAPI
00101 int mtprngNext   (mtprngParam* mp, uint32* data, int size)
00102         /*@modifies mp, data @*/;
00103 /*@=exportlocal@*/
00104 
00107 /*@-exportlocal@*/
00108 BEECRYPTAPI
00109 int mtprngCleanup(mtprngParam* mp)
00110         /*@modifies mp @*/;
00111 /*@=exportlocal@*/
00112 
00113 #ifdef __cplusplus
00114 }
00115 #endif
00116 
00117 #endif

Generated on Tue Sep 17 15:56:37 2002 for rpm by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002