RetroArch
Functions
pkparse.c File Reference
#include "mbedtls/config.h"
#include "mbedtls/pk.h"
#include "mbedtls/asn1.h"
#include "mbedtls/oid.h"
#include <string.h>
#include "mbedtls/rsa.h"
#include "mbedtls/ecp.h"
#include "mbedtls/ecdsa.h"
#include "mbedtls/pem.h"
#include "mbedtls/pkcs5.h"
#include "mbedtls/pkcs12.h"
#include "mbedtls/platform.h"
#include "arc4_alt.h"
Include dependency graph for pkparse.c:

Functions

int mbedtls_pk_load_file (const char *path, unsigned char **buf, size_t *n)
 
int mbedtls_pk_parse_keyfile (mbedtls_pk_context *ctx, const char *path, const char *pwd)
 Load and parse a private key. More...
 
int mbedtls_pk_parse_public_keyfile (mbedtls_pk_context *ctx, const char *path)
 Load and parse a public key. More...
 
static int pk_get_ecparams (unsigned char **p, const unsigned char *end, mbedtls_asn1_buf *params)
 
static int pk_group_from_specified (const mbedtls_asn1_buf *params, mbedtls_ecp_group *grp)
 
static int pk_group_id_from_group (const mbedtls_ecp_group *grp, mbedtls_ecp_group_id *grp_id)
 
static int pk_group_id_from_specified (const mbedtls_asn1_buf *params, mbedtls_ecp_group_id *grp_id)
 
static int pk_use_ecparams (const mbedtls_asn1_buf *params, mbedtls_ecp_group *grp)
 
static int pk_get_ecpubkey (unsigned char **p, const unsigned char *end, mbedtls_ecp_keypair *key)
 
static int pk_get_rsapubkey (unsigned char **p, const unsigned char *end, mbedtls_rsa_context *rsa)
 
static int pk_get_pk_alg (unsigned char **p, const unsigned char *end, mbedtls_pk_type_t *pk_alg, mbedtls_asn1_buf *params)
 
int mbedtls_pk_parse_subpubkey (unsigned char **p, const unsigned char *end, mbedtls_pk_context *pk)
 Parse a SubjectPublicKeyInfo DER structure. More...
 
static int pk_parse_key_pkcs1_der (mbedtls_rsa_context *rsa, const unsigned char *key, size_t keylen)
 
static int pk_parse_key_sec1_der (mbedtls_ecp_keypair *eck, const unsigned char *key, size_t keylen)
 
static int pk_parse_key_pkcs8_unencrypted_der (mbedtls_pk_context *pk, const unsigned char *key, size_t keylen)
 
static int pk_parse_key_pkcs8_encrypted_der (mbedtls_pk_context *pk, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
 
int mbedtls_pk_parse_key (mbedtls_pk_context *pk, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
 Parse a private key in PEM or DER format. More...
 
int mbedtls_pk_parse_public_key (mbedtls_pk_context *ctx, const unsigned char *key, size_t keylen)
 Parse a public key in PEM or DER format. More...
 

Function Documentation

◆ mbedtls_pk_load_file()

int mbedtls_pk_load_file ( const char *  path,
unsigned char **  buf,
size_t *  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_pk_parse_key()

int mbedtls_pk_parse_key ( mbedtls_pk_context ctx,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  pwd,
size_t  pwdlen 
)

Parse a private key in PEM or DER format.

Parameters
ctxkey to be initialized
keyinput buffer
keylensize of the buffer (including the terminating null byte for PEM data)
pwdpassword for decryption (optional)
pwdlensize of the password
Note
On entry, ctx must be empty, either freshly initialised with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a specific key type, check the result with mbedtls_pk_can_do().
The key is also checked for correctness.
Returns
0 if successful, or a specific PK or PEM error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_pk_parse_keyfile()

int mbedtls_pk_parse_keyfile ( mbedtls_pk_context ctx,
const char *  path,
const char *  password 
)

Load and parse a private key.

Parameters
ctxkey to be initialized
pathfilename to read the private key from
passwordpassword to decrypt the file (can be NULL)
Note
On entry, ctx must be empty, either freshly initialised with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a specific key type, check the result with mbedtls_pk_can_do().
The key is also checked for correctness.
Returns
0 if successful, or a specific PK or PEM error code
Here is the call graph for this function:

◆ mbedtls_pk_parse_public_key()

int mbedtls_pk_parse_public_key ( mbedtls_pk_context ctx,
const unsigned char *  key,
size_t  keylen 
)

Parse a public key in PEM or DER format.

Parameters
ctxkey to be initialized
keyinput buffer
keylensize of the buffer (including the terminating null byte for PEM data)
Note
On entry, ctx must be empty, either freshly initialised with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a specific key type, check the result with mbedtls_pk_can_do().
The key is also checked for correctness.
Returns
0 if successful, or a specific PK or PEM error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mbedtls_pk_parse_public_keyfile()

int mbedtls_pk_parse_public_keyfile ( mbedtls_pk_context ctx,
const char *  path 
)

Load and parse a public key.

Parameters
ctxkey to be initialized
pathfilename to read the public key from
Note
On entry, ctx must be empty, either freshly initialised with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a specific key type, check the result with mbedtls_pk_can_do().
The key is also checked for correctness.
Returns
0 if successful, or a specific PK or PEM error code
Here is the call graph for this function:

◆ mbedtls_pk_parse_subpubkey()

int mbedtls_pk_parse_subpubkey ( unsigned char **  p,
const unsigned char *  end,
mbedtls_pk_context pk 
)

Parse a SubjectPublicKeyInfo DER structure.

Parameters
pthe position in the ASN.1 data
endend of the buffer
pkthe key to fill
Returns
0 if successful, or a specific PK error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_get_ecparams()

static int pk_get_ecparams ( unsigned char **  p,
const unsigned char *  end,
mbedtls_asn1_buf params 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_get_ecpubkey()

static int pk_get_ecpubkey ( unsigned char **  p,
const unsigned char *  end,
mbedtls_ecp_keypair key 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_get_pk_alg()

static int pk_get_pk_alg ( unsigned char **  p,
const unsigned char *  end,
mbedtls_pk_type_t pk_alg,
mbedtls_asn1_buf params 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_get_rsapubkey()

static int pk_get_rsapubkey ( unsigned char **  p,
const unsigned char *  end,
mbedtls_rsa_context rsa 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_group_from_specified()

static int pk_group_from_specified ( const mbedtls_asn1_buf params,
mbedtls_ecp_group grp 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_group_id_from_group()

static int pk_group_id_from_group ( const mbedtls_ecp_group grp,
mbedtls_ecp_group_id grp_id 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_group_id_from_specified()

static int pk_group_id_from_specified ( const mbedtls_asn1_buf params,
mbedtls_ecp_group_id grp_id 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_parse_key_pkcs1_der()

static int pk_parse_key_pkcs1_der ( mbedtls_rsa_context rsa,
const unsigned char *  key,
size_t  keylen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_parse_key_pkcs8_encrypted_der()

static int pk_parse_key_pkcs8_encrypted_der ( mbedtls_pk_context pk,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  pwd,
size_t  pwdlen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_parse_key_pkcs8_unencrypted_der()

static int pk_parse_key_pkcs8_unencrypted_der ( mbedtls_pk_context pk,
const unsigned char *  key,
size_t  keylen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_parse_key_sec1_der()

static int pk_parse_key_sec1_der ( mbedtls_ecp_keypair eck,
const unsigned char *  key,
size_t  keylen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pk_use_ecparams()

static int pk_use_ecparams ( const mbedtls_asn1_buf params,
mbedtls_ecp_group grp 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: