mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-26 21:40:18 +00:00
Remove OpenSSL dep;
Implement some OpenSSL function over MbedTLS
This commit is contained in:
parent
9464b1d424
commit
dacdb1f658
9 changed files with 187 additions and 55 deletions
|
@ -39,7 +39,7 @@ include $(DEVKITPRO)/libnx/switch_rules
|
|||
#---------------------------------------------------------------------------------
|
||||
TARGET := moonlight
|
||||
BUILD := build
|
||||
SOURCES := libgamestream src/nanogui_resources src src/streaming src/streaming/ffmpeg \
|
||||
SOURCES := libgamestream src src/switch src/nanogui_resources src/streaming src/streaming/ffmpeg \
|
||||
src/crypto src/streaming/video src/ui/windows src/ui/buttons src/ui \
|
||||
third_party/moonlight-common-c/enet third_party/moonlight-common-c/reedsolomon third_party/moonlight-common-c/src \
|
||||
third_party/nanogui/ext/nanovg/src third_party/nanogui/src
|
||||
|
@ -53,7 +53,7 @@ INCLUDES := include
|
|||
ARCH := -march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
|
||||
|
||||
M_INCLUDES := \
|
||||
-I$(TOPDIR)/src -I$(TOPDIR)/src/streaming -I$(TOPDIR)/src/crypto -I$(TOPDIR)/src/crypto/keys \
|
||||
-I$(TOPDIR)/src -I$(TOPDIR)/src/switch -I$(TOPDIR)/src/streaming -I$(TOPDIR)/src/crypto -I$(TOPDIR)/src/crypto/keys \
|
||||
-I$(TOPDIR)/src/streaming/ffmpeg -I$(TOPDIR)/src/streaming/video -I$(TOPDIR)/src/streaming/audio \
|
||||
-I$(TOPDIR)/src/nanogui_resources \
|
||||
-I$(TOPDIR)/src/ui -I$(TOPDIR)/src/ui/buttons -I$(TOPDIR)/src/ui/windows \
|
||||
|
@ -63,8 +63,7 @@ M_INCLUDES := \
|
|||
-I$(TOPDIR)/third_party/moonlight-common-c/enet/include \
|
||||
-I$(TOPDIR)/third_party/nanogui/include \
|
||||
-I$(TOPDIR)/third_party/nanogui/ext/nanovg/src \
|
||||
-I$(TOPDIR)/third_party/json/single_include/nlohmann \
|
||||
-I/Users/rock88/Downloads/moonlight-switch-master/dependencies/include
|
||||
-I$(TOPDIR)/third_party/json/single_include/nlohmann
|
||||
|
||||
DEFINES := -DNANOGUI_USE_OPENGL -DNVG_STB_IMAGE_IMPLEMENTATION -DNANOGUI_NO_GLFW \
|
||||
-DHAS_SOCKLEN_T -DHAS_POLL -DHAS_FCNTL -D_GNU_SOURCE -DUSE_MBEDTLS_CRYPTO
|
||||
|
@ -80,10 +79,9 @@ ASFLAGS := -g $(ARCH)
|
|||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lcurl -lmbedtls -lmbedx509 -lmbedcrypto \
|
||||
-lavcodec -lavutil -lopus -lssl -lcrypto -lbz2 -lz -lexpat -lm \
|
||||
-lavcodec -lavutil -lopus -lbz2 -lz -lexpat -lm \
|
||||
-lglad -lEGL -lglapi -ldrm_nouveau -lglfw3 \
|
||||
-lnx -lwebp -lswresample -lavformat -lvpx \
|
||||
-L/Users/rock88/Downloads/moonlight-switch-master/dependencies/lib
|
||||
-lnx -lwebp -lswresample -lavformat -lvpx
|
||||
|
||||
LIBGAMESTREAM_C_SOURCES = \
|
||||
xml.c
|
||||
|
@ -94,8 +92,8 @@ LIBGAMESTREAM_CPP_SOURCES = \
|
|||
|
||||
MOONLIGHT_LIBRETRO_C_SOURCES = \
|
||||
nanogui_resources.c \
|
||||
moonlight_libnx.c \
|
||||
moonlight_glfw.c
|
||||
moonlight_glfw.c \
|
||||
switch_wrapper.c
|
||||
|
||||
MOONLIGHT_LIBRETRO_CXX_SOURCES = \
|
||||
AddHostWindow.cpp \
|
||||
|
@ -116,7 +114,8 @@ MOONLIGHT_LIBRETRO_CXX_SOURCES = \
|
|||
FFmpegVideoDecoder.cpp \
|
||||
GLVideoRenderer.cpp \
|
||||
Data.cpp \
|
||||
MbedTLSCryptoManager.cpp
|
||||
MbedTLSCryptoManager.cpp \
|
||||
mbedtls_to_openssl_wrapper.cpp
|
||||
|
||||
MOONLIGHT_COMMON_C_SOURCES = \
|
||||
callbacks.c \
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
3602C3BA245DB3C800368900 /* AppListWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3602C3B8245DB3C800368900 /* AppListWindow.cpp */; };
|
||||
3602C3BD245DBA9100368900 /* AppButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3602C3BB245DBA9100368900 /* AppButton.cpp */; };
|
||||
3603E93C246316400051287D /* InputController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3603E93A246316400051287D /* InputController.cpp */; };
|
||||
363898332471B7C500F99920 /* OpenSSLCryptoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 363898302471B7C500F99920 /* OpenSSLCryptoManager.cpp */; };
|
||||
363898342471B7C500F99920 /* MbedTLSCryptoManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 363898312471B7C500F99920 /* MbedTLSCryptoManager.cpp */; };
|
||||
3652EFCD245B3B00001FABF3 /* widget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3652EF0F245B3B00001FABF3 /* widget.cpp */; };
|
||||
3652EFCE245B3B00001FABF3 /* common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3652EF10245B3B00001FABF3 /* common.cpp */; };
|
||||
|
@ -102,6 +101,7 @@
|
|||
36DFE217245A278700FC51CE /* glsym_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 36DFE0DB245A1FEC00FC51CE /* glsym_gl.c */; };
|
||||
36DFE218245A278900FC51CE /* rglgen.c in Sources */ = {isa = PBXBuildFile; fileRef = 36DFE0DE245A1FEC00FC51CE /* rglgen.c */; };
|
||||
36E63790247010C70032F5FB /* Data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36E6378E247010C70032F5FB /* Data.cpp */; };
|
||||
36F16475247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36F16474247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
|
@ -290,7 +290,6 @@
|
|||
367CD958245DE25F00A95738 /* StreamWindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StreamWindow.cpp; sourceTree = "<group>"; };
|
||||
367CD959245DE25F00A95738 /* StreamWindow.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = StreamWindow.hpp; sourceTree = "<group>"; };
|
||||
369445A82466CE2700786D0A /* Makefile.libnx */ = {isa = PBXFileReference; explicitFileType = sourcecode.make; path = Makefile.libnx; sourceTree = "<group>"; };
|
||||
369445A92466E2B000786D0A /* moonlight_libnx.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = moonlight_libnx.c; sourceTree = "<group>"; };
|
||||
36A0C0352461DBA30083289C /* AddHostButton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AddHostButton.cpp; sourceTree = "<group>"; };
|
||||
36A0C0362461DBA30083289C /* AddHostButton.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AddHostButton.hpp; sourceTree = "<group>"; };
|
||||
36A0C0382461E4C00083289C /* SettingsWindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SettingsWindow.cpp; sourceTree = "<group>"; };
|
||||
|
@ -303,7 +302,6 @@
|
|||
36D3F8432469B5C400CDEF9B /* MoonlightSession.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = MoonlightSession.hpp; sourceTree = "<group>"; };
|
||||
36D3F8452469C6BC00CDEF9B /* Log.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Log.h; sourceTree = "<group>"; };
|
||||
36D3F8492469CC2600CDEF9B /* IAudioRenderer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IAudioRenderer.hpp; sourceTree = "<group>"; };
|
||||
36D461BE24709B8F00A543B4 /* build.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; name = build.sh; path = "../../../../Downloads/openssl-1.1.1g/build.sh"; sourceTree = "<group>"; };
|
||||
36DBDE8E2450BB7E0057C8D3 /* moonlight */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = moonlight; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
36DBDE992450BCD50057C8D3 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
36DBDE9B2450BCD90057C8D3 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
|
@ -326,6 +324,10 @@
|
|||
36E6378B246FFFF30032F5FB /* CryptoManager.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CryptoManager.hpp; sourceTree = "<group>"; };
|
||||
36E6378E247010C70032F5FB /* Data.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Data.cpp; sourceTree = "<group>"; };
|
||||
36E6378F247010C70032F5FB /* Data.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Data.hpp; sourceTree = "<group>"; };
|
||||
36F1646F2474736E00D70AD9 /* switch_wrapper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = switch_wrapper.c; sourceTree = "<group>"; };
|
||||
36F164712474736E00D70AD9 /* evp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = evp.h; sourceTree = "<group>"; };
|
||||
36F164722474736E00D70AD9 /* rand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rand.h; sourceTree = "<group>"; };
|
||||
36F16474247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = mbedtls_to_openssl_wrapper.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -639,6 +641,7 @@
|
|||
36DFE0CA2459FA3F00FC51CE /* nanogui_resources */,
|
||||
36DFDCF12459F79000FC51CE /* ui */,
|
||||
36D3F8462469C8DD00CDEF9B /* streaming */,
|
||||
36F1646E2474736E00D70AD9 /* switch */,
|
||||
3652F003245C28C6001FABF3 /* GameStreamClient.cpp */,
|
||||
3652F004245C28C6001FABF3 /* GameStreamClient.hpp */,
|
||||
36A0C03B2461F03C0083289C /* Settings.cpp */,
|
||||
|
@ -649,7 +652,6 @@
|
|||
3652F084245C6CFC001FABF3 /* libretro.h */,
|
||||
3652F085245C6CFC001FABF3 /* moonlight_libretro.cpp */,
|
||||
36B406962459F460005BD903 /* moonlight_glfw.cpp */,
|
||||
369445A92466E2B000786D0A /* moonlight_libnx.c */,
|
||||
);
|
||||
path = src;
|
||||
sourceTree = "<group>";
|
||||
|
@ -689,7 +691,6 @@
|
|||
36DBDE852450BB7E0057C8D3 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
36D461BE24709B8F00A543B4 /* build.sh */,
|
||||
3602C3C0245DC7E300368900 /* Makefile */,
|
||||
369445A82466CE2700786D0A /* Makefile.libnx */,
|
||||
36A0C03E2461FFF10083289C /* build_opus_lakka_switch.sh */,
|
||||
|
@ -783,6 +784,25 @@
|
|||
path = crypto;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
36F1646E2474736E00D70AD9 /* switch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
36F164702474736E00D70AD9 /* openssl */,
|
||||
36F1646F2474736E00D70AD9 /* switch_wrapper.c */,
|
||||
36F16474247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp */,
|
||||
);
|
||||
path = switch;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
36F164702474736E00D70AD9 /* openssl */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
36F164712474736E00D70AD9 /* evp.h */,
|
||||
36F164722474736E00D70AD9 /* rand.h */,
|
||||
);
|
||||
path = openssl;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
|
@ -871,7 +891,6 @@
|
|||
36DFE0CD2459FA3F00FC51CE /* nanogui_resources.cpp in Sources */,
|
||||
36DFE217245A278700FC51CE /* glsym_gl.c in Sources */,
|
||||
3652F06A245C292B001FABF3 /* protocol.c in Sources */,
|
||||
363898332471B7C500F99920 /* OpenSSLCryptoManager.cpp in Sources */,
|
||||
3652EFFC245B6434001FABF3 /* MainWindow.cpp in Sources */,
|
||||
3652F086245C6CFC001FABF3 /* moonlight_libretro.cpp in Sources */,
|
||||
3652EFD3245B3B00001FABF3 /* button.cpp in Sources */,
|
||||
|
@ -919,6 +938,7 @@
|
|||
3652EFCE245B3B00001FABF3 /* common.cpp in Sources */,
|
||||
3652F077245C292B001FABF3 /* VideoDepacketizer.c in Sources */,
|
||||
3652EFF1245B3B00001FABF3 /* messagedialog.cpp in Sources */,
|
||||
36F16475247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp in Sources */,
|
||||
36B406982459F5CB005BD903 /* moonlight_glfw.cpp in Sources */,
|
||||
3652F06F245C292B001FABF3 /* ControlStream.c in Sources */,
|
||||
3652EFD6245B3B00001FABF3 /* window.cpp in Sources */,
|
||||
|
@ -1009,18 +1029,15 @@
|
|||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
/usr/local/include,
|
||||
"\"/usr/local/Cellar/openssl@1.0/1.0.2t/include\"",
|
||||
"\"$(SRCROOT)/third_party/nanogui/include\"",
|
||||
"\"$(SRCROOT)/third_party/nanogui/ext/nanovg/src\"",
|
||||
"\"$(SRCROOT)/src/nanogui_resources\"",
|
||||
"\"$(SRCROOT)/third_party/moonlight-common-c/enet/include\"",
|
||||
"\"$(SRCROOT)/third_party/moonlight-common-c/src\"",
|
||||
"\"$(SRCROOT)/third_party/json/single_include/nlohmann\"",
|
||||
"\"$(SRCROOT)/src/switch\"",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
/usr/local/lib,
|
||||
"\"/usr/local/Cellar/openssl@1.0/1.0.2t/lib\"",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = /usr/local/lib;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
|
@ -1039,8 +1056,6 @@
|
|||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lglfw3",
|
||||
"-lssl",
|
||||
"-lcrypto",
|
||||
"-lcurl",
|
||||
"-lexpat",
|
||||
"-lavcodec",
|
||||
|
@ -1103,18 +1118,15 @@
|
|||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
/usr/local/include,
|
||||
"\"/usr/local/Cellar/openssl@1.0/1.0.2t/include\"",
|
||||
"\"$(SRCROOT)/third_party/nanogui/include\"",
|
||||
"\"$(SRCROOT)/third_party/nanogui/ext/nanovg/src\"",
|
||||
"\"$(SRCROOT)/src/nanogui_resources\"",
|
||||
"\"$(SRCROOT)/third_party/moonlight-common-c/enet/include\"",
|
||||
"\"$(SRCROOT)/third_party/moonlight-common-c/src\"",
|
||||
"\"$(SRCROOT)/third_party/json/single_include/nlohmann\"",
|
||||
"\"$(SRCROOT)/src/switch\"",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
/usr/local/lib,
|
||||
"\"/usr/local/Cellar/openssl@1.0/1.0.2t/lib\"",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = /usr/local/lib;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
|
@ -1132,8 +1144,6 @@
|
|||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lglfw3",
|
||||
"-lssl",
|
||||
"-lcrypto",
|
||||
"-lcurl",
|
||||
"-lexpat",
|
||||
"-lavcodec",
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#ifdef __SWITCH__
|
||||
retro_input_state_t input_state_cb;
|
||||
#else
|
||||
extern retro_input_state_t input_state_cb;
|
||||
#endif
|
||||
|
||||
static int mouse_x = 0, mouse_y = 0;
|
||||
static int mouse_l = 0, mouse_r = 0;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <curl/curl.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include "glsym/glsym.h"
|
||||
#include "libretro.h"
|
||||
|
@ -66,7 +65,7 @@ void retro_init(void) {
|
|||
Settings::settings()->set_working_dir("/storage/system/moonlight");
|
||||
#endif
|
||||
|
||||
OpenSSL_add_all_algorithms();
|
||||
//OpenSSL_add_all_algorithms();
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
}
|
||||
|
||||
|
|
97
src/switch/mbedtls_to_openssl_wrapper.cpp
Normal file
97
src/switch/mbedtls_to_openssl_wrapper.cpp
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include <openssl/rand.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <mbedtls/gcm.h>
|
||||
#include <cstdlib>
|
||||
#include "Data.hpp"
|
||||
|
||||
struct MBED_CIPHER_CTX {
|
||||
mbedtls_gcm_context ctx;
|
||||
int iv_len;
|
||||
const unsigned char *iv;
|
||||
unsigned char* tag;
|
||||
};
|
||||
|
||||
const EVP_CIPHER *EVP_aes_128_gcm(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const EVP_CIPHER *EVP_aes_128_cbc(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx) {
|
||||
if (ctx) {
|
||||
mbedtls_gcm_init(&ctx->ctx);
|
||||
ctx->iv_len = 0;
|
||||
ctx->iv = NULL;
|
||||
ctx->tag = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *ctx) {
|
||||
if (ctx) {
|
||||
mbedtls_gcm_free(&ctx->ctx);
|
||||
|
||||
if (ctx->tag) {
|
||||
free(ctx->tag);
|
||||
ctx->tag = NULL;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void) {
|
||||
EVP_CIPHER_CTX* ctx = (EVP_CIPHER_CTX *)malloc(sizeof(EVP_CIPHER_CTX));
|
||||
EVP_CIPHER_CTX_init(ctx);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx) {
|
||||
if (ctx && ctx->tag) {
|
||||
free(ctx->tag);
|
||||
}
|
||||
}
|
||||
|
||||
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr) {
|
||||
if (ctx && type == EVP_CTRL_GCM_SET_IVLEN) {
|
||||
ctx->iv_len = arg;
|
||||
} else if (ctx && type == EVP_CTRL_GCM_GET_TAG) {
|
||||
unsigned char *tag = (unsigned char*)ptr;
|
||||
|
||||
for (int i = 0; i < arg; i++) {
|
||||
tag[i] = ctx->tag[i];
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv) {
|
||||
if (ctx && key != NULL && iv != NULL) {
|
||||
mbedtls_gcm_setkey(&ctx->ctx, MBEDTLS_CIPHER_ID_AES, key, ctx->iv_len * 8);
|
||||
mbedtls_gcm_starts(&ctx->ctx, MBEDTLS_GCM_ENCRYPT, iv, ctx->iv_len, NULL, 0);
|
||||
ctx->iv = iv;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl) {
|
||||
if (ctx) {
|
||||
ctx->tag = (unsigned char*)malloc(ctx->iv_len);
|
||||
|
||||
mbedtls_gcm_crypt_and_tag(&ctx->ctx, MBEDTLS_GCM_ENCRYPT, inl, ctx->iv, ctx->iv_len, NULL, 0, in, out, ctx->iv_len, ctx->tag);
|
||||
*outl = inl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int RAND_bytes(unsigned char *buf, int num) {
|
||||
Data rand = Data::random_bytes(num);
|
||||
for (int i = 0; i < num; i++) {
|
||||
buf[i] = rand.bytes()[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
31
src/switch/openssl/evp.h
Normal file
31
src/switch/openssl/evp.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#define EVP_CTRL_GCM_SET_IVLEN 0x9
|
||||
#define EVP_CTRL_GCM_GET_TAG 0x10
|
||||
|
||||
typedef int EVP_CIPHER;
|
||||
typedef int ENGINE;
|
||||
|
||||
struct MBED_CIPHER_CTX;
|
||||
typedef struct MBED_CIPHER_CTX EVP_CIPHER_CTX;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
const EVP_CIPHER *EVP_aes_128_gcm(void);
|
||||
const EVP_CIPHER *EVP_aes_128_cbc(void);
|
||||
|
||||
void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx);
|
||||
int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *ctx);
|
||||
EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
|
||||
void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *ctx);
|
||||
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
|
||||
|
||||
int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl, const unsigned char *key, const unsigned char *iv);
|
||||
int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, const unsigned char *in, int inl);
|
||||
int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
11
src/switch/openssl/rand.h
Normal file
11
src/switch/openssl/rand.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int RAND_bytes(unsigned char *buf, int num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,10 +1,6 @@
|
|||
#include <netinet/in.h>
|
||||
#include <stdint.h>
|
||||
#include <switch.h>
|
||||
#include "libretro.h"
|
||||
|
||||
retro_audio_sample_batch_t audio_batch_cb = NULL;
|
||||
retro_input_state_t input_state_cb = NULL;
|
||||
|
||||
uint32_t htonl(uint32_t hostlong) {
|
||||
return __builtin_bswap32(hostlong);
|
||||
|
@ -22,22 +18,6 @@ uint16_t ntohs(uint16_t netshort) {
|
|||
return __builtin_bswap16(netshort);
|
||||
}
|
||||
|
||||
uid_t getuid() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
uid_t geteuid() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
gid_t getgid(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
gid_t getegid(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int sigaction(int a, const struct sigaction* b, struct sigaction* c) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,11 +26,9 @@ static int nxlink_sock = -1;
|
|||
|
||||
void userAppInit() {
|
||||
socketInitializeDefault();
|
||||
nxlink_sock = nxlinkStdio();
|
||||
nxlinkStdio();
|
||||
}
|
||||
|
||||
void userAppExit() {
|
||||
if (nxlink_sock != -1)
|
||||
close(nxlink_sock);
|
||||
socketExit();
|
||||
}
|
|
@ -23,6 +23,7 @@ StreamWindow::StreamWindow(Widget *parent, const std::string &address, int app_i
|
|||
|
||||
m_loader = add<LoadingOverlay>();
|
||||
|
||||
inc_ref();
|
||||
m_session->start([this](auto result) {
|
||||
if (m_loader) {
|
||||
m_loader->dispose();
|
||||
|
@ -35,6 +36,8 @@ StreamWindow::StreamWindow(Widget *parent, const std::string &address, int app_i
|
|||
auto app = static_cast<Application *>(screen());
|
||||
app->pop_window();
|
||||
}
|
||||
|
||||
dec_ref();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue