mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Configure BearSSL to always rely on ClassiCube's platform function to retrieve the current time
This commit is contained in:
parent
9a1072d45a
commit
388b9daac4
4 changed files with 18 additions and 21 deletions
|
@ -85,6 +85,8 @@ ClassiCube runs on:
|
||||||
<li> PS Vita - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_vita.yml">unfinished, rendering issues</a> </li>
|
<li> PS Vita - <a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_vita.yml">unfinished, rendering issues</a> </li>
|
||||||
<li> Xbox -<a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_xbox"> unfinished, major rendering issues</a> </li>
|
<li> Xbox -<a href="https://github.com/UnknownShadow200/ClassiCube/actions/workflows/build_xbox"> unfinished, major rendering issues</a> </li>
|
||||||
<li> PS3 - doesn't render properly yet </li>
|
<li> PS3 - doesn't render properly yet </li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
|
||||||
# Compiling
|
# Compiling
|
||||||
|
|
||||||
|
|
17
src/SSL.c
17
src/SSL.c
|
@ -456,8 +456,8 @@ cc_bool SSLBackend_DescribeError(cc_result res, cc_string* dst) {
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
static void InjectEntropy(SSLContext* ctx) {
|
static void InjectEntropy(SSLContext* ctx) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
int res = PS_GenerateRandomBytes(buf, 32);
|
PS_GenerateRandomBytes(buf, 32);
|
||||||
if (res == 0) return; // NOTE: Not implemented in Citra
|
// NOTE: PS_GenerateRandomBytes isn't implemented in Citra
|
||||||
|
|
||||||
br_ssl_engine_inject_entropy(&ctx->sc.eng, buf, 32);
|
br_ssl_engine_inject_entropy(&ctx->sc.eng, buf, 32);
|
||||||
}
|
}
|
||||||
|
@ -485,6 +485,18 @@ static void InjectEntropy(SSLContext* ctx) {
|
||||||
#else
|
#else
|
||||||
static void InjectEntropy(SSLContext* ctx) { }
|
static void InjectEntropy(SSLContext* ctx) { }
|
||||||
#endif
|
#endif
|
||||||
|
static void SetCurrentTime(SSLContext* ctx) {
|
||||||
|
cc_uint64 cur = DateTime_CurrentUTC_MS() / 1000;
|
||||||
|
uint32_t days = (uint32_t)(cur / 86400) + 366;
|
||||||
|
uint32_t secs = (uint32_t)(cur % 86400);
|
||||||
|
|
||||||
|
br_x509_minimal_set_time(&ctx->xc, days, secs);
|
||||||
|
/* This matches bearssl's default time calculation
|
||||||
|
time_t x = time(NULL);
|
||||||
|
vd = (uint32_t)(x / 86400) + 719528;
|
||||||
|
vs = (uint32_t)(x % 86400);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
static int sock_read(void* ctx_, unsigned char* buf, size_t len) {
|
static int sock_read(void* ctx_, unsigned char* buf, size_t len) {
|
||||||
SSLContext* ctx = (SSLContext*)ctx_;
|
SSLContext* ctx = (SSLContext*)ctx_;
|
||||||
|
@ -519,6 +531,7 @@ cc_result SSL_Init(cc_socket socket, const cc_string* host_, void** out_ctx) {
|
||||||
br_x509_minimal_set_ecdsa(&ctx->xc, &br_ec_prime_i31, &br_ecdsa_i31_vrfy_asn1);
|
br_x509_minimal_set_ecdsa(&ctx->xc, &br_ec_prime_i31, &br_ecdsa_i31_vrfy_asn1);
|
||||||
}*/
|
}*/
|
||||||
InjectEntropy(ctx);
|
InjectEntropy(ctx);
|
||||||
|
SetCurrentTime(ctx);
|
||||||
ctx->socket = socket;
|
ctx->socket = socket;
|
||||||
|
|
||||||
br_ssl_engine_set_buffer(&ctx->sc.eng, ctx->iobuf, sizeof(ctx->iobuf), 1);
|
br_ssl_engine_set_buffer(&ctx->sc.eng, ctx->iobuf, sizeof(ctx->iobuf), 1);
|
||||||
|
|
|
@ -36,7 +36,7 @@ void Window_Init(void) {
|
||||||
|
|
||||||
void Window_Create2D(int width, int height) {
|
void Window_Create2D(int width, int height) {
|
||||||
launcherMode = true;
|
launcherMode = true;
|
||||||
vid_set_mode(DEFAULT_VID_MODE, PM_RGB0888);
|
vid_set_mode(DEFAULT_VID_MODE, PM_RGB888);
|
||||||
vid_flip(0);
|
vid_flip(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
third_party/bearssl/src/inner.h
vendored
18
third_party/bearssl/src/inner.h
vendored
|
@ -432,24 +432,6 @@
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* Detect support for an OS-provided time source.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BR_USE_UNIX_TIME
|
|
||||||
#if defined __unix__ || defined __linux__ \
|
|
||||||
|| defined _POSIX_SOURCE || defined _POSIX_C_SOURCE \
|
|
||||||
|| (defined __APPLE__ && defined __MACH__)
|
|
||||||
#define BR_USE_UNIX_TIME 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef BR_USE_WIN32_TIME
|
|
||||||
#if defined _WIN32 || defined _WIN64
|
|
||||||
#define BR_USE_WIN32_TIME 1
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ==================================================================== */
|
/* ==================================================================== */
|
||||||
/*
|
/*
|
||||||
* Encoding/decoding functions.
|
* Encoding/decoding functions.
|
||||||
|
|
Loading…
Reference in a new issue