mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
And for Windows too
This commit is contained in:
parent
9467c8951a
commit
0e1fba3d1e
@ -1081,8 +1081,23 @@ cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL (WINAPI *_RtlGenRandom)(PVOID data, ULONG len);
|
||||||
|
|
||||||
cc_result Platform_GetEntropy(void* data, int len) {
|
cc_result Platform_GetEntropy(void* data, int len) {
|
||||||
return ERR_NOT_SUPPORTED;
|
static const struct DynamicLibSym funcs[] = {
|
||||||
|
DynamicLib_Sym2("SystemFunction036", RtlGenRandom)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!_RtlGenRandom) {
|
||||||
|
static const cc_string kernel32 = String_FromConst("ADVAPI32.DLL");
|
||||||
|
void* lib;
|
||||||
|
|
||||||
|
DynamicLib_LoadAll(&kernel32, funcs, Array_Elems(funcs), &lib);
|
||||||
|
if (!_RtlGenRandom) return ERR_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_RtlGenRandom(data, len)) return GetLastError();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
5
third_party/bearssl/src/config.h
vendored
5
third_party/bearssl/src/config.h
vendored
@ -42,6 +42,11 @@
|
|||||||
#undef _WIN32
|
#undef _WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Rely on ClassiCube's implementation for RNG */
|
||||||
|
#define BR_USE_WIN32_RAND 0
|
||||||
|
#define BR_USE_URANDOM 0
|
||||||
|
#define BR_USE_GETENTROPY 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When BR_64 is enabled, 64-bit integer types are assumed to be
|
* When BR_64 is enabled, 64-bit integer types are assumed to be
|
||||||
* efficient (i.e. the architecture has 64-bit registers and can
|
* efficient (i.e. the architecture has 64-bit registers and can
|
||||||
|
56
third_party/bearssl/src/ssl_engine.c
vendored
56
third_party/bearssl/src/ssl_engine.c
vendored
@ -24,62 +24,6 @@
|
|||||||
|
|
||||||
#include "inner.h"
|
#include "inner.h"
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* obsolete */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If BR_USE_URANDOM is not defined, then try to autodetect its presence
|
|
||||||
* through compiler macros.
|
|
||||||
*/
|
|
||||||
#ifndef BR_USE_URANDOM
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macro values documented on:
|
|
||||||
* https://sourceforge.net/p/predef/wiki/OperatingSystems/
|
|
||||||
*
|
|
||||||
* Only the most common systems have been included here for now. This
|
|
||||||
* should be enriched later on.
|
|
||||||
*/
|
|
||||||
#if defined _AIX \
|
|
||||||
|| defined __ANDROID__ \
|
|
||||||
|| defined __FreeBSD__ \
|
|
||||||
|| defined __NetBSD__ \
|
|
||||||
|| defined __OpenBSD__ \
|
|
||||||
|| defined __DragonFly__ \
|
|
||||||
|| defined __linux__ \
|
|
||||||
|| (defined __sun && (defined __SVR4 || defined __svr4__)) \
|
|
||||||
|| (defined __APPLE__ && defined __MACH__)
|
|
||||||
#define BR_USE_URANDOM 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If BR_USE_WIN32_RAND is not defined, perform autodetection here.
|
|
||||||
*/
|
|
||||||
#ifndef BR_USE_WIN32_RAND
|
|
||||||
|
|
||||||
#if defined _WIN32 || defined _WIN64
|
|
||||||
#define BR_USE_WIN32_RAND 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BR_USE_URANDOM
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BR_USE_WIN32_RAND
|
|
||||||
#include <windows.h>
|
|
||||||
#include <wincrypt.h>
|
|
||||||
#pragma comment(lib, "advapi32")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ==================================================================== */
|
/* ==================================================================== */
|
||||||
/*
|
/*
|
||||||
* This part of the file does the low-level record management.
|
* This part of the file does the low-level record management.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user