[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22565 - libmicrohttpd/src/testcurl
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22565 - libmicrohttpd/src/testcurl |
Date: |
Mon, 9 Jul 2012 13:43:14 +0200 |
Author: grothoff
Date: 2012-07-09 13:43:14 +0200 (Mon, 09 Jul 2012)
New Revision: 22565
Modified:
libmicrohttpd/src/testcurl/daemontest_digestauth.c
libmicrohttpd/src/testcurl/daemontest_digestauth_with_arguments.c
Log:
-LRN: use cryptoapi for PRNG on W32
Modified: libmicrohttpd/src/testcurl/daemontest_digestauth.c
===================================================================
--- libmicrohttpd/src/testcurl/daemontest_digestauth.c 2012-07-09 11:42:47 UTC
(rev 22564)
+++ libmicrohttpd/src/testcurl/daemontest_digestauth.c 2012-07-09 11:43:14 UTC
(rev 22565)
@@ -35,6 +35,8 @@
#ifndef WINDOWS
#include <sys/socket.h>
#include <unistd.h>
+#else
+#include <wincrypt.h>
#endif
#define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>Access
granted</body></html>"
@@ -135,6 +137,7 @@
cbc.buf = buf;
cbc.size = 2048;
cbc.pos = 0;
+#if !WINDOWS
fd = open("/dev/urandom", O_RDONLY);
if (-1 == fd)
{
@@ -157,6 +160,28 @@
off += len;
}
(void) close(fd);
+#else
+ {
+ HCRYPTPROV cc;
+ BOOL b;
+ b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
+ if (b == 0)
+ {
+ fprintf (stderr, "Failed to acquire crypto provider context: %lu\n",
+ GetLastError ());
+ return 1;
+ }
+ b = CryptGenRandom (cc, 8, rnd);
+ if (b == 0)
+ {
+ fprintf (stderr, "Failed to generate 8 random bytes: %lu\n",
+ GetLastError ());
+ }
+ CryptReleaseContext (cc, 0);
+ if (b == 0)
+ return 1;
+ }
+#endif
d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
1337, NULL, NULL, &ahc_echo, PAGE,
MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
Modified: libmicrohttpd/src/testcurl/daemontest_digestauth_with_arguments.c
===================================================================
--- libmicrohttpd/src/testcurl/daemontest_digestauth_with_arguments.c
2012-07-09 11:42:47 UTC (rev 22564)
+++ libmicrohttpd/src/testcurl/daemontest_digestauth_with_arguments.c
2012-07-09 11:43:14 UTC (rev 22565)
@@ -35,6 +35,8 @@
#ifndef WINDOWS
#include <sys/socket.h>
#include <unistd.h>
+#else
+#include <wincrypt.h>
#endif
#define PAGE "<html><head><title>libmicrohttpd demo</title></head><body>Access
granted</body></html>"
@@ -135,6 +137,7 @@
cbc.buf = buf;
cbc.size = 2048;
cbc.pos = 0;
+#if !WINDOWS
fd = open("/dev/urandom", O_RDONLY);
if (-1 == fd)
{
@@ -157,6 +160,28 @@
off += len;
}
(void) close(fd);
+#else
+ {
+ HCRYPTPROV cc;
+ BOOL b;
+ b = CryptAcquireContext (&cc, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT);
+ if (b == 0)
+ {
+ fprintf (stderr, "Failed to acquire crypto provider context: %lu\n",
+ GetLastError ());
+ return 1;
+ }
+ b = CryptGenRandom (cc, 8, rnd);
+ if (b == 0)
+ {
+ fprintf (stderr, "Failed to generate 8 random bytes: %lu\n",
+ GetLastError ());
+ }
+ CryptReleaseContext (cc, 0);
+ if (b == 0)
+ return 1;
+ }
+#endif
d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
1337, NULL, NULL, &ahc_echo, PAGE,
MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22565 - libmicrohttpd/src/testcurl,
gnunet <=