26 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include MBEDTLS_CONFIG_FILE
35 #if defined(MBEDTLS_THREADING_C)
42 #define MBEDTLS_ERR_RSA_BAD_INPUT_DATA -0x4080
43 #define MBEDTLS_ERR_RSA_INVALID_PADDING -0x4100
44 #define MBEDTLS_ERR_RSA_KEY_GEN_FAILED -0x4180
45 #define MBEDTLS_ERR_RSA_KEY_CHECK_FAILED -0x4200
46 #define MBEDTLS_ERR_RSA_PUBLIC_FAILED -0x4280
47 #define MBEDTLS_ERR_RSA_PRIVATE_FAILED -0x4300
48 #define MBEDTLS_ERR_RSA_VERIFY_FAILED -0x4380
49 #define MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE -0x4400
50 #define MBEDTLS_ERR_RSA_RNG_FAILED -0x4480
55 #define MBEDTLS_RSA_PUBLIC 0
56 #define MBEDTLS_RSA_PRIVATE 1
58 #define MBEDTLS_RSA_PKCS_V15 0
59 #define MBEDTLS_RSA_PKCS_V21 1
61 #define MBEDTLS_RSA_SIGN 1
62 #define MBEDTLS_RSA_CRYPT 2
64 #define MBEDTLS_RSA_SALT_LEN_ANY -1
70 #if defined(MBEDTLS_RSA_C)
107 #if defined(MBEDTLS_THREADING_C)
108 mbedtls_threading_mutex_t mutex;
137 void mbedtls_rsa_init( mbedtls_rsa_context *ctx,
149 void mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx,
int padding,
int hash_id);
165 int mbedtls_rsa_gen_key( mbedtls_rsa_context *ctx,
166 int (*f_rng)(
void *,
unsigned char *,
size_t),
168 unsigned int nbits,
int exponent );
177 int mbedtls_rsa_check_pubkey(
const mbedtls_rsa_context *ctx );
186 int mbedtls_rsa_check_privkey(
const mbedtls_rsa_context *ctx );
197 int mbedtls_rsa_check_pub_priv(
const mbedtls_rsa_context *pub,
const mbedtls_rsa_context *prv );
215 int mbedtls_rsa_public( mbedtls_rsa_context *ctx,
216 const unsigned char *input,
217 unsigned char *output );
233 int mbedtls_rsa_private( mbedtls_rsa_context *ctx,
234 int (*f_rng)(
void *,
unsigned char *,
size_t),
236 const unsigned char *input,
237 unsigned char *output );
258 int mbedtls_rsa_pkcs1_encrypt( mbedtls_rsa_context *ctx,
259 int (*f_rng)(
void *,
unsigned char *,
size_t),
261 int mode,
size_t ilen,
262 const unsigned char *input,
263 unsigned char *output );
281 int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
282 int (*f_rng)(
void *,
unsigned char *,
size_t),
284 int mode,
size_t ilen,
285 const unsigned char *input,
286 unsigned char *output );
307 int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
308 int (*f_rng)(
void *,
unsigned char *,
size_t),
311 const unsigned char *label,
size_t label_len,
313 const unsigned char *input,
314 unsigned char *output );
336 int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx,
337 int (*f_rng)(
void *,
unsigned char *,
size_t),
339 int mode,
size_t *olen,
340 const unsigned char *input,
341 unsigned char *output,
342 size_t output_max_len );
362 int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx,
363 int (*f_rng)(
void *,
unsigned char *,
size_t),
365 int mode,
size_t *olen,
366 const unsigned char *input,
367 unsigned char *output,
368 size_t output_max_len );
390 int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx,
391 int (*f_rng)(
void *,
unsigned char *,
size_t),
394 const unsigned char *label,
size_t label_len,
396 const unsigned char *input,
397 unsigned char *output,
398 size_t output_max_len );
424 int mbedtls_rsa_pkcs1_sign( mbedtls_rsa_context *ctx,
425 int (*f_rng)(
void *,
unsigned char *,
size_t),
429 unsigned int hashlen,
430 const unsigned char *hash,
431 unsigned char *sig );
451 int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx,
452 int (*f_rng)(
void *,
unsigned char *,
size_t),
456 unsigned int hashlen,
457 const unsigned char *hash,
458 unsigned char *sig );
484 int mbedtls_rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
485 int (*f_rng)(
void *,
unsigned char *,
size_t),
489 unsigned int hashlen,
490 const unsigned char *hash,
491 unsigned char *sig );
516 int mbedtls_rsa_pkcs1_verify( mbedtls_rsa_context *ctx,
517 int (*f_rng)(
void *,
unsigned char *,
size_t),
521 unsigned int hashlen,
522 const unsigned char *hash,
523 const unsigned char *sig );
543 int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx,
544 int (*f_rng)(
void *,
unsigned char *,
size_t),
548 unsigned int hashlen,
549 const unsigned char *hash,
550 const unsigned char *sig );
577 int mbedtls_rsa_rsassa_pss_verify( mbedtls_rsa_context *ctx,
578 int (*f_rng)(
void *,
unsigned char *,
size_t),
582 unsigned int hashlen,
583 const unsigned char *hash,
584 const unsigned char *sig );
610 int mbedtls_rsa_rsassa_pss_verify_ext( mbedtls_rsa_context *ctx,
611 int (*f_rng)(
void *,
unsigned char *,
size_t),
615 unsigned int hashlen,
616 const unsigned char *hash,
618 int expected_salt_len,
619 const unsigned char *sig );
630 int mbedtls_rsa_copy( mbedtls_rsa_context *dst,
const mbedtls_rsa_context *src );
637 void mbedtls_rsa_free( mbedtls_rsa_context *ctx );
644 int mbedtls_rsa_self_test(
int verbose );
Compatibility names (set of defines)
Multi-precision integer library.
Threading abstraction layer.
Generic message digest wrapper.