* (bug 3019) use the operating system's random number generator if possible
when generating the qkey file
This commit is contained in:
parent
8801b06a1e
commit
c6249fcc25
7 changed files with 65 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue