apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mladen Turk" <mt...@mappingsoft.com>
Subject [PATCH] apr_generate_random_bytes - WIN32
Date Mon, 29 Oct 2001 18:45:50 GMT
Hi,

The WIN-XP does not starts the cryptographic service provider (CSP) by
default (at least on my installation).
I think they move that out to boot faster.
Well, anyhow, the patch tries to create the new key container with the
default name if the CSP was not started allready.

Interesting is that the call takes couple of seconds to finish when called
for the first time.

MT.

Index: rand.c
===================================================================
RCS file: /home/cvspublic/apr/misc/win32/rand.c,v
retrieving revision 1.10
diff -u -r1.10 rand.c
--- rand.c	2001/02/16 04:15:58	1.10
+++ rand.c	2001/10/29 18:21:38
@@ -63,7 +63,11 @@
     apr_status_t res = APR_SUCCESS;

     if (!CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,0)) {
-	return apr_get_os_error();
+        /* Try to create the new key container */
+        if (CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,
+                                CRYPT_NEWKEYSET)) {
+        	return apr_get_os_error();
+        }
     }
     if (!CryptGenRandom(hProv,length,buf)) {
     	res = apr_get_os_error();



Mime
View raw message