mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-10 06:14:15 +00:00
Update moonlight-common-c;
Remove mbedtls_to_openssl_wrapper, use build in MBEDTLS crypto from moonlight-common-c
This commit is contained in:
parent
342b07ee4c
commit
0611bf28ed
4 changed files with 12 additions and 128 deletions
5
Makefile
5
Makefile
|
@ -76,7 +76,8 @@ M_INCLUDES := \
|
|||
-I$(TOPDIR)/third_party/nanogui/ext/nanovg/src
|
||||
|
||||
DEFINES := -DNANOGUI_USE_OPENGL -DNVG_STB_IMAGE_IMPLEMENTATION -DNANOGUI_NO_GLFW \
|
||||
-DHAS_SOCKLEN_T -DHAS_POLL -DHAS_FCNTL -DUSE_MBEDTLS_CRYPTO -DMOONLIGHT_VERSION=\"$(MOONLIGHT_VERSION)\"
|
||||
-DUSE_MBEDTLS -DHAS_SOCKLEN_T -DHAS_POLL -DHAS_FCNTL -DUSE_MBEDTLS_CRYPTO \
|
||||
-DMOONLIGHT_VERSION=\"$(MOONLIGHT_VERSION)\"
|
||||
|
||||
CFLAGS := -g -Wall -fcompare-debug-second -O2 -ffunction-sections $(ARCH) $(DEFINES) $(INCLUDE) $(M_INCLUDES) -D__SWITCH__
|
||||
CXXFLAGS := $(CFLAGS) -std=gnu++17
|
||||
|
@ -118,7 +119,6 @@ MOONLIGHT_LIBRETRO_CXX_SOURCES = \
|
|||
GLVideoRenderer.cpp \
|
||||
Data.cpp \
|
||||
MbedTLSCryptoManager.cpp \
|
||||
mbedtls_to_openssl_wrapper.cpp \
|
||||
AudrenAudioRenderer.cpp \
|
||||
BoxArtManager.cpp \
|
||||
Logger.cpp \
|
||||
|
@ -157,6 +157,7 @@ MOONLIGHT_COMMON_C_SOURCES = \
|
|||
Misc.c \
|
||||
Platform.c \
|
||||
PlatformSockets.c \
|
||||
PlatformCrypto.c \
|
||||
RtpFecQueue.c \
|
||||
RtpReorderQueue.c \
|
||||
RtspConnection.c \
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
28896597262C88C700139ABE /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28896596262C88C700139ABE /* CoreMedia.framework */; };
|
||||
28896599262C88D000139ABE /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28896598262C88D000139ABE /* CoreVideo.framework */; };
|
||||
2889659D262C88DD00139ABE /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2889659C262C88DC00139ABE /* VideoToolbox.framework */; };
|
||||
288965AF262C89D800139ABE /* mbedtls_to_openssl_wrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36F16474247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp */; };
|
||||
28AD4A752606120A009314C6 /* glad.c in Sources */ = {isa = PBXBuildFile; fileRef = 28AD4A722606120A009314C6 /* glad.c */; };
|
||||
28EE5DAC2635B49E00C9C623 /* PlatformCrypto.c in Sources */ = {isa = PBXBuildFile; fileRef = 28EE5DAA2635B49E00C9C623 /* PlatformCrypto.c */; };
|
||||
3602C3B7245D903000368900 /* HostButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3602C3B5245D903000368900 /* HostButton.cpp */; };
|
||||
3602C3BA245DB3C800368900 /* AppListWindow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3602C3B8245DB3C800368900 /* AppListWindow.cpp */; };
|
||||
3602C3BD245DBA9100368900 /* AppButton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3602C3BB245DBA9100368900 /* AppButton.cpp */; };
|
||||
|
@ -170,6 +170,8 @@
|
|||
28AD4A712606120A009314C6 /* glad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = glad.h; sourceTree = "<group>"; };
|
||||
28AD4A722606120A009314C6 /* glad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = glad.c; sourceTree = "<group>"; };
|
||||
28AD4A742606120A009314C6 /* khrplatform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = khrplatform.h; sourceTree = "<group>"; };
|
||||
28EE5DAA2635B49E00C9C623 /* PlatformCrypto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = PlatformCrypto.c; sourceTree = "<group>"; };
|
||||
28EE5DAB2635B49E00C9C623 /* PlatformCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCrypto.h; sourceTree = "<group>"; };
|
||||
3602C3B5245D903000368900 /* HostButton.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HostButton.cpp; sourceTree = "<group>"; };
|
||||
3602C3B6245D903000368900 /* HostButton.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = HostButton.hpp; sourceTree = "<group>"; };
|
||||
3602C3B8245DB3C800368900 /* AppListWindow.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppListWindow.cpp; sourceTree = "<group>"; };
|
||||
|
@ -392,7 +394,6 @@
|
|||
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>"; };
|
||||
36F16476247481F200D70AD9 /* AudrenAudioRenderer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AudrenAudioRenderer.cpp; sourceTree = "<group>"; };
|
||||
36F16477247481F200D70AD9 /* AudrenAudioRenderer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AudrenAudioRenderer.hpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
@ -732,6 +733,8 @@
|
|||
isa = PBXGroup;
|
||||
children = (
|
||||
3652F04E245C292B001FABF3 /* Limelight.h */,
|
||||
28EE5DAA2635B49E00C9C623 /* PlatformCrypto.c */,
|
||||
28EE5DAB2635B49E00C9C623 /* PlatformCrypto.h */,
|
||||
3652F047245C292B001FABF3 /* PlatformThreads.h */,
|
||||
3652F048245C292B001FABF3 /* Input.h */,
|
||||
3652F049245C292B001FABF3 /* ControlStream.c */,
|
||||
|
@ -952,7 +955,6 @@
|
|||
children = (
|
||||
36F164702474736E00D70AD9 /* openssl */,
|
||||
36F1646F2474736E00D70AD9 /* switch_wrapper.c */,
|
||||
36F16474247473A300D70AD9 /* mbedtls_to_openssl_wrapper.cpp */,
|
||||
);
|
||||
path = switch;
|
||||
sourceTree = "<group>";
|
||||
|
@ -1148,11 +1150,11 @@
|
|||
3652EFD0245B3B00001FABF3 /* vscrollpanel.cpp in Sources */,
|
||||
3652F06D245C292B001FABF3 /* win32.c in Sources */,
|
||||
3652F002245B6961001FABF3 /* AddHostWindow.cpp in Sources */,
|
||||
288965AF262C89D800139ABE /* mbedtls_to_openssl_wrapper.cpp in Sources */,
|
||||
3652EFF8245B4EE2001FABF3 /* Application.cpp in Sources */,
|
||||
3652F07E245C292B001FABF3 /* AudioStream.c in Sources */,
|
||||
3652F076245C292B001FABF3 /* Connection.c in Sources */,
|
||||
3652EFE4245B3B00001FABF3 /* combobox.cpp in Sources */,
|
||||
28EE5DAC2635B49E00C9C623 /* PlatformCrypto.c in Sources */,
|
||||
3652EFF2245B3B00001FABF3 /* textbox.cpp in Sources */,
|
||||
3652F074245C292B001FABF3 /* Platform.c in Sources */,
|
||||
3661D2FF2469E0C00060EE24 /* GLVideoRenderer.cpp in Sources */,
|
||||
|
@ -1271,6 +1273,7 @@
|
|||
"-DHAVE_PULSE",
|
||||
"-DUSE_MBEDTLS_CRYPTO",
|
||||
"-DMOONLIGHT_VERSION=\\\"1.1.0\\\"",
|
||||
"-DUSE_MBEDTLS",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lglfw",
|
||||
|
@ -1364,6 +1367,7 @@
|
|||
"-DHAVE_PULSE",
|
||||
"-DUSE_MBEDTLS_CRYPTO",
|
||||
"-DMOONLIGHT_VERSION=\\\"1.1.0\\\"",
|
||||
"-DUSE_MBEDTLS",
|
||||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lglfw",
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
#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;
|
||||
}
|
||||
|
||||
// TODO: This is correct?
|
||||
int EVP_DecryptInit_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_DECRYPT, iv, ctx->iv_len, NULL, 0);
|
||||
ctx->iv = iv;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_DecryptUpdate(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_DECRYPT, inl, ctx->iv, ctx->iv_len, NULL, 0, in, out, ctx->iv_len, ctx->tag);
|
||||
*outl = inl;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, 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;
|
||||
}
|
2
third_party/moonlight-common-c
vendored
2
third_party/moonlight-common-c
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 5782246b30bfc11e659cf53b498886a924aa97d1
|
||||
Subproject commit 13041e0323685ff1b2ccade347cb1de850286d23
|
Loading…
Reference in a new issue