26 #if !defined(POLARSSL_CONFIG_FILE)
29 #include POLARSSL_CONFIG_FILE
32 #if defined(POLARSSL_PK_C)
39 #if defined(POLARSSL_ECP_C)
43 #if defined(POLARSSL_ECDSA_C)
47 #if defined(POLARSSL_PLATFORM_C)
51 #define polarssl_malloc malloc
52 #define polarssl_free free
56 static void polarssl_zeroize(
void *v,
size_t n ) {
57 volatile unsigned char *p = v;
while( n-- ) *p++ = 0;
60 #if defined(POLARSSL_RSA_C)
67 static size_t rsa_get_size(
const void *ctx )
72 static int rsa_verify_wrap(
void *ctx,
md_type_t md_alg,
73 const unsigned char *hash,
size_t hash_len,
74 const unsigned char *sig,
size_t sig_len )
83 (
unsigned int) hash_len, hash, sig ) ) != 0 )
92 static int rsa_sign_wrap(
void *ctx,
md_type_t md_alg,
93 const unsigned char *hash,
size_t hash_len,
94 unsigned char *sig,
size_t *sig_len,
95 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
100 md_alg, (
unsigned int) hash_len, hash, sig ) );
103 static int rsa_decrypt_wrap(
void *ctx,
104 const unsigned char *input,
size_t ilen,
105 unsigned char *output,
size_t *olen,
size_t osize,
106 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
115 static int rsa_encrypt_wrap(
void *ctx,
116 const unsigned char *input,
size_t ilen,
117 unsigned char *output,
size_t *olen,
size_t osize,
118 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
125 f_rng, p_rng,
RSA_PUBLIC, ilen, input, output ) );
128 static void *rsa_alloc_wrap(
void )
138 static void rsa_free_wrap(
void *ctx )
144 static void rsa_debug(
const void *ctx,
pk_debug_item *items )
147 items->
name =
"rsa.N";
153 items->
name =
"rsa.E";
172 #if defined(POLARSSL_ECP_C)
176 static int eckey_can_do(
pk_type_t type )
183 static size_t eckey_get_size(
const void *ctx )
188 #if defined(POLARSSL_ECDSA_C)
190 static int ecdsa_verify_wrap(
void *ctx,
md_type_t md_alg,
191 const unsigned char *hash,
size_t hash_len,
192 const unsigned char *sig,
size_t sig_len );
194 static int ecdsa_sign_wrap(
void *ctx,
md_type_t md_alg,
195 const unsigned char *hash,
size_t hash_len,
196 unsigned char *sig,
size_t *sig_len,
197 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng );
199 static int eckey_verify_wrap(
void *ctx,
md_type_t md_alg,
200 const unsigned char *hash,
size_t hash_len,
201 const unsigned char *sig,
size_t sig_len )
209 ret = ecdsa_verify_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len );
216 static int eckey_sign_wrap(
void *ctx,
md_type_t md_alg,
217 const unsigned char *hash,
size_t hash_len,
218 unsigned char *sig,
size_t *sig_len,
219 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
227 ret = ecdsa_sign_wrap( &ecdsa, md_alg, hash, hash_len, sig, sig_len,
237 static void *eckey_alloc_wrap(
void )
247 static void eckey_free_wrap(
void *ctx )
253 static void eckey_debug(
const void *ctx,
pk_debug_item *items )
256 items->
name =
"eckey.Q";
265 #if defined(POLARSSL_ECDSA_C)
282 static int eckeydh_can_do(
pk_type_t type )
303 #if defined(POLARSSL_ECDSA_C)
304 static int ecdsa_can_do(
pk_type_t type )
309 static int ecdsa_verify_wrap(
void *ctx,
md_type_t md_alg,
310 const unsigned char *hash,
size_t hash_len,
311 const unsigned char *sig,
size_t sig_len )
317 hash, hash_len, sig, sig_len );
325 static int ecdsa_sign_wrap(
void *ctx,
md_type_t md_alg,
326 const unsigned char *hash,
size_t hash_len,
327 unsigned char *sig,
size_t *sig_len,
328 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
331 #if defined(POLARSSL_ECDSA_DETERMINISTIC)
336 hash, hash_len, sig, sig_len, md_alg ) );
341 hash, hash_len, sig, sig_len, f_rng, p_rng ) );
345 static void *ecdsa_alloc_wrap(
void )
355 static void ecdsa_free_wrap(
void *ctx )
380 static int rsa_alt_can_do(
pk_type_t type )
385 static size_t rsa_alt_get_size(
const void *ctx )
392 static int rsa_alt_sign_wrap(
void *ctx,
md_type_t md_alg,
393 const unsigned char *hash,
size_t hash_len,
394 unsigned char *sig,
size_t *sig_len,
395 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
402 md_alg, (
unsigned int) hash_len, hash, sig ) );
405 static int rsa_alt_decrypt_wrap(
void *ctx,
406 const unsigned char *input,
size_t ilen,
407 unsigned char *output,
size_t *olen,
size_t osize,
408 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
422 static void *rsa_alt_alloc_wrap(
void )
432 static void rsa_alt_free_wrap(
void *ctx )
445 rsa_alt_decrypt_wrap,