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
This commit is contained in:
Родитель
0c23ec232b
Коммит
f8f2188888
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -113,6 +113,8 @@ int Curl_schannel_init(void);
|
|||
void Curl_schannel_cleanup(void);
|
||||
size_t Curl_schannel_version(char *buffer, size_t size);
|
||||
|
||||
int Curl_schannel_random(unsigned char *entropy, size_t length);
|
||||
|
||||
/* API setup for Schannel */
|
||||
#define curlssl_init Curl_schannel_init
|
||||
#define curlssl_cleanup Curl_schannel_cleanup
|
||||
|
@ -129,5 +131,6 @@ size_t Curl_schannel_version(char *buffer, size_t size);
|
|||
#define curlssl_check_cxn(x) (x=x, -1)
|
||||
#define curlssl_data_pending Curl_schannel_data_pending
|
||||
#define CURL_SSL_BACKEND CURLSSLBACKEND_SCHANNEL
|
||||
#define curlssl_random(x,y,z) Curl_schannel_random(y,z)
|
||||
#endif /* USE_SCHANNEL */
|
||||
#endif /* HEADER_CURL_SCHANNEL_H */
|
||||
|
|
Загрузка…
Ссылка в новой задаче