53#if !defined(MBEDTLS_CONFIG_FILE)
56#include MBEDTLS_CONFIG_FILE
61#if defined(MBEDTLS_RSA_C)
65#if defined(MBEDTLS_ECP_C)
69#if defined(MBEDTLS_ECDSA_C)
73#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
74 !defined(inline) && !defined(__cplusplus)
75#define inline __inline
78#define MBEDTLS_ERR_PK_ALLOC_FAILED -0x3F80
79#define MBEDTLS_ERR_PK_TYPE_MISMATCH -0x3F00
80#define MBEDTLS_ERR_PK_BAD_INPUT_DATA -0x3E80
81#define MBEDTLS_ERR_PK_FILE_IO_ERROR -0x3E00
82#define MBEDTLS_ERR_PK_KEY_INVALID_VERSION -0x3D80
83#define MBEDTLS_ERR_PK_KEY_INVALID_FORMAT -0x3D00
84#define MBEDTLS_ERR_PK_UNKNOWN_PK_ALG -0x3C80
85#define MBEDTLS_ERR_PK_PASSWORD_REQUIRED -0x3C00
86#define MBEDTLS_ERR_PK_PASSWORD_MISMATCH -0x3B80
87#define MBEDTLS_ERR_PK_INVALID_PUBKEY -0x3B00
88#define MBEDTLS_ERR_PK_INVALID_ALG -0x3A80
89#define MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE -0x3A00
90#define MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE -0x3980
91#define MBEDTLS_ERR_PK_SIG_LEN_MISMATCH -0x3900
94#define MBEDTLS_ERR_PK_HW_ACCEL_FAILED -0x3880
145#define MBEDTLS_PK_DEBUG_MAX_ITEMS 3
161#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
175#if defined(MBEDTLS_RSA_C)
188#if defined(MBEDTLS_ECP_C)
201#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
206 const unsigned char *
input,
unsigned char *output,
207 size_t output_max_len );
209 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
211 const unsigned char *
hash,
unsigned char *sig );
240#if defined(MBEDTLS_ECDSA_C) && defined(MBEDTLS_ECP_RESTARTABLE)
275#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
357 const unsigned char *
hash,
size_t hash_len,
358 const unsigned char *sig,
size_t sig_len );
382 const unsigned char *
hash,
size_t hash_len,
383 const unsigned char *sig,
size_t sig_len,
417 const unsigned char *
hash,
size_t hash_len,
418 const unsigned char *sig,
size_t sig_len );
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 );
483 const unsigned char *
hash,
size_t hash_len,
484 unsigned char *sig,
size_t *sig_len,
485 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng,
506 const unsigned char *
input,
size_t ilen,
507 unsigned char *output,
size_t *olen,
size_t osize,
508 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
527 const unsigned char *
input,
size_t ilen,
528 unsigned char *output,
size_t *olen,
size_t osize,
529 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
570#if defined(MBEDTLS_PK_PARSE_C)
601 const unsigned char *
key,
size_t keylen,
602 const unsigned char *
pwd,
size_t pwdlen );
627 const unsigned char *
key,
size_t keylen );
629#if defined(MBEDTLS_FS_IO)
675#if defined(MBEDTLS_PK_WRITE_C)
706#if defined(MBEDTLS_PEM_WRITE_C)
738#if defined(MBEDTLS_PK_PARSE_C)
753#if defined(MBEDTLS_PK_WRITE_C)
764int mbedtls_pk_write_pubkey(
unsigned char **
p,
unsigned char *
start,
772#if defined(MBEDTLS_FS_IO)
773int mbedtls_pk_load_file(
const char *
path,
unsigned char **
buf,
size_t *
n );
void pwd(int argc, const char *argv[])
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
This file contains ECDSA definitions and functions.
GLuint GLuint GLsizei GLenum type
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLenum GLenum input
This file contains the generic message-digest wrapper.
mbedtls_md_type_t
Supported message digests.
int(* mbedtls_pk_rsa_alt_decrypt_func)(void *ctx, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len)
Types for RSA-alt abstraction.
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.
int mbedtls_pk_debug(const mbedtls_pk_context *ctx, mbedtls_pk_debug_item *items)
Export debug information.
static size_t mbedtls_pk_get_len(const mbedtls_pk_context *ctx)
Get the length in bytes of the underlying key.
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()
int mbedtls_pk_parse_subpubkey(unsigned char **p, const unsigned char *end, mbedtls_pk_context *pk)
Parse a SubjectPublicKeyInfo DER structure.
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.
mbedtls_pk_type_t
Public key types.
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).
static mbedtls_rsa_context * mbedtls_pk_rsa(const mbedtls_pk_context pk)
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.
static mbedtls_ecp_keypair * mbedtls_pk_ec(const mbedtls_pk_context pk)
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.
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....
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_pk_debug_type
Types for interfacing with the debug module.
void mbedtls_pk_init(mbedtls_pk_context *ctx)
Initialize a mbedtls_pk_context (as NONE).
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_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()
mbedtls_pk_type_t mbedtls_pk_get_type(const mbedtls_pk_context *ctx)
Get the key type.
int mbedtls_pk_setup_rsa_alt(mbedtls_pk_context *ctx, void *key, mbedtls_pk_rsa_alt_decrypt_func decrypt_func, mbedtls_pk_rsa_alt_sign_func sign_func, mbedtls_pk_rsa_alt_key_len_func key_len_func)
Initialize an RSA-alt context.
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).
size_t(* mbedtls_pk_rsa_alt_key_len_func)(void *ctx)
void mbedtls_pk_free(mbedtls_pk_context *ctx)
Free the components of a mbedtls_pk_context.
int(* mbedtls_pk_rsa_alt_sign_func)(void *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, mbedtls_md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
void mbedtls_pk_restart_ctx
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.
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).
const char * mbedtls_pk_get_name(const mbedtls_pk_context *ctx)
Access the type name.
This file provides an API for the RSA public-key cryptosystem.
#define mbedtls_pk_get_bitlen
This file provides an API for Elliptic Curves over GF(P) (ECP).
The ECP key-pair structure.
const mbedtls_pk_info_t * pk_info
Item to send to the debug module.
mbedtls_pk_debug_type type
Options for RSASSA-PSS signature verification. See mbedtls_rsa_rsassa_pss_verify_ext()
mbedtls_md_type_t mgf1_hash_id
The RSA context structure.