28 #if !defined(MBEDTLS_CONFIG_FILE) 31 #include MBEDTLS_CONFIG_FILE 36 #if defined(MBEDTLS_RSA_C) 40 #if defined(MBEDTLS_ECP_C) 44 #if defined(MBEDTLS_ECDSA_C) 48 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \ 49 !defined(inline) && !defined(__cplusplus) 50 #define inline __inline 53 #define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80 54 #define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00 55 #define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80 56 #define MBEDTLS_ERR_PK_FILE_IO_ERROR -0x3E00 57 #define MBEDTLS_ERR_PK_KEY_INVALID_VERSION -0x3D80 58 #define MBEDTLS_ERR_PK_KEY_INVALID_FORMAT -0x3D00 59 #define MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -0x3C80 60 #define MBEDTLS_ERR_PK_PASSWORD_REQUIRED -0x3C00 61 #define MBEDTLS_ERR_PK_PASSWORD_MISMATCH -0x3B80 62 #define MBEDTLS_ERR_PK_INVALID_PUBKEY -0x3B00 63 #define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80 64 #define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00 65 #define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980 66 #define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900 69 #define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880 120 #define MBEDTLS_PK_DEBUG_MAX_ITEMS 3 136 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) 150 #if defined(MBEDTLS_RSA_C) 163 #if defined(MBEDTLS_ECP_C) 176 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) 180 typedef int (*mbedtls_pk_rsa_alt_decrypt_func)(
void *ctx,
int mode,
size_t *olen,
181 const unsigned char *input,
unsigned char *output,
182 size_t output_max_len );
183 typedef int (*mbedtls_pk_rsa_alt_sign_func)(
void *ctx,
184 int (*f_rng)(
void *,
unsigned char *, size_t),
void *p_rng,
186 const unsigned char *hash,
unsigned char *sig );
187 typedef size_t (*mbedtls_pk_rsa_alt_key_len_func)(
void *ctx );
215 #if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE) 250 #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) 267 mbedtls_pk_rsa_alt_decrypt_func decrypt_func,
268 mbedtls_pk_rsa_alt_sign_func sign_func,
269 mbedtls_pk_rsa_alt_key_len_func key_len_func );
332 const unsigned char *hash,
size_t hash_len,
333 const unsigned char *sig,
size_t sig_len );
357 const unsigned char *hash,
size_t hash_len,
358 const unsigned char *sig,
size_t sig_len,
392 const unsigned char *hash,
size_t hash_len,
393 const unsigned char *sig,
size_t sig_len );
421 const unsigned char *hash,
size_t hash_len,
422 unsigned char *sig,
size_t *sig_len,
423 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
450 const unsigned char *hash,
size_t hash_len,
451 unsigned char *sig,
size_t *sig_len,
452 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
473 const unsigned char *input,
size_t ilen,
474 unsigned char *output,
size_t *olen,
size_t osize,
475 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
494 const unsigned char *input,
size_t ilen,
495 unsigned char *output,
size_t *olen,
size_t osize,
496 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
537 #if defined(MBEDTLS_PK_PARSE_C) 568 const unsigned char *key,
size_t keylen,
569 const unsigned char *pwd,
size_t pwdlen );
594 const unsigned char *key,
size_t keylen );
596 #if defined(MBEDTLS_FS_IO) 619 const char *path,
const char *password );
642 #if defined(MBEDTLS_PK_WRITE_C) 656 int mbedtls_pk_write_key_der(
mbedtls_pk_context *ctx,
unsigned char *buf,
size_t size );
671 int mbedtls_pk_write_pubkey_der(
mbedtls_pk_context *ctx,
unsigned char *buf,
size_t size );
673 #if defined(MBEDTLS_PEM_WRITE_C) 684 int mbedtls_pk_write_pubkey_pem(
mbedtls_pk_context *ctx,
unsigned char *buf,
size_t size );
696 int mbedtls_pk_write_key_pem(
mbedtls_pk_context *ctx,
unsigned char *buf,
size_t size );
705 #if defined(MBEDTLS_PK_PARSE_C) 716 int mbedtls_pk_parse_subpubkey(
unsigned char **p,
const unsigned char *end,
720 #if defined(MBEDTLS_PK_WRITE_C) 731 int mbedtls_pk_write_pubkey(
unsigned char **p,
unsigned char *start,
739 #if defined(MBEDTLS_FS_IO) 740 int mbedtls_pk_load_file(
const char *path,
unsigned char **buf,
size_t *n );
Options for RSASSA-PSS signature verification. See mbedtls_rsa_rsassa_pss_verify_ext()
Definition: pk.h:92
Public key container.
Definition: pk.h:130
void mbedtls_pk_init(mbedtls_pk_context *ctx)
Initialize a mbedtls_pk_context (as NONE).
mbedtls_pk_debug_type
Types for interfacing with the debug module.
Definition: pk.h:102
int mbedtls_pk_sign_restartable(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, mbedtls_pk_restart_ctx *rs_ctx)
Restartable version of mbedtls_pk_sign()
struct mbedtls_pk_rsassa_pss_options mbedtls_pk_rsassa_pss_options
Options for RSASSA-PSS signature verification. See mbedtls_rsa_rsassa_pss_verify_ext()
int mbedtls_pk_can_do(const mbedtls_pk_context *ctx, mbedtls_pk_type_t type)
Tell if a context can do the operation given by type.
This file provides an API for Elliptic Curves over GF(P) (ECP).
int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options, mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature, with options. (Includes verification of the padding depending on type....
The ECP key-pair structure.
Definition: ecp.h:326
This file contains ECDSA definitions and functions.
const mbedtls_pk_info_t * pk_info
Definition: pk.h:132
int mbedtls_pk_encrypt(mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Encrypt message (including padding if relevant).
int mbedtls_pk_verify_restartable(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len, mbedtls_pk_restart_ctx *rs_ctx)
Restartable version of mbedtls_pk_verify()
size_t mbedtls_pk_get_bitlen(const mbedtls_pk_context *ctx)
Get the size in bits of the underlying key.
mbedtls_pk_type_t
Public key types.
Definition: pk.h:78
Configuration options (set of defines)
void * value
Definition: pk.h:116
int mbedtls_pk_sign(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Make signature, including padding if relevant.
void mbedtls_pk_restart_ctx
Definition: pk.h:147
const char * name
Definition: pk.h:115
int mbedtls_pk_debug(const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items)
Export debug information.
void * pk_ctx
Definition: pk.h:133
Definition: pk_internal.h:36
void mbedtls_pk_free(mbedtls_pk_context *ctx)
Free the components of a mbedtls_pk_context.
int expected_salt_len
Definition: pk.h:95
mbedtls_md_type_t mgf1_hash_id
Definition: pk.h:94
This file contains the generic message-digest wrapper.
This file provides an API for the RSA public-key cryptosystem.
int mbedtls_pk_verify(mbedtls_pk_context *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature (including padding if relevant).
mbedtls_pk_type_t mbedtls_pk_get_type(const mbedtls_pk_context *ctx)
Get the key type.
const char * mbedtls_pk_get_name(const mbedtls_pk_context *ctx)
Access the type name.
int mbedtls_pk_setup(mbedtls_pk_context *ctx, const mbedtls_pk_info_t *info)
Initialize a PK context with the information given and allocates the type-specific PK subcontext.
struct mbedtls_pk_context mbedtls_pk_context
Public key container.
mbedtls_pk_debug_type type
Definition: pk.h:114
int mbedtls_pk_check_pair(const mbedtls_pk_context *pub, const mbedtls_pk_context *prv)
Check if a public-private pair of keys matches.
mbedtls_md_type_t
Supported message digests.
Definition: md.h:58
struct mbedtls_pk_debug_item mbedtls_pk_debug_item
Item to send to the debug module.
The RSA context structure.
Definition: rsa.h:100
Item to send to the debug module.
Definition: pk.h:112
const mbedtls_pk_info_t * mbedtls_pk_info_from_type(mbedtls_pk_type_t pk_type)
Return information associated with the given PK type.
int mbedtls_pk_decrypt(mbedtls_pk_context *ctx, const unsigned char *input, size_t ilen, unsigned char *output, size_t *olen, size_t osize, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Decrypt message (including padding if relevant).