]> Chaos Git - corbenik/ctrulib.git/commitdiff
Switched the sslopt enum to anonymous, and updated sslcRead(), as requested. Implemen...
authoryellows8 <yellows8@users.noreply.github.com>
Wed, 30 Mar 2016 19:02:18 +0000 (15:02 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Wed, 30 Mar 2016 19:02:18 +0000 (15:02 -0400)
libctru/include/3ds/services/sslc.h
libctru/source/services/sslc.c

index 0b1d52cc9d42022549a13341cf95f9a240238a5e..2aa0705ca57f696513a999348a501d60c4415c78 100644 (file)
@@ -29,11 +29,11 @@ typedef enum {
 } 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);
@@ -118,7 +118,7 @@ Result sslcGenerateRandomData(u8 *buf, u32 size);
  * @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.
@@ -179,7 +179,17 @@ Result sslcContextSetHandle8(sslcContext *context, u32 handle);
  * @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.
index 8e5c8d9c021608a8953bb8e62e75ae17dcbc6733..687952fcf6002e91de3b860f830e6ea2f0d4d315 100644 (file)
@@ -51,7 +51,7 @@ static Result sslcipc_Initialize(void)
        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;
@@ -312,6 +312,26 @@ static Result sslcipc_ContextSetValue(sslcContext *context, u32 type, u32 value)
        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();
@@ -341,7 +361,7 @@ static Result sslcipc_DestroyContext(sslcContext *context)
        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;
 
@@ -392,7 +412,7 @@ Result sslcRead(sslcContext *context, void *buf, size_t len, bool peek)
 {
        u32 type = 0;
 
-       if(peek==true)type = 1;
+       if(peek)type = 1;
 
        return sslcipc_DataTransfer(context, buf, len, type);
 }
@@ -417,7 +437,7 @@ Result sslcContextSetHandle8(sslcContext *context, u32 handle)
        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);
 }