diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2002-05-29 22:07:58 +0000 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2002-05-29 22:07:58 +0000 |
commit | e07273f5b0140d1bf07a3a4d7549791744a74f88 (patch) | |
tree | c2666fc1ca9d3da8c271c8233b9502acc97b2151 /misc/win32 | |
parent | 8419dd91db3484a496a619a1fa517b5c7d3c2718 (diff) | |
download | apr-e07273f5b0140d1bf07a3a4d7549791744a74f88.tar.gz |
Fix apr_generate_random_bytes() for Win32 on Win NT or 9x by
dropping the 0x40 bit (CRYPT_SILENT) for earlier OS'es.
Thanks for nagging Mr. Trawick :)
PR: 9286
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@63441 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc/win32')
-rw-r--r-- | misc/win32/rand.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/misc/win32/rand.c b/misc/win32/rand.c index 3bf8c31ca..ca55caeba 100644 --- a/misc/win32/rand.c +++ b/misc/win32/rand.c @@ -54,6 +54,7 @@ #include "apr_private.h" #include "apr_general.h" +#include "misc.h" #include <wincrypt.h> APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, @@ -63,9 +64,12 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf, apr_status_t res = APR_SUCCESS; /* 0x40 bit = CRYPT_SILENT, only introduced in more recent PSDKs + * and will only work for Win2K and later. */ - if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT | 0x40)) { + DWORD flags = CRYPT_VERIFYCONTEXT + | ((apr_os_level >= APR_WIN_2000) ? 0x40 : 0); + + if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, flags)) { return apr_get_os_error(); } if (!CryptGenRandom(hProv, length, buf)) { |