From 9439b39631507d8cda6ea4aa9cf2e8972b695a89 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 26 Oct 2023 14:46:54 -0400 Subject: [PATCH] ssl: Updated sslConnectionSetPrivateOption for 17.0.0. --- nx/include/switch/services/ssl.h | 5 +++-- nx/source/services/ssl.c | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/nx/include/switch/services/ssl.h b/nx/include/switch/services/ssl.h index 2d3b6697..67c0da17 100644 --- a/nx/include/switch/services/ssl.h +++ b/nx/include/switch/services/ssl.h @@ -180,6 +180,7 @@ typedef enum { /// PrivateOptionType typedef enum { SslPrivateOptionType_DtlsSession = 1, ///< \ref sslConnectionSetSessionCacheMode will throw an error if the input ::SslSessionCacheMode is non-zero and this option flag is set. + SslPrivateOptionType_SetCipher = 2, ///< [17.0.0+] This exclusively enables the cipher suite specified in the input u32 value passed to \ref sslConnectionSetPrivateOption (all other ciphers disabled). } SslPrivateOptionType; /// AlpnProtoState @@ -747,9 +748,9 @@ Result sslConnectionGetDtlsHandshakeTimeout(SslConnection *c, u64 *out); * @note Only available on [16.0.0+]. * @param c \ref SslConnection * @param[in] option \ref SslPrivateOptionType - * @param[in] flag Input flag value. + * @param[in] value Input value. */ -Result sslConnectionSetPrivateOption(SslConnection *c, SslPrivateOptionType option, bool flag); +Result sslConnectionSetPrivateOption(SslConnection *c, SslPrivateOptionType option, u32 value); /** * @brief SetSrtpCiphers diff --git a/nx/source/services/ssl.c b/nx/source/services/ssl.c index 05243a6b..5f76da38 100644 --- a/nx/source/services/ssl.c +++ b/nx/source/services/ssl.c @@ -135,6 +135,15 @@ static Result _sslCmdInU8U32NoOut(Service* srv, u8 val0, u32 val1, u32 cmd_id) { return _sslObjectDispatchIn(srv, cmd_id, in); } +static Result _sslCmdInTwoU32sNoOut(Service* srv, u32 val0, u32 val1, u32 cmd_id) { + const struct { + u32 val0; + u32 val1; + } in = { val0, val1 }; + + return _sslObjectDispatchIn(srv, cmd_id, in); +} + static Result _sslCmdNoInOutU32(Service* srv, u32 *out, u32 cmd_id) { return _sslObjectDispatchOut(srv, cmd_id, *out); } @@ -897,14 +906,17 @@ Result sslConnectionGetDtlsHandshakeTimeout(SslConnection *c, u64 *out) { ); } -Result sslConnectionSetPrivateOption(SslConnection *c, SslPrivateOptionType option, bool flag) { +Result sslConnectionSetPrivateOption(SslConnection *c, SslPrivateOptionType option, u32 value) { if (!serviceIsActive(&c->s)) return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); if (hosversionBefore(16,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); - return _sslCmdInU8U32NoOut(&c->s, flag!=0, option, 30); + if (hosversionBefore(17,0,0)) + return _sslCmdInU8U32NoOut(&c->s, value!=0, option, 30); + else + return _sslCmdInTwoU32sNoOut(&c->s, option, value, 30); } Result sslConnectionSetSrtpCiphers(SslConnection *c, const u16 *ciphers, u32 count) {