]> git.sur5r.net Git - openldap/commitdiff
Port to NT.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 27 Oct 1999 04:41:38 +0000 (04:41 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 27 Oct 1999 04:41:38 +0000 (04:41 +0000)
include/portable.nt
libraries/liblutil/entropy.c
libraries/liblutil/liblutil.dsp

index af077ef6f25a9d72376f92f614d462ff30ed4a60..e358c26848c63eca8273dd6b93429ef1d65deb19 100644 (file)
@@ -94,6 +94,9 @@ typedef char * caddr_t;
 /* we have <process.h> */
 #define HAVE_PROCESS_H 1
 
+/* we have <wincrypt.h> */
+#define HAVE_WINCRYPT_H 1
+
 #define LDAP_SIGUSR1   SIGILL
 #define LDAP_SIGUSR2   SIGTERM
 
index c372efab1009c3ae208226363b5d409658bed7a9..07b4c83b5f9e8092e732108a497ed0115d70bc2f 100644 (file)
@@ -6,6 +6,16 @@
 
 #include "portable.h"
 
+#include <ac/string.h>
+#include <ac/time.h>
+
+#ifdef HAVE_WINCRYPT_H
+#include <wincrypt.h>
+#endif
+#ifdef HAVE_PROCESS_H
+#include <process.h>
+#endif
+
 #include <fcntl.h>
 
 #include <lutil.h>
@@ -35,6 +45,26 @@ int lutil_entropy( char *buf, int nbytes )
                /* should return nbytes */
                if( rc < nbytes ) return -1;
 
+               return 0;
+       }
+#elif PROV_RSA_FULL
+       {
+               /* Not used since _WIN32_WINNT not set... */
+               HCRYPTPROV hProv = 0;
+
+               /* Get handle to user default provider */
+               if(!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0)) {
+                  return -1;
+               }
+
+               /* Generate random initialization vector */
+               if(!CryptGenRandom(hProv, (DWORD) nbytes, (BYTE *) buf)) {
+                  return -1;
+               }
+
+               /* Release provider handle */
+               if(hProv != 0) CryptReleaseContext(hProv, 0);
+
                return 0;
        }
 #else
index 54800a3eca9624342415670af3cfa653dab405a3..af200def70f1ae47400385d70913d50e1ba4acd9 100644 (file)
@@ -136,6 +136,10 @@ SOURCE=.\debug.c
 # End Source File
 # Begin Source File
 
+SOURCE=.\entropy.c
+# End Source File
+# Begin Source File
+
 SOURCE="..\..\include\getopt-compat.h"
 # End Source File
 # Begin Source File