* (bug 3019) use the operating system's random number generator if possible

when generating the qkey file
This commit is contained in:
Tony J. White = 2007-02-16 23:50:37 +00:00
parent 8801b06a1e
commit c6249fcc25
7 changed files with 65 additions and 9 deletions

View file

@ -32,6 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <direct.h>
#include <io.h>
#include <conio.h>
#include <wincrypt.h>
/*
================
@ -81,6 +82,24 @@ void Sys_SnapVector( float *v )
}
#endif
qboolean Sys_RandomBytes( byte *string, int len )
{
HCRYPTPROV prov;
if( !CryptAcquireContext( &prov, NULL, NULL,
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT ) ) {
return qfalse;
}
if( !CryptGenRandom( prov, len, (BYTE *)string ) ) {
CryptReleaseContext( prov, 0 );
return qfalse;
}
CryptReleaseContext( prov, 0 );
return qtrue;
}
/*
**