libctru  v2.4.1
Data Structures | Enumerations | Functions
sslc.h File Reference

SSLC(TLS) service. More...

Go to the source code of this file.

Data Structures

struct  sslcContext
 sslc context. More...
 

Enumerations

enum  SSLC_DefaultRootCert {
  SSLC_DefaultRootCert_Nintendo_CA = 0x1 ,
  SSLC_DefaultRootCert_Nintendo_CA_G2 = 0x2 ,
  SSLC_DefaultRootCert_Nintendo_CA_G3 = 0x3 ,
  SSLC_DefaultRootCert_Nintendo_Class2_CA = 0x4 ,
  SSLC_DefaultRootCert_Nintendo_Class2_CA_G2 = 0x5 ,
  SSLC_DefaultRootCert_Nintendo_Class2_CA_G3 = 0x6 ,
  SSLC_DefaultRootCert_CyberTrust = 0x7 ,
  SSLC_DefaultRootCert_AddTrust_External_CA = 0x8 ,
  SSLC_DefaultRootCert_COMODO = 0x9 ,
  SSLC_DefaultRootCert_USERTrust = 0xA ,
  SSLC_DefaultRootCert_DigiCert_EV = 0xB
}
 
enum  SSLC_DefaultClientCert { SSLC_DefaultClientCert_ClCertA = 0x40 }
 
enum  {
  SSLCOPT_Default = 0 ,
  SSLCOPT_DisableVerify = BIT(9) ,
  SSLCOPT_TLSv10 = BIT(11)
}
 sslc options. https://www.3dbrew.org/wiki/SSL_Services#SSLOpt
 

Functions

Result sslcInit (Handle session_handle)
 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.
 
void sslcExit (void)
 Exits SSLC.
 
Result sslcCreateRootCertChain (u32 *RootCertChain_contexthandle)
 Creates a RootCertChain. More...
 
Result sslcDestroyRootCertChain (u32 RootCertChain_contexthandle)
 Destroys a RootCertChain. More...
 
Result sslcAddTrustedRootCA (u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle)
 Adds a trusted RootCA cert to a RootCertChain. More...
 
Result sslcRootCertChainAddDefaultCert (u32 RootCertChain_contexthandle, SSLC_DefaultRootCert certID, u32 *cert_contexthandle)
 Adds a default RootCA cert to a RootCertChain. More...
 
Result sslcRootCertChainRemoveCert (u32 RootCertChain_contexthandle, u32 cert_contexthandle)
 Removes the specified cert from the RootCertChain. More...
 
Result sslcCreate8CertChain (u32 *CertChain_contexthandle)
 Creates an unknown CertChain. More...
 
Result sslcDestroy8CertChain (u32 CertChain_contexthandle)
 Destroys a CertChain from sslcCreate8CertChain(). More...
 
Result sslc8CertChainAddCert (u32 CertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle)
 Adds a cert to a CertChain from sslcCreate8CertChain(). More...
 
Result sslc8CertChainAddDefaultCert (u32 CertChain_contexthandle, u8 certID, u32 *cert_contexthandle)
 Adds a default cert to a CertChain from sslcCreate8CertChain(). More...
 
Result sslc8CertChainRemoveCert (u32 CertChain_contexthandle, u32 cert_contexthandle)
 Removes the specified cert from the CertChain from sslcCreate8CertChain(). More...
 
Result sslcOpenClientCertContext (const u8 *cert, u32 certsize, const u8 *key, u32 keysize, u32 *ClientCert_contexthandle)
 Opens a new ClientCert-context. More...
 
Result sslcOpenDefaultClientCertContext (SSLC_DefaultClientCert certID, u32 *ClientCert_contexthandle)
 Opens a ClientCert-context with a default certID. More...
 
Result sslcCloseClientCertContext (u32 ClientCert_contexthandle)
 Closes the specified ClientCert-context. More...
 
Result sslcSeedRNG (void)
 This uses ps:ps SeedRNG internally.
 
Result sslcGenerateRandomData (u8 *buf, u32 size)
 This uses ps:ps GenerateRandomData internally. More...
 
Result sslcCreateContext (sslcContext *context, int sockfd, u32 input_opt, const char *hostname)
 Creates a sslc context. More...
 
Result sslcDestroyContext (sslcContext *context)
 
Result sslcStartConnection (sslcContext *context, int *internal_retval, u32 *out)
 
Result sslcRead (sslcContext *context, void *buf, size_t len, bool peek)
 
Result sslcWrite (sslcContext *context, const void *buf, size_t len)
 
Result sslcContextSetRootCertChain (sslcContext *context, u32 handle)
 
Result sslcContextSetClientCert (sslcContext *context, u32 handle)
 
Result sslcContextSetHandle8 (sslcContext *context, u32 handle)
 
Result sslcContextClearOpt (sslcContext *context, u32 bitmask)
 
Result sslcContextGetProtocolCipher (sslcContext *context, char *outprotocols, u32 outprotocols_maxsize, char *outcipher, u32 outcipher_maxsize)
 
Result sslcContextGetState (sslcContext *context, u32 *out)
 
Result sslcContextInitSharedmem (sslcContext *context, u8 *buf, u32 size)
 
Result sslcAddCert (sslcContext *context, const u8 *buf, u32 size)
 

Detailed Description

SSLC(TLS) service.

https://3dbrew.org/wiki/SSL_Services

Function Documentation

◆ sslc8CertChainAddCert()

Result sslc8CertChainAddCert ( u32  CertChain_contexthandle,
const u8 cert,
u32  certsize,
u32 cert_contexthandle 
)

Adds a cert to a CertChain from sslcCreate8CertChain().

Parameters
CertChain_contexthandleCertChain to use.
certPointer to the cert.
certsizeSize of the cert.

◆ sslc8CertChainAddDefaultCert()

Result sslc8CertChainAddDefaultCert ( u32  CertChain_contexthandle,
u8  certID,
u32 cert_contexthandle 
)

Adds a default cert to a CertChain from sslcCreate8CertChain().

Not actually usable since no certIDs are implemented in SSL-module for this.

Parameters
CertChain_contexthandleCertChain to use.
certIDID of the cert to add.
cert_contexthandleOptional, the cert contexthandle can be written here.

◆ sslc8CertChainRemoveCert()

Result sslc8CertChainRemoveCert ( u32  CertChain_contexthandle,
u32  cert_contexthandle 
)

Removes the specified cert from the CertChain from sslcCreate8CertChain().

Parameters
CertChain_contexthandleCertChain to use.
cert_contexthandleCert contexthandle to remove from the CertChain.

◆ sslcAddTrustedRootCA()

Result sslcAddTrustedRootCA ( u32  RootCertChain_contexthandle,
const u8 cert,
u32  certsize,
u32 cert_contexthandle 
)

Adds a trusted RootCA cert to a RootCertChain.

Parameters
RootCertChain_contexthandleRootCertChain to use.
certPointer to the DER cert.
certsizeSize of the DER cert.
Examples
network/sslc/source/ssl.c.

◆ sslcCloseClientCertContext()

Result sslcCloseClientCertContext ( u32  ClientCert_contexthandle)

Closes the specified ClientCert-context.

Parameters
ClientCert_contexthandleClientCert-context to use.

◆ sslcCreate8CertChain()

Result sslcCreate8CertChain ( u32 CertChain_contexthandle)

Creates an unknown CertChain.

Parameters
CertChain_contexthandleOutput contexthandle.

◆ sslcCreateContext()

Result sslcCreateContext ( sslcContext context,
int  sockfd,
u32  input_opt,
const char *  hostname 
)

Creates a sslc context.

Parameters
contextsslc context.
sockfdSocket fd, this code automatically uses the required SOC command before using the actual sslc command.
input_optInput sslc options bitmask.
hostnameServer hostname.
Examples
network/sslc/source/ssl.c.

◆ sslcCreateRootCertChain()

Result sslcCreateRootCertChain ( u32 RootCertChain_contexthandle)

Creates a RootCertChain.

Parameters
RootCertChain_contexthandleOutput contexthandle.
Examples
network/sslc/source/ssl.c.

◆ sslcDestroy8CertChain()

Result sslcDestroy8CertChain ( u32  CertChain_contexthandle)

Destroys a CertChain from sslcCreate8CertChain().

Parameters
CertChain_contexthandleCertChain contexthandle.

◆ sslcDestroyRootCertChain()

Result sslcDestroyRootCertChain ( u32  RootCertChain_contexthandle)

Destroys a RootCertChain.

Parameters
RootCertChain_contexthandleRootCertChain contexthandle.
Examples
network/sslc/source/ssl.c.

◆ sslcGenerateRandomData()

Result sslcGenerateRandomData ( u8 buf,
u32  size 
)

This uses ps:ps GenerateRandomData internally.

Parameters
bufOutput buffer.
sizeOutput size.

◆ sslcOpenClientCertContext()

Result sslcOpenClientCertContext ( const u8 cert,
u32  certsize,
const u8 key,
u32  keysize,
u32 ClientCert_contexthandle 
)

Opens a new ClientCert-context.

Parameters
certPointer to the DER cert.
certsizeSize of the DER cert.
keyPointer to the DER key.
keysizeSize of the DER key.
ClientCert_contexthandleOutput contexthandle.

◆ sslcOpenDefaultClientCertContext()

Result sslcOpenDefaultClientCertContext ( SSLC_DefaultClientCert  certID,
u32 ClientCert_contexthandle 
)

Opens a ClientCert-context with a default certID.

Parameters
certIDID of the ClientCert to use.
ClientCert_contexthandleOutput contexthandle.

◆ sslcRootCertChainAddDefaultCert()

Result sslcRootCertChainAddDefaultCert ( u32  RootCertChain_contexthandle,
SSLC_DefaultRootCert  certID,
u32 cert_contexthandle 
)

Adds a default RootCA cert to a RootCertChain.

Parameters
RootCertChain_contexthandleRootCertChain to use.
certIDID of the cert to add.
cert_contexthandleOptional, the cert contexthandle can be written here.

◆ sslcRootCertChainRemoveCert()

Result sslcRootCertChainRemoveCert ( u32  RootCertChain_contexthandle,
u32  cert_contexthandle 
)

Removes the specified cert from the RootCertChain.

Parameters
RootCertChain_contexthandleRootCertChain to use.
cert_contexthandleCert contexthandle to remove from the RootCertChain.