mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Make it easier to switch SSL backends
This commit is contained in:
parent
b95abff3f0
commit
6da3ab1354
3 changed files with 36 additions and 16 deletions
30
src/Core.h
30
src/Core.h
|
@ -141,6 +141,10 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_GFX_BACKEND_D3D11 5
|
||||
#define CC_GFX_BACKEND_VULKAN 6
|
||||
|
||||
#define CC_SSL_BACKEND_NONE 1
|
||||
#define CC_SSL_BACKEND_BEARSSL 2
|
||||
#define CC_SSL_BACKEND_SCHANNEL 3
|
||||
|
||||
#define CC_GFX_BACKEND_IS_GL() (CC_GFX_BACKEND == CC_GFX_BACKEND_GL1 || CC_GFX_BACKEND == CC_GFX_BACKEND_GL2)
|
||||
|
||||
#define CC_BUILD_NETWORKING
|
||||
|
@ -162,8 +166,8 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined XENON
|
||||
/* libxenon also defines __linux__ (yes, really) */
|
||||
#define CC_BUILD_XBOX360
|
||||
|
@ -172,11 +176,12 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_NOMUSIC
|
||||
#define CC_BUILD_NOSOUNDS
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined _WIN32
|
||||
#define CC_BUILD_WIN
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_SCHANNEL
|
||||
#define CC_BUILD_WINMM
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_SCHANNEL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_D3D9
|
||||
#define DEFAULT_WIN_BACKEND CC_WIN_BACKEND_WIN32
|
||||
#elif defined __ANDROID__
|
||||
|
@ -315,15 +320,15 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_COOPTHREADED
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined __3DS__
|
||||
#define CC_BUILD_3DS
|
||||
#define CC_BUILD_CONSOLE
|
||||
#define CC_BUILD_LOWMEM
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_DUALSCREEN
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined GEKKO
|
||||
#define CC_BUILD_GCWII
|
||||
#define CC_BUILD_CONSOLE
|
||||
|
@ -332,31 +337,31 @@ typedef cc_uint8 cc_bool;
|
|||
#endif
|
||||
#define CC_BUILD_COOPTHREADED
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined __vita__
|
||||
#define CC_BUILD_PSVITA
|
||||
#define CC_BUILD_CONSOLE
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_TOUCH
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined _arch_dreamcast
|
||||
#define CC_BUILD_DREAMCAST
|
||||
#define CC_BUILD_CONSOLE
|
||||
#define CC_BUILD_LOWMEM
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#define CC_BUILD_SMALLSTACK
|
||||
#undef CC_BUILD_RESOURCES
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined PLAT_PS3
|
||||
#define CC_BUILD_PS3
|
||||
#define CC_BUILD_CONSOLE
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined N64
|
||||
#define CC_BIG_ENDIAN
|
||||
#define CC_BUILD_N64
|
||||
|
@ -376,8 +381,8 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_COOPTHREADED
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined PLAT_NDS
|
||||
#define CC_BUILD_NDS
|
||||
#define CC_BUILD_CONSOLE
|
||||
|
@ -396,18 +401,18 @@ typedef cc_uint8 cc_bool;
|
|||
#define CC_BUILD_COOPTHREADED
|
||||
#define CC_BUILD_OPENAL
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_SPLITSCREEN
|
||||
#define CC_BUILD_TOUCH
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined __SWITCH__
|
||||
#define CC_BUILD_SWITCH
|
||||
#define CC_BUILD_CONSOLE
|
||||
#define CC_BUILD_HTTPCLIENT
|
||||
#define CC_BUILD_BEARSSL
|
||||
#define CC_BUILD_TOUCH
|
||||
#define CC_BUILD_GLES
|
||||
#define CC_BUILD_EGL
|
||||
#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL2
|
||||
#define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL
|
||||
#elif defined PLAT_PS1
|
||||
#define CC_BUILD_PS1
|
||||
#define CC_BUILD_CONSOLE
|
||||
|
@ -455,6 +460,9 @@ typedef cc_uint8 cc_bool;
|
|||
#if defined DEFAULT_GFX_BACKEND && !defined CC_GFX_BACKEND
|
||||
#define CC_GFX_BACKEND DEFAULT_GFX_BACKEND
|
||||
#endif
|
||||
#if defined DEFAULT_SSL_BACKEND && !defined CC_SSL_BACKEND
|
||||
#define CC_SSL_BACKEND DEFAULT_SSL_BACKEND
|
||||
#endif
|
||||
|
||||
#ifdef CC_BUILD_CONSOLE
|
||||
#undef CC_BUILD_FREETYPE
|
||||
|
|
|
@ -136,6 +136,14 @@ void Platform_Log(const char* msg, int len) {
|
|||
OutputDebugStringA("\n");
|
||||
}
|
||||
|
||||
static VOID (WINAPI *_GetSystemTimeAsFileTime)(LPFILETIME sysTime);
|
||||
/* Fallback support for NT 3.5 */
|
||||
static VOID WINAPI Fallback_GetSystemTimeAsFileTime(LPFILETIME sysTime) {
|
||||
SYSTEMTIME curTime;
|
||||
GetSystemTime(&curTime);
|
||||
SystemTimeToFileTime(&curTime, sysTime);
|
||||
}
|
||||
|
||||
#define FILETIME_EPOCH 50491123200ULL
|
||||
#define FILETIME_UNIX_EPOCH 11644473600ULL
|
||||
#define FileTime_TotalSecs(time) ((time / 10000000) + FILETIME_EPOCH)
|
||||
|
@ -144,7 +152,7 @@ TimeMS DateTime_CurrentUTC(void) {
|
|||
FILETIME ft;
|
||||
cc_uint64 raw;
|
||||
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
_GetSystemTimeAsFileTime(&ft);
|
||||
/* in 100 nanosecond units, since Jan 1 1601 */
|
||||
raw = ft.dwLowDateTime | ((cc_uint64)ft.dwHighDateTime << 32);
|
||||
return FileTime_TotalSecs(raw);
|
||||
|
@ -171,7 +179,7 @@ cc_uint64 Stopwatch_Measure(void) {
|
|||
QueryPerformanceCounter(&t);
|
||||
return (cc_uint64)t.QuadPart;
|
||||
} else {
|
||||
GetSystemTimeAsFileTime(&ft);
|
||||
_GetSystemTimeAsFileTime(&ft);
|
||||
return (cc_uint64)ft.dwLowDateTime | ((cc_uint64)ft.dwHighDateTime << 32);
|
||||
}
|
||||
}
|
||||
|
@ -964,12 +972,15 @@ static BOOL (WINAPI *_IsDebuggerPresent)(void);
|
|||
|
||||
static void LoadKernelFuncs(void) {
|
||||
static const struct DynamicLibSym funcs[] = {
|
||||
DynamicLib_Sym(AttachConsole), DynamicLib_Sym(IsDebuggerPresent)
|
||||
DynamicLib_Sym(AttachConsole), DynamicLib_Sym(IsDebuggerPresent),
|
||||
DynamicLib_Sym(GetSystemTimeAsFileTime),
|
||||
};
|
||||
|
||||
static const cc_string kernel32 = String_FromConst("KERNEL32.DLL");
|
||||
void* lib;
|
||||
DynamicLib_LoadAll(&kernel32, funcs, Array_Elems(funcs), &lib);
|
||||
/* Not present on Windows NT 3.5 */
|
||||
if (!_GetSystemTimeAsFileTime) _GetSystemTimeAsFileTime = Fallback_GetSystemTimeAsFileTime;
|
||||
}
|
||||
|
||||
void Platform_Init(void) {
|
||||
|
@ -1046,6 +1057,7 @@ cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
|||
LocalFree(output.pbData);
|
||||
return 0;
|
||||
}
|
||||
|
||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||
DATA_BLOB input, output;
|
||||
int i;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "SSL.h"
|
||||
#include "Errors.h"
|
||||
|
||||
#if defined CC_BUILD_SCHANNEL
|
||||
#if CC_SSL_BACKEND == CC_SSL_BACKEND_SCHANNEL
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOSERVICE
|
||||
#define NOMCX
|
||||
|
@ -404,7 +404,7 @@ cc_result SSL_Free(void* ctx_) {
|
|||
Mem_Free(ctx);
|
||||
return 0;
|
||||
}
|
||||
#elif defined CC_BUILD_BEARSSL
|
||||
#elif CC_SSL_BACKEND == CC_SSL_BACKEND_BEARSSL
|
||||
#include "String.h"
|
||||
#include "bearssl.h"
|
||||
#include "../misc/certs/certs.h"
|
||||
|
|
Loading…
Reference in a new issue