} SSLC_DefaultClientCert;
/// sslc options. https://www.3dbrew.org/wiki/SSL_Services#SSLOpt
-typedef enum {
+enum {
SSLCOPT_Default = 0,
SSLCOPT_DisableVerify = BIT(9), // "Disables server cert verification when set."
SSLCOPT_TLSv10 = BIT(11) // "Use TLSv1.0."
-} SSLC_SSLOpt;
+};
/// Initializes SSLC. Normally session_handle should be 0. When non-zero this will use the specified handle for the main-service-session without using the Initialize command, instead of using srvGetServiceHandle.
Result sslcInit(Handle session_handle);
* @param input_opt Input sslc options bitmask.
* @param hostname Server hostname.
*/
-Result sslcCreateContext(sslcContext *context, int sockfd, SSLC_SSLOpt input_opt, char *hostname);
+Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname);
/*
* @brief Destroys a sslc context. The associated sockfd must be closed manually.
* @param context sslc context.
* @param bitmask opt bitmask.
*/
-Result sslcContextClearOpt(sslcContext *context, SSLC_SSLOpt bitmask);
+Result sslcContextClearOpt(sslcContext *context, u32 bitmask);
+
+/*
+ * @brief This copies two strings from context state to the specified output buffers. Each string is only copied if it was successfully loaded. The maxsizes include the nul-terminator. TODO: Update this with what these strings actually are.
+ * @param context sslc context.
+ * @param str0 Output buffer for str0.
+ * @param str0_maxsize Max size of the str0 output buffer.
+ * @param str0 Output buffer for str1.
+ * @param str0_maxsize Max size of the str1 output buffer.
+ */
+Result sslcContextGetStrings(sslcContext *context, char *str0, u32 str0_maxsize, char *str1, u32 str1_maxsize);
/*
* @brief This loads an u32 from the specified context state. This needs updated once it's known what this field is for.
return cmdbuf[1];
}
-static Result sslcipc_CreateContext(sslcContext *context, int sockfd, SSLC_SSLOpt input_opt, char *hostname)
+static Result sslcipc_CreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname)
{
u32* cmdbuf=getThreadCommandBuffer();
u32 size = strlen(hostname)+1;
return cmdbuf[1];
}
+Result sslcContextGetStrings(sslcContext *context, char *str0, u32 str0_maxsize, char *str1, u32 str1_maxsize)
+{
+ u32* cmdbuf=getThreadCommandBuffer();
+
+ cmdbuf[0]=IPC_MakeHeader(0x1C,3,4); // 0x1C00C4
+ cmdbuf[1]=context->sslchandle;
+ cmdbuf[2]=str0_maxsize;
+ cmdbuf[3]=str1_maxsize;
+ cmdbuf[4]=IPC_Desc_Buffer(str0_maxsize, IPC_BUFFER_W);
+ cmdbuf[5]=(u32)str0;
+ cmdbuf[6]=IPC_Desc_Buffer(str1_maxsize, IPC_BUFFER_W);
+ cmdbuf[7]=(u32)str1;
+
+ Result ret=0;
+ if(R_FAILED(ret=svcSendSyncRequest(context->servhandle)))return ret;
+ ret = cmdbuf[1];
+
+ return ret;
+}
+
Result sslcContextGetState(sslcContext *context, u32 *out)
{
u32* cmdbuf=getThreadCommandBuffer();
return cmdbuf[1];
}
-Result sslcCreateContext(sslcContext *context, int sockfd, SSLC_SSLOpt input_opt, char *hostname)
+Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, char *hostname)
{
Result ret=0;
{
u32 type = 0;
- if(peek==true)type = 1;
+ if(peek)type = 1;
return sslcipc_DataTransfer(context, buf, len, type);
}
return sslcipc_ContextSetValue(context, 2, handle);
}
-Result sslcContextClearOpt(sslcContext *context, SSLC_SSLOpt bitmask)
+Result sslcContextClearOpt(sslcContext *context, u32 bitmask)
{
return sslcipc_ContextSetValue(context, 3, bitmask);
}