aboutsummaryrefslogtreecommitdiffstats
path: root/code/win32
diff options
context:
space:
mode:
Diffstat (limited to 'code/win32')
-rw-r--r--code/win32/win_shared.c19
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;
+}
+
/*
**