26 #if !defined(POLARSSL_CONFIG_FILE)
29 #include POLARSSL_CONFIG_FILE
32 #if defined(POLARSSL_PK_C)
37 #if defined(POLARSSL_RSA_C)
40 #if defined(POLARSSL_ECP_C)
43 #if defined(POLARSSL_ECDSA_C)
48 static void polarssl_zeroize(
void *v,
size_t n ) {
49 volatile unsigned char *p = v;
while( n-- ) *p++ = 0;
69 if( ctx == NULL || ctx->
pk_info == NULL )
83 #if defined(POLARSSL_RSA_C)
87 #if defined(POLARSSL_ECP_C)
89 return( &eckey_info );
91 return( &eckeydh_info );
93 #if defined(POLARSSL_ECDSA_C)
95 return( &ecdsa_info );
108 if( ctx == NULL || info == NULL || ctx->
pk_info != NULL )
130 if( ctx == NULL || ctx->
pk_info != NULL )
154 if( ctx == NULL || ctx->
pk_info == NULL )
163 static inline int pk_hashlen_helper(
md_type_t md_alg,
size_t *hash_len )
173 *hash_len = md_info->
size;
181 const unsigned char *hash,
size_t hash_len,
182 const unsigned char *sig,
size_t sig_len )
184 if( ctx == NULL || ctx->
pk_info == NULL ||
185 pk_hashlen_helper( md_alg, &hash_len ) != 0 )
200 const unsigned char *hash,
size_t hash_len,
201 const unsigned char *sig,
size_t sig_len )
203 if( ctx == NULL || ctx->
pk_info == NULL )
211 #if defined(POLARSSL_RSA_C) && defined(POLARSSL_PKCS1_V21)
215 if( options == NULL )
225 md_alg, hash_len, hash,
242 if( options != NULL )
245 return(
pk_verify( ctx, md_alg, hash, hash_len, sig, sig_len ) );
252 const unsigned char *hash,
size_t hash_len,
253 unsigned char *sig,
size_t *sig_len,
254 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
256 if( ctx == NULL || ctx->
pk_info == NULL ||
257 pk_hashlen_helper( md_alg, &hash_len ) != 0 )
264 sig, sig_len, f_rng, p_rng ) );
271 const unsigned char *input,
size_t ilen,
272 unsigned char *output,
size_t *olen,
size_t osize,
273 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
275 if( ctx == NULL || ctx->
pk_info == NULL )
282 output, olen, osize, f_rng, p_rng ) );
289 const unsigned char *input,
size_t ilen,
290 unsigned char *output,
size_t *olen,
size_t osize,
291 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
293 if( ctx == NULL || ctx->
pk_info == NULL )
300 output, olen, osize, f_rng, p_rng ) );
308 if( ctx == NULL || ctx->
pk_info == NULL )
319 if( ctx == NULL || ctx->
pk_info == NULL )
334 if( ctx == NULL || ctx->
pk_info == NULL )
335 return(
"invalid PK" );
345 if( ctx == NULL || ctx->
pk_info == NULL )