28 #if defined(POLARSSL_PK_C)
33 #if defined(POLARSSL_RSA_C)
36 #if defined(POLARSSL_ECP_C)
39 #if defined(POLARSSL_ECDSA_C)
60 if( ctx == NULL || ctx->
pk_info == NULL)
75 #if defined(POLARSSL_RSA_C)
79 #if defined(POLARSSL_ECP_C)
85 #if defined(POLARSSL_ECDSA_C)
100 if( ctx == NULL || info == NULL || ctx->
pk_info != NULL )
122 if( ctx == NULL || ctx->
pk_info != NULL )
146 if( ctx == NULL || ctx->
pk_info == NULL )
155 static inline int pk_hashlen_helper(
md_type_t md_alg,
size_t *hash_len )
165 *hash_len = md_info->
size;
173 const unsigned char *hash,
size_t hash_len,
174 const unsigned char *sig,
size_t sig_len )
176 if( ctx == NULL || ctx->
pk_info == NULL ||
177 pk_hashlen_helper( md_alg, &hash_len ) != 0 )
191 const unsigned char *hash,
size_t hash_len,
192 unsigned char *sig,
size_t *sig_len,
193 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
195 if( ctx == NULL || ctx->
pk_info == NULL ||
196 pk_hashlen_helper( md_alg, &hash_len ) != 0 )
203 sig, sig_len, f_rng, p_rng ) );
210 const unsigned char *input,
size_t ilen,
211 unsigned char *output,
size_t *olen,
size_t osize,
212 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
214 if( ctx == NULL || ctx->
pk_info == NULL )
221 output, olen, osize, f_rng, p_rng ) );
228 const unsigned char *input,
size_t ilen,
229 unsigned char *output,
size_t *olen,
size_t osize,
230 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
232 if( ctx == NULL || ctx->
pk_info == NULL )
239 output, olen, osize, f_rng, p_rng ) );
247 if( ctx == NULL || ctx->
pk_info == NULL )
258 if( ctx == NULL || ctx->
pk_info == NULL )
270 if( ctx == NULL || ctx->
pk_info == NULL )
271 return(
"invalid PK" );
281 if( ctx == NULL || ctx->
pk_info == NULL )
const pk_info_t * pk_info_from_type(pk_type_t pk_type)
Return information associated with the given PK type.
pk_rsa_alt_decrypt_func decrypt_func
const pk_info_t eckeydh_info
int(* verify_func)(void *ctx, md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature.
Elliptic curves over GF(p)
size_t pk_get_size(const pk_context *ctx)
Get the size in bits of the underlying key.
int pk_decrypt(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.
int pk_debug(const pk_context *ctx, pk_debug_item *items)
Export debug information.
Configuration options (set of defines)
const pk_info_t * pk_info
Public key informations.
pk_type_t pk_get_type(const pk_context *ctx)
Get the key type.
const char * pk_get_name(const pk_context *ctx)
Access the type name.
Public Key abstraction layer.
int pk_init_ctx_rsa_alt(pk_context *ctx, void *key, pk_rsa_alt_decrypt_func decrypt_func, pk_rsa_alt_sign_func sign_func, pk_rsa_alt_key_len_func key_len_func)
Initialize an RSA-alt context.
#define POLARSSL_ERR_PK_BAD_INPUT_DATA
Bad input parameters to function.
int(* encrypt_func)(void *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.
const md_info_t * md_info_from_type(md_type_t md_type)
Returns the message digest information associated with the given digest type.
void(* debug_func)(const void *ctx, pk_debug_item *items)
Interface with the debug module.
int(* can_do)(pk_type_t type)
Tell if the context implements this type (e.g.
Item to send to the debug module.
int pk_verify(pk_context *ctx, md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len)
Verify signature.
Public key information and operations.
int pk_can_do(pk_context *ctx, pk_type_t type)
Tell if a context can do the operation given by type.
#define POLARSSL_ERR_PK_MALLOC_FAILED
Memory alloation failed.
size_t(* get_size)(const void *)
Get key size in bits.
void * pk_ctx
Underlying public key context.
pk_type_t
Public key types.
pk_rsa_alt_sign_func sign_func
int pk_init_ctx(pk_context *ctx, const pk_info_t *info)
Initialize a PK context with the information given and allocates the type-specific PK subcontext...
const pk_info_t rsa_alt_info
The RSA public-key cryptosystem.
size_t(* pk_rsa_alt_key_len_func)(void *ctx)
#define POLARSSL_ERR_PK_TYPE_MISMATCH
Type mismatch, eg attempt to encrypt with an ECDSA key.
void pk_free(pk_context *ctx)
Free a pk_context.
int pk_sign(pk_context *ctx, 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.
void *(* ctx_alloc_func)(void)
Allocate a new context.
const pk_info_t eckey_info
const pk_info_t ecdsa_info
int(* 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 pk_encrypt(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.
void pk_init(pk_context *ctx)
Initialize a pk_context (as NONE)
int size
Output length of the digest function.
int(* pk_rsa_alt_sign_func)(void *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, int hash_id, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
const char * name
Type name.
pk_rsa_alt_key_len_func key_len_func
pk_type_t type
Public key type.
int(* sign_func)(void *ctx, 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.
Message digest information.
int(* decrypt_func)(void *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.
void(* ctx_free_func)(void *ctx)
Free the given context.