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_contexthandle | CertChain to use.
  cert | Pointer to the cert.
  certsize | Size 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_contexthandle | CertChain to use.
  certID | ID of the cert to add.
  cert_contexthandle | Optional, 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_contexthandle | CertChain to use.
  cert_contexthandle | Cert 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_contexthandle | RootCertChain to use.
  cert | Pointer to the DER cert.
  certsize | Size of the DER cert.

Examples
  network/sslc/source/ssl.c.

## sslcCloseClientCertContext()

Result sslcCloseClientCertContext | ( | u32 | ClientCert_contexthandle | ) |

Closes the specified ClientCert-context.

Parameters

  ClientCert_contexthandle | ClientCert-context to use.

## sslcCreate8CertChain()

Result sslcCreate8CertChain | ( | u32 * | CertChain_contexthandle | ) |

Creates an unknown CertChain.

Parameters

  CertChain_contexthandle | Output contexthandle.

## sslcCreateContext()

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

Creates a sslc context.

Parameters

  context | sslc context.
  sockfd | Socket fd, this code automatically uses the required SOC command before using the actual sslc command.
  input_opt | Input sslc options bitmask.
  hostname | Server hostname.

Examples
  network/sslc/source/ssl.c.

## sslcCreateRootCertChain()

Result sslcCreateRootCertChain | ( | u32 * | RootCertChain_contexthandle | ) |

Creates a RootCertChain.

Parameters

  RootCertChain_contexthandle | Output contexthandle.

Examples
  network/sslc/source/ssl.c.

## sslcDestroy8CertChain()

Result sslcDestroy8CertChain | ( | u32 | CertChain_contexthandle | ) |

Destroys a CertChain from sslcCreate8CertChain().

Parameters

  CertChain_contexthandle | CertChain contexthandle.

## sslcDestroyRootCertChain()

Result sslcDestroyRootCertChain | ( | u32 | RootCertChain_contexthandle | ) |

Destroys a RootCertChain.

Parameters

  RootCertChain_contexthandle | RootCertChain contexthandle.

Examples
  network/sslc/source/ssl.c.

## sslcGenerateRandomData()

Result sslcGenerateRandomData | ( | u8 * | buf,
|  | u32 | size
| ) |  |

This uses ps:ps GenerateRandomData internally.

Parameters

  buf | Output buffer.
  size | Output size.

## sslcOpenClientCertContext()

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

Opens a new ClientCert-context.

Parameters

  cert | Pointer to the DER cert.
  certsize | Size of the DER cert.
  key | Pointer to the DER key.
  keysize | Size of the DER key.
  ClientCert_contexthandle | Output contexthandle.

## sslcOpenDefaultClientCertContext()

Result sslcOpenDefaultClientCertContext | ( | SSLC_DefaultClientCert | certID,
|  | u32 * | ClientCert_contexthandle
| ) |  |

Opens a ClientCert-context with a default certID.

Parameters

  certID | ID of the ClientCert to use.
  ClientCert_contexthandle | Output contexthandle.

## sslcRootCertChainAddDefaultCert()

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

Adds a default RootCA cert to a RootCertChain.

Parameters

  RootCertChain_contexthandle | RootCertChain to use.
  certID | ID of the cert to add.
  cert_contexthandle | Optional, 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_contexthandle | RootCertChain to use.
  cert_contexthandle | Cert contexthandle to remove from the RootCertChain.