Browse Source

win32 sys_arch: fix sys_win_rand_init() if the crypt context does not exist yet

master
goldsimon 9 years ago
parent
commit
1c91c1aa74
  1. 10
      ports/win32/sys_arch.c

10
ports/win32/sys_arch.c

@ -69,7 +69,15 @@ u32_t sys_win_rand(void)
static void sys_win_rand_init(void)
{
if(!CryptAcquireContext(&hcrypt, NULL, NULL, PROV_RSA_FULL, 0)) {
LWIP_ASSERT("CryptAcquireContext failed", 0);
DWORD err = GetLastError();
LWIP_PLATFORM_DIAG(("CryptAcquireContext failed with error %d, trying to create NEWKEYSET", (int)err));
if(!CryptAcquireContext(&hcrypt, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
DWORD err = GetLastError();
char errbuf[128];
snprintf(errbuf, sizeof(errbuf), "CryptAcquireContext failed with error %d", (int)err);
LWIP_UNUSED_ARG(err);
LWIP_ASSERT(errbuf, 0);
}
}
}

Loading…
Cancel
Save