+#else
+ int error = 0;
+ HCRYPTPROV crypt_prov = 0;
+ LPVOID msg_buf;
+
+ CryptAcquireContext(&crypt_prov, NULL, NULL,
+ PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
+ if (!CryptGenRandom(crypt_prov, n, buffer)) {
+ error = EINVAL;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
+ | FORMAT_MESSAGE_FROM_SYSTEM
+ | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ 0,
+ (LPTSTR)&msg_buf,
+ 0,
+ NULL
+ );
+ VLOG_ERR("CryptGenRandom: read error (%s)", msg_buf);
+ LocalFree(msg_buf);
+ }
+
+ CryptReleaseContext(crypt_prov, 0);
+#endif