RetroArch
Macros | Functions
x509.c File Reference
#include "mbedtls/config.h"
#include "mbedtls/x509.h"
#include "mbedtls/asn1.h"
#include "mbedtls/oid.h"
#include <stdio.h>
#include <string.h>
#include "mbedtls/pem.h"
#include "mbedtls/platform.h"
#include "mbedtls/platform_time.h"
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include "mbedtls/x509_crt.h"
#include "mbedtls/certs.h"
Include dependency graph for x509.c:

Macros

#define CHECK(code)   if( ( ret = code ) != 0 ){ return( ret ); }
 
#define CHECK_RANGE(min, max, val)   if( val < min || val > max ){ return( ret ); }
 

Functions

int mbedtls_x509_get_serial (unsigned char **p, const unsigned char *end, mbedtls_x509_buf *serial)
 
int mbedtls_x509_get_alg_null (unsigned char **p, const unsigned char *end, mbedtls_x509_buf *alg)
 
int mbedtls_x509_get_alg (unsigned char **p, const unsigned char *end, mbedtls_x509_buf *alg, mbedtls_x509_buf *params)
 
static int x509_get_hash_alg (const mbedtls_x509_buf *alg, mbedtls_md_type_t *md_alg)
 
int mbedtls_x509_get_rsassa_pss_params (const mbedtls_x509_buf *params, mbedtls_md_type_t *md_alg, mbedtls_md_type_t *mgf_md, int *salt_len)
 
static int x509_get_attr_type_value (unsigned char **p, const unsigned char *end, mbedtls_x509_name *cur)
 
int mbedtls_x509_get_name (unsigned char **p, const unsigned char *end, mbedtls_x509_name *cur)
 
static int x509_parse_int (unsigned char **p, size_t n, int *res)
 
static int x509_date_is_valid (const mbedtls_x509_time *time)
 
static int x509_parse_time (unsigned char **p, size_t len, size_t yearlen, mbedtls_x509_time *time)
 
int mbedtls_x509_get_time (unsigned char **p, const unsigned char *end, mbedtls_x509_time *time)
 
int mbedtls_x509_get_sig (unsigned char **p, const unsigned char *end, mbedtls_x509_buf *sig)
 
int mbedtls_x509_get_sig_alg (const mbedtls_x509_buf *sig_oid, const mbedtls_x509_buf *sig_params, mbedtls_md_type_t *md_alg, mbedtls_pk_type_t *pk_alg, void **sig_opts)
 
int mbedtls_x509_get_ext (unsigned char **p, const unsigned char *end, mbedtls_x509_buf *ext, int tag)
 
int mbedtls_x509_dn_gets (char *buf, size_t size, const mbedtls_x509_name *dn)
 Store the certificate DN in printable form into buf; no more than size characters will be written. More...
 
int mbedtls_x509_serial_gets (char *buf, size_t size, const mbedtls_x509_buf *serial)
 Store the certificate serial in printable form into buf; no more than size characters will be written. More...
 
int mbedtls_x509_sig_alg_gets (char *buf, size_t size, const mbedtls_x509_buf *sig_oid, mbedtls_pk_type_t pk_alg, mbedtls_md_type_t md_alg, const void *sig_opts)
 
int mbedtls_x509_key_size_helper (char *buf, size_t buf_size, const char *name)
 
static int x509_get_current_time (mbedtls_x509_time *now)
 
static int x509_check_time (const mbedtls_x509_time *before, const mbedtls_x509_time *after)
 
int mbedtls_x509_time_is_past (const mbedtls_x509_time *to)
 Check a given mbedtls_x509_time against the system time and tell if it's in the past. More...
 
int mbedtls_x509_time_is_future (const mbedtls_x509_time *from)
 Check a given mbedtls_x509_time against the system time and tell if it's in the future. More...
 
int mbedtls_x509_self_test (int verbose)
 Checkup routine. More...
 

Macro Definition Documentation

◆ CHECK

#define CHECK (   code)    if( ( ret = code ) != 0 ){ return( ret ); }

◆ CHECK_RANGE

#define CHECK_RANGE (   min,
  max,
  val 
)    if( val < min || val > max ){ return( ret ); }

Function Documentation

◆ mbedtls_x509_dn_gets()

int mbedtls_x509_dn_gets ( char *  buf,
size_t  size,
const mbedtls_x509_name *  dn 
)

Store the certificate DN in printable form into buf; no more than size characters will be written.

Parameters
bufBuffer to write to
sizeMaximum size of buffer
dnThe X509 name to represent
Returns
The length of the string written (not including the terminated nul byte), or a negative error code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_alg()

int mbedtls_x509_get_alg ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_buf *  alg,
mbedtls_x509_buf *  params 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_alg_null()

int mbedtls_x509_get_alg_null ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_buf *  alg 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_ext()

int mbedtls_x509_get_ext ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_buf *  ext,
int  tag 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_name()

int mbedtls_x509_get_name ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_name *  cur 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_rsassa_pss_params()

int mbedtls_x509_get_rsassa_pss_params ( const mbedtls_x509_buf *  params,
mbedtls_md_type_t *  md_alg,
mbedtls_md_type_t *  mgf_md,
int *  salt_len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_serial()

int mbedtls_x509_get_serial ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_buf *  serial 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_sig()

int mbedtls_x509_get_sig ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_buf *  sig 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_sig_alg()

int mbedtls_x509_get_sig_alg ( const mbedtls_x509_buf *  sig_oid,
const mbedtls_x509_buf *  sig_params,
mbedtls_md_type_t *  md_alg,
mbedtls_pk_type_t *  pk_alg,
void **  sig_opts 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_get_time()

int mbedtls_x509_get_time ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_time *  time 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_key_size_helper()

int mbedtls_x509_key_size_helper ( char *  buf,
size_t  buf_size,
const char *  name 
)
Here is the caller graph for this function:

◆ mbedtls_x509_self_test()

int mbedtls_x509_self_test ( int  verbose)

Checkup routine.

Returns
0 if successful, or 1 if the test failed
Here is the call graph for this function:

◆ mbedtls_x509_serial_gets()

int mbedtls_x509_serial_gets ( char *  buf,
size_t  size,
const mbedtls_x509_buf *  serial 
)

Store the certificate serial in printable form into buf; no more than size characters will be written.

Parameters
bufBuffer to write to
sizeMaximum size of buffer
serialThe X509 serial to represent
Returns
The length of the string written (not including the terminated nul byte), or a negative error code.
Here is the caller graph for this function:

◆ mbedtls_x509_sig_alg_gets()

int mbedtls_x509_sig_alg_gets ( char *  buf,
size_t  size,
const mbedtls_x509_buf *  sig_oid,
mbedtls_pk_type_t  pk_alg,
mbedtls_md_type_t  md_alg,
const void *  sig_opts 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_time_is_future()

int mbedtls_x509_time_is_future ( const mbedtls_x509_time *  time)

Check a given mbedtls_x509_time against the system time and tell if it's in the future.

Note
Intended usage is "if( is_future( valid_from ) ) ERROR". Hence the return value of 1 if on internal errors.
Parameters
timembedtls_x509_time to check
Returns
1 if the given time is in the future or an error occured, 0 otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_x509_time_is_past()

int mbedtls_x509_time_is_past ( const mbedtls_x509_time *  time)

Check a given mbedtls_x509_time against the system time and tell if it's in the past.

Note
Intended usage is "if( is_past( valid_to ) ) ERROR". Hence the return value of 1 if on internal errors.
Parameters
timembedtls_x509_time to check
Returns
1 if the given time is in the past or an error occured, 0 otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ x509_check_time()

static int x509_check_time ( const mbedtls_x509_time *  before,
const mbedtls_x509_time *  after 
)
static
Here is the caller graph for this function:

◆ x509_date_is_valid()

static int x509_date_is_valid ( const mbedtls_x509_time *  time)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ x509_get_attr_type_value()

static int x509_get_attr_type_value ( unsigned char **  p,
const unsigned char *  end,
mbedtls_x509_name *  cur 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ x509_get_current_time()

static int x509_get_current_time ( mbedtls_x509_time *  now)
static
Here is the caller graph for this function:

◆ x509_get_hash_alg()

static int x509_get_hash_alg ( const mbedtls_x509_buf *  alg,
mbedtls_md_type_t *  md_alg 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ x509_parse_int()

static int x509_parse_int ( unsigned char **  p,
size_t  n,
int *  res 
)
static
Here is the caller graph for this function:

◆ x509_parse_time()

static int x509_parse_time ( unsigned char **  p,
size_t  len,
size_t  yearlen,
mbedtls_x509_time *  time 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: