diff options
author | tjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2007-02-16 23:50:37 +0000 |
---|---|---|
committer | tjw <tjw@edf5b092-35ff-0310-97b2-ce42778d08ea> | 2007-02-16 23:50:37 +0000 |
commit | 9dbe35a4dd8d5fce96c627f000d15395f32bc55a (patch) | |
tree | 3bc0f6b9f85125a426cdc2a290237adc76b1c699 /code/win32 | |
parent | 9a51af746dd98abd8ca52424a4b78a16e3d98b7b (diff) | |
download | ioquake3-aero-9dbe35a4dd8d5fce96c627f000d15395f32bc55a.tar.gz ioquake3-aero-9dbe35a4dd8d5fce96c627f000d15395f32bc55a.zip |
* (bug 3019) use the operating system's random number generator if possible
when generating the qkey file
git-svn-id: svn://svn.icculus.org/quake3/trunk@1046 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/win32')
-rw-r--r-- | code/win32/win_shared.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/code/win32/win_shared.c b/code/win32/win_shared.c index f28ff3a..24e3079 100644 --- a/code/win32/win_shared.c +++ b/code/win32/win_shared.c @@ -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; +} + /* ** |