mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 21:43:12 -07:00
Add Nintendo Switch chiaki-lib support (#233)
This commit is contained in:
parent
6d02714d0e
commit
f35311bf61
19 changed files with 771 additions and 20 deletions
|
@ -27,12 +27,28 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__SWITCH__) || defined(CHIAKI_LIB_ENABLE_MBEDTLS)
|
||||
#include "mbedtls/ecdh.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define CHIAKI_ECDH_SECRET_SIZE 32
|
||||
|
||||
typedef struct chiaki_ecdh_t
|
||||
{
|
||||
// the following lines may lead to memory corruption
|
||||
// __SWITCH__ or CHIAKI_LIB_ENABLE_MBEDTLS must be defined
|
||||
// globally (whole project)
|
||||
#if defined(__SWITCH__) || defined(CHIAKI_LIB_ENABLE_MBEDTLS)
|
||||
// mbedtls ecdh context
|
||||
mbedtls_ecdh_context ctx;
|
||||
// deterministic random bit generator
|
||||
mbedtls_ctr_drbg_context drbg;
|
||||
#else
|
||||
struct ec_group_st *group;
|
||||
struct ec_key_st *key_local;
|
||||
#endif
|
||||
} ChiakiECDH;
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_init(ChiakiECDH *ecdh);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -36,6 +38,15 @@ typedef struct chiaki_stop_pipe_t
|
|||
{
|
||||
#ifdef _WIN32
|
||||
WSAEVENT event;
|
||||
#elif defined(__SWITCH__) || defined(CHIAKI_ENABLE_SWITCH_LINUX)
|
||||
// due to a lack pipe/event/socketpair
|
||||
// on switch env, we use a physical socket
|
||||
// to send/trigger the cancel signal
|
||||
struct sockaddr_in addr;
|
||||
// local stop socket file descriptor
|
||||
// this fd is audited by 'select' as
|
||||
// fd_set *readfds
|
||||
int fd;
|
||||
#else
|
||||
int fds[2];
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue