pkparse.c File Reference

#include "polarssl/config.h"
#include "polarssl/pk.h"
#include "polarssl/asn1.h"
#include "polarssl/oid.h"
#include "polarssl/rsa.h"
#include "polarssl/ecp.h"
#include "polarssl/ecdsa.h"
#include "polarssl/pem.h"
#include "polarssl/pkcs5.h"
#include "polarssl/pkcs12.h"
#include <stdlib.h>
Include dependency graph for pkparse.c:

Go to the source code of this file.

Defines

#define polarssl_malloc   malloc
#define polarssl_free   free

Functions

static int load_file (const char *path, unsigned char **buf, size_t *n)
int pk_parse_keyfile (pk_context *ctx, const char *path, const char *pwd)
 Load and parse a private key.
int pk_parse_public_keyfile (pk_context *ctx, const char *path)
 Load and parse a public key.
static int pk_get_ecparams (unsigned char **p, const unsigned char *end, asn1_buf *params)
static int pk_use_ecparams (const asn1_buf *params, ecp_group *grp)
static int pk_get_ecpubkey (unsigned char **p, const unsigned char *end, ecp_keypair *key)
static int pk_get_rsapubkey (unsigned char **p, const unsigned char *end, rsa_context *rsa)
static int pk_get_pk_alg (unsigned char **p, const unsigned char *end, pk_type_t *pk_alg, asn1_buf *params)
int pk_parse_subpubkey (unsigned char **p, const unsigned char *end, pk_context *pk)
 Parse a SubjectPublicKeyInfo DER structure.
static int pk_parse_key_pkcs1_der (rsa_context *rsa, const unsigned char *key, size_t keylen)
static int pk_parse_key_sec1_der (ecp_keypair *eck, const unsigned char *key, size_t keylen)
static int pk_parse_key_pkcs8_unencrypted_der (pk_context *pk, const unsigned char *key, size_t keylen)
static int pk_parse_key_pkcs8_encrypted_der (pk_context *pk, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
int pk_parse_key (pk_context *pk, const unsigned char *key, size_t keylen, const unsigned char *pwd, size_t pwdlen)
 Parse a private key.
int pk_parse_public_key (pk_context *ctx, const unsigned char *key, size_t keylen)
 Parse a public key.

Define Documentation

#define polarssl_free   free

Definition at line 58 of file pkparse.c.

#define polarssl_malloc   malloc

Definition at line 57 of file pkparse.c.


Function Documentation

static int load_file ( const char *  path,
unsigned char **  buf,
size_t *  n 
) [static]
static int pk_get_ecparams ( unsigned char **  p,
const unsigned char *  end,
asn1_buf params 
) [static]
static int pk_get_ecpubkey ( unsigned char **  p,
const unsigned char *  end,
ecp_keypair key 
) [static]
static int pk_get_pk_alg ( unsigned char **  p,
const unsigned char *  end,
pk_type_t pk_alg,
asn1_buf params 
) [static]
static int pk_get_rsapubkey ( unsigned char **  p,
const unsigned char *  end,
rsa_context rsa 
) [static]
int pk_parse_key ( pk_context ctx,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  pwd,
size_t  pwdlen 
)
static int pk_parse_key_pkcs1_der ( rsa_context rsa,
const unsigned char *  key,
size_t  keylen 
) [static]
static int pk_parse_key_pkcs8_encrypted_der ( pk_context pk,
const unsigned char *  key,
size_t  keylen,
const unsigned char *  pwd,
size_t  pwdlen 
) [static]
static int pk_parse_key_pkcs8_unencrypted_der ( pk_context pk,
const unsigned char *  key,
size_t  keylen 
) [static]
static int pk_parse_key_sec1_der ( ecp_keypair eck,
const unsigned char *  key,
size_t  keylen 
) [static]
int pk_parse_keyfile ( pk_context ctx,
const char *  path,
const char *  password 
)

Load and parse a private key.

Parameters:
ctx key to be initialized
path filename to read the private key from
password password to decrypt the file (can be NULL)
Returns:
0 if successful, or a specific PK or PEM error code

Definition at line 107 of file pkparse.c.

References load_file(), pk_parse_key(), and polarssl_free.

Referenced by test_suite_pk_parse_keyfile_ec(), test_suite_pk_parse_keyfile_rsa(), test_suite_pk_write_key_check(), test_suite_x509_crt_check(), and test_suite_x509_csr_check().

int pk_parse_public_key ( pk_context ctx,
const unsigned char *  key,
size_t  keylen 
)

Parse a public key.

Parameters:
ctx key to be initialized
key input buffer
keylen size of the buffer
Returns:
0 if successful, or a specific PK or PEM error code

Definition at line 926 of file pkparse.c.

References pem_context::buf, pem_context::buflen, pem_free(), pem_init(), pem_read_buffer(), pk_parse_subpubkey(), and POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT.

Referenced by pk_parse_public_keyfile().

int pk_parse_public_keyfile ( pk_context ctx,
const char *  path 
)

Load and parse a public key.

Parameters:
ctx key to be initialized
path filename to read the private key from
Returns:
0 if successful, or a specific PK or PEM error code

Definition at line 132 of file pkparse.c.

References load_file(), pk_parse_public_key(), and polarssl_free.

Referenced by test_suite_pk_parse_public_keyfile_ec(), test_suite_pk_parse_public_keyfile_rsa(), and test_suite_pk_write_pubkey_check().

int pk_parse_subpubkey ( unsigned char **  p,
const unsigned char *  end,
pk_context pk 
)
static int pk_use_ecparams ( const asn1_buf params,
ecp_group grp 
) [static]

Generated on 9 Apr 2014 for PolarSSL v1.3.2 by  doxygen 1.6.1