aboutsummaryrefslogtreecommitdiff
path: root/lib/vtls/curl_schannel.c
diff options
context:
space:
mode:
authorMarcel Raad <raad@teamviewer.com>2014-07-31 12:59:46 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-07-31 13:10:54 +0200
commitf8f2188888abba00983c267ead82150b3a9dfa3e (patch)
tree1dc82ef30620390ffb31c4aed41f6d8692adb81e /lib/vtls/curl_schannel.c
parent0c23ec232bcbfd69c0eb048d2e47e2e1d66cd999 (diff)
schannel: use CryptGenRandom for random numbers
This function is available for every Windows version since Windows 95/NT. reference: http://msdn.microsoft.com/en-us/library/windows/desktop/aa379942.aspx
Diffstat (limited to 'lib/vtls/curl_schannel.c')
-rw-r--r--lib/vtls/curl_schannel.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/vtls/curl_schannel.c b/lib/vtls/curl_schannel.c
index 64e79e141..e4e595eaa 100644
--- a/lib/vtls/curl_schannel.c
+++ b/lib/vtls/curl_schannel.c
@@ -1215,6 +1215,23 @@ size_t Curl_schannel_version(char *buffer, size_t size)
return size;
}
+int Curl_schannel_random(unsigned char *entropy, size_t length)
+{
+ HCRYPTPROV hCryptProv = 0;
+
+ if(!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
+ return 1;
+
+ if(!CryptGenRandom(hCryptProv, (DWORD)length, entropy)) {
+ CryptReleaseContext(hCryptProv, 0UL);
+ return 1;
+ }
+
+ CryptReleaseContext(hCryptProv, 0UL);
+ return 0;
+}
+
#ifdef _WIN32_WCE
static CURLcode verify_certificate(struct connectdata *conn, int sockindex)
{