32 #if !defined(POLARSSL_CONFIG_FILE)
35 #include POLARSSL_CONFIG_FILE
38 #if defined(POLARSSL_RSA_C)
43 #if defined(POLARSSL_PKCS1_V21)
50 #if defined(POLARSSL_PLATFORM_C)
53 #define polarssl_printf printf
67 #if defined(POLARSSL_THREADING_C)
81 #if defined(POLARSSL_GENPRIME)
87 int (*f_rng)(
void *,
unsigned char *,
size_t),
89 unsigned int nbits,
int exponent )
94 if( f_rng == NULL || nbits < 128 || exponent < 3 )
163 if( !ctx->
N.
p || !ctx->
E.
p )
166 if( ( ctx->
N.
p[0] & 1 ) == 0 ||
167 ( ctx->
E.
p[0] & 1 ) == 0 )
187 mpi PQ, DE, P1, Q1, H, I, G, G2, L1, L2, DP, DQ, QP;
192 if( !ctx->
P.
p || !ctx->
Q.
p || !ctx->
D.
p )
247 const unsigned char *input,
248 unsigned char *output )
278 #if !defined(POLARSSL_RSA_NO_CRT)
286 int (*f_rng)(
void *,
unsigned char *,
size_t),
void *p_rng )
290 #if defined(POLARSSL_THREADING_C)
294 if( ctx->
Vf.
p != NULL )
326 #if defined(POLARSSL_THREADING_C)
338 int (*f_rng)(
void *,
unsigned char *,
size_t),
340 const unsigned char *input,
341 unsigned char *output )
346 #if !defined(POLARSSL_RSA_NO_CRT)
354 #if defined(POLARSSL_THREADING_C)
355 mpi Vi_copy, Vf_copy;
375 #if defined(POLARSSL_RSA_NO_CRT)
386 MPI_CHK( rsa_prepare_blinding( ctx, Vi, Vf, f_rng, p_rng ) );
429 #if !defined(POLARSSL_RSA_NO_CRT) && defined(POLARSSL_THREADING_C)
439 #if defined(POLARSSL_PKCS1_V21)
449 static void mgf_mask(
unsigned char *dst,
size_t dlen,
unsigned char *src,
453 unsigned char counter[4];
459 memset( counter, 0, 4 );
478 for( i = 0; i < use_len; ++i )
488 #if defined(POLARSSL_PKCS1_V21)
493 int (*f_rng)(
void *,
unsigned char *,
size_t),
496 const unsigned char *label,
size_t label_len,
498 const unsigned char *input,
499 unsigned char *output )
503 unsigned char *p = output;
512 if( md_info == NULL )
518 if( olen < ilen + 2 * hlen + 2 || f_rng == NULL )
521 memset( output, 0, olen );
527 if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 )
534 md( md_info, label, label_len, p );
536 p += olen - 2 * hlen - 2 - ilen;
538 memcpy( p, input, ilen );
544 mgf_mask( output + hlen + 1, olen - hlen - 1, output + 1, hlen,
549 mgf_mask( output + 1, hlen, output + hlen + 1, olen - hlen - 1,
556 :
rsa_private( ctx, f_rng, p_rng, output, output ) );
560 #if defined(POLARSSL_PKCS1_V15)
565 int (*f_rng)(
void *,
unsigned char *,
size_t),
567 int mode,
size_t ilen,
568 const unsigned char *input,
569 unsigned char *output )
573 unsigned char *p = output;
580 if( olen < ilen + 11 )
583 nb_pad = olen - 3 - ilen;
590 while( nb_pad-- > 0 )
595 ret = f_rng( p_rng, p, 1 );
596 }
while( *p == 0 && --rng_dl && ret == 0 );
600 if( rng_dl == 0 || ret != 0)
610 while( nb_pad-- > 0 )
615 memcpy( p, input, ilen );
619 :
rsa_private( ctx, f_rng, p_rng, output, output ) );
627 int (*f_rng)(
void *,
unsigned char *,
size_t),
629 int mode,
size_t ilen,
630 const unsigned char *input,
631 unsigned char *output )
635 #if defined(POLARSSL_PKCS1_V15)
641 #if defined(POLARSSL_PKCS1_V21)
644 ilen, input, output );
652 #if defined(POLARSSL_PKCS1_V21)
657 int (*f_rng)(
void *,
unsigned char *,
size_t),
660 const unsigned char *label,
size_t label_len,
662 const unsigned char *input,
663 unsigned char *output,
664 size_t output_max_len )
667 size_t ilen, i, pad_len;
668 unsigned char *p, bad, pad_done;
683 if( ilen < 16 || ilen >
sizeof( buf ) )
687 if( md_info == NULL )
708 md( md_info, label, label_len, lhash );
711 mgf_mask( buf + 1, hlen, buf + hlen + 1, ilen - hlen - 1,
715 mgf_mask( buf + hlen + 1, ilen - hlen - 1, buf + 1, hlen,
731 for( i = 0; i < hlen; i++ )
732 bad |= lhash[i] ^ *p++;
738 for( i = 0; i < ilen - 2 * hlen - 2; i++ )
741 pad_len += ( pad_done == 0 );
756 if (ilen - (p - buf) > output_max_len)
759 *olen = ilen - (p - buf);
760 memcpy( output, p, *olen );
766 #if defined(POLARSSL_PKCS1_V15)
771 int (*f_rng)(
void *,
unsigned char *,
size_t),
773 int mode,
size_t *olen,
774 const unsigned char *input,
775 unsigned char *output,
776 size_t output_max_len)
779 size_t ilen, pad_count = 0, i;
780 unsigned char *p, bad, pad_done = 0;
788 if( ilen < 16 || ilen >
sizeof( buf ) )
813 for( i = 0; i < ilen - 3; i++ )
815 pad_done |= ( p[i] == 0 );
816 pad_count += ( pad_done == 0 );
828 for( i = 0; i < ilen - 3; i++ )
830 pad_done |= ( p[i] != 0xFF );
831 pad_count += ( pad_done == 0 );
841 if (ilen - (p - buf) > output_max_len)
844 *olen = ilen - (p - buf);
845 memcpy( output, p, *olen );
855 int (*f_rng)(
void *,
unsigned char *,
size_t),
857 int mode,
size_t *olen,
858 const unsigned char *input,
859 unsigned char *output,
860 size_t output_max_len)
864 #if defined(POLARSSL_PKCS1_V15)
867 input, output, output_max_len );
870 #if defined(POLARSSL_PKCS1_V21)
882 #if defined(POLARSSL_PKCS1_V21)
887 int (*f_rng)(
void *,
unsigned char *,
size_t),
891 unsigned int hashlen,
892 const unsigned char *hash,
896 unsigned char *p = sig;
898 unsigned int slen, hlen, offset = 0;
914 if( md_info == NULL )
921 if( md_info == NULL )
927 if( olen < hlen + slen + 2 )
930 memset( sig, 0, olen );
934 if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 )
940 p += olen - hlen * 2 - 2;
942 memcpy( p, salt, slen );
962 mgf_mask( sig + offset, olen - hlen - 1 - offset, p, hlen, &md_ctx );
967 sig[0] &= 0xFF >> ( olen * 8 - msb );
978 #if defined(POLARSSL_PKCS1_V15)
986 int (*f_rng)(
void *,
unsigned char *,
size_t),
990 unsigned int hashlen,
991 const unsigned char *hash,
994 size_t nb_pad, olen, oid_size = 0;
995 unsigned char *p = sig;
1007 if( md_info == NULL )
1013 nb_pad -= 10 + oid_size;
1020 if( ( nb_pad < 8 ) || ( nb_pad > olen ) )
1025 memset( p, 0xFF, nb_pad );
1031 memcpy( p, hash, hashlen );
1045 *p++ = (
unsigned char) ( 0x08 + oid_size + hashlen );
1047 *p++ = (
unsigned char) ( 0x04 + oid_size );
1049 *p++ = oid_size & 0xFF;
1050 memcpy( p, oid, oid_size );
1056 memcpy( p, hash, hashlen );
1069 int (*f_rng)(
void *,
unsigned char *,
size_t),
1073 unsigned int hashlen,
1074 const unsigned char *hash,
1075 unsigned char *sig )
1079 #if defined(POLARSSL_PKCS1_V15)
1082 hashlen, hash, sig );
1085 #if defined(POLARSSL_PKCS1_V21)
1088 hashlen, hash, sig );
1096 #if defined(POLARSSL_PKCS1_V21)
1101 int (*f_rng)(
void *,
unsigned char *,
size_t),
1105 unsigned int hashlen,
1106 const unsigned char *hash,
1107 const unsigned char *sig )
1114 unsigned char zeros[8];
1125 if( siglen < 16 || siglen >
sizeof( buf ) )
1137 if( buf[siglen - 1] != 0xBC )
1145 if( md_info == NULL )
1152 if( md_info == NULL )
1156 slen = siglen - hlen - 1;
1158 memset( zeros, 0, 8 );
1171 if( buf[0] >> ( 8 - siglen * 8 + msb ) )
1176 mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx );
1178 buf[0] &= 0xFF >> ( siglen * 8 - msb );
1180 while( p < buf + siglen && *p == 0 )
1183 if( p == buf + siglen ||
1202 if( memcmp( p + slen, result, hlen ) == 0 )
1209 #if defined(POLARSSL_PKCS1_V15)
1214 int (*f_rng)(
void *,
unsigned char *,
size_t),
1218 unsigned int hashlen,
1219 const unsigned char *hash,
1220 const unsigned char *sig )
1223 size_t len, siglen, asn1_len;
1224 unsigned char *p, *end;
1235 if( siglen < 16 || siglen >
sizeof( buf ) )
1247 if( *p++ != 0 || *p++ != RSA_SIGN )
1252 if( p >= buf + siglen - 1 || *p != 0xFF )
1258 len = siglen - ( p - buf );
1262 if( memcmp( p, hash, hashlen ) == 0 )
1269 if( md_info == NULL )
1281 if( asn1_len + 2 != len )
1288 if( asn1_len + 6 + hashlen != len )
1300 if( md_alg != msg_md_alg )
1312 if( asn1_len != hashlen )
1315 if( memcmp( p, hash, hashlen ) != 0 )
1331 int (*f_rng)(
void *,
unsigned char *,
size_t),
1335 unsigned int hashlen,
1336 const unsigned char *hash,
1337 const unsigned char *sig )
1341 #if defined(POLARSSL_PKCS1_V15)
1344 hashlen, hash, sig );
1347 #if defined(POLARSSL_PKCS1_V21)
1350 hashlen, hash, sig );
1382 #if !defined(POLARSSL_RSA_NO_CRT)
1402 #if !defined(POLARSSL_RSA_NO_CRT)
1410 #if defined(POLARSSL_THREADING_C)
1415 #if defined(POLARSSL_SELF_TEST)
1424 #define RSA_N "9292758453063D803DD603D5E777D788" \
1425 "8ED1D5BF35786190FA2F23EBC0848AEA" \
1426 "DDA92CA6C3D80B32C4D109BE0F36D6AE" \
1427 "7130B9CED7ACDF54CFC7555AC14EEBAB" \
1428 "93A89813FBF3C4F8066D2D800F7C38A8" \
1429 "1AE31942917403FF4946B0A83D3D3E05" \
1430 "EE57C6F5F5606FB5D4BC6CD34EE0801A" \
1431 "5E94BB77B07507233A0BC7BAC8F90F79"
1433 #define RSA_E "10001"
1435 #define RSA_D "24BF6185468786FDD303083D25E64EFC" \
1436 "66CA472BC44D253102F8B4A9D3BFA750" \
1437 "91386C0077937FE33FA3252D28855837" \
1438 "AE1B484A8A9A45F7EE8C0C634F99E8CD" \
1439 "DF79C5CE07EE72C7F123142198164234" \
1440 "CABB724CF78B8173B9F880FC86322407" \
1441 "AF1FEDFDDE2BEB674CA15F3E81A1521E" \
1442 "071513A1E85B5DFA031F21ECAE91A34D"
1444 #define RSA_P "C36D0EB7FCD285223CFB5AABA5BDA3D8" \
1445 "2C01CAD19EA484A87EA4377637E75500" \
1446 "FCB2005C5C7DD6EC4AC023CDA285D796" \
1447 "C3D9E75E1EFC42488BB4F1D13AC30A57"
1449 #define RSA_Q "C000DF51A7C77AE8D7C7370C1FF55B69" \
1450 "E211C2B9E5DB1ED0BF61D0D9899620F4" \
1451 "910E4168387E3C30AA1E00C339A79508" \
1452 "8452DD96A9A5EA5D9DCA68DA636032AF"
1454 #define RSA_DP "C1ACF567564274FB07A0BBAD5D26E298" \
1455 "3C94D22288ACD763FD8E5600ED4A702D" \
1456 "F84198A5F06C2E72236AE490C93F07F8" \
1457 "3CC559CD27BC2D1CA488811730BB5725"
1459 #define RSA_DQ "4959CBF6F8FEF750AEE6977C155579C7" \
1460 "D8AAEA56749EA28623272E4F7D0592AF" \
1461 "7C1F1313CAC9471B5C523BFE592F517B" \
1462 "407A1BD76C164B93DA2D32A383E58357"
1464 #define RSA_QP "9AE7FBC99546432DF71896FC239EADAE" \
1465 "F38D18D2B2F0E2DD275AA977E2BF4411" \
1466 "F5A3B2A5D33605AEBBCCBA7FEB9F2D2F" \
1467 "A74206CEC169D74BF5A8C50D6F48EA08"
1470 #define RSA_PT "\xAA\xBB\xCC\x03\x02\x01\x00\xFF\xFF\xFF\xFF\xFF" \
1471 "\x11\x22\x33\x0A\x0B\x0C\xCC\xDD\xDD\xDD\xDD\xDD"
1473 #if defined(POLARSSL_PKCS1_V15)
1474 static int myrand(
void *rng_state,
unsigned char *output,
size_t len )
1476 #if !defined(__OpenBSD__)
1479 if( rng_state != NULL )
1482 for( i = 0; i < len; ++i )
1485 if( rng_state != NULL )
1488 arc4random_buf( output, len );
1501 #if defined(POLARSSL_PKCS1_V15)
1504 unsigned char rsa_plaintext[PT_LEN];
1505 unsigned char rsa_decrypted[PT_LEN];
1506 unsigned char rsa_ciphertext[KEY_LEN];
1507 #if defined(POLARSSL_SHA1_C)
1508 unsigned char sha1sum[20];
1538 memcpy( rsa_plaintext, RSA_PT, PT_LEN );
1541 rsa_plaintext, rsa_ciphertext ) != 0 )
1553 rsa_ciphertext, rsa_decrypted,
1554 sizeof(rsa_decrypted) ) != 0 )
1562 if( memcmp( rsa_decrypted, rsa_plaintext, len ) != 0 )
1570 #if defined(POLARSSL_SHA1_C)
1574 sha1( rsa_plaintext, PT_LEN, sha1sum );
1577 sha1sum, rsa_ciphertext ) != 0 )
1589 sha1sum, rsa_ciphertext ) != 0 )
int md(const md_info_t *md_info, const unsigned char *input, size_t ilen, unsigned char *output)
Output = message_digest( input buffer )
int mpi_cmp_int(const mpi *X, t_sint z)
Compare signed values.
#define POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE
The output buffer for decryption is not large enough.
void mpi_swap(mpi *X, mpi *Y)
Swap the contents of X and Y.
int rsa_self_test(int verbose)
Checkup routine.
int rsa_copy(rsa_context *dst, const rsa_context *src)
Copy the components of an RSA context.
int(* polarssl_mutex_lock)(threading_mutex_t *mutex)
int rsa_rsaes_oaep_encrypt(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, const unsigned char *label, size_t label_len, size_t ilen, const unsigned char *input, unsigned char *output)
Perform a PKCS#1 v2.1 OAEP encryption (RSAES-OAEP-ENCRYPT)
#define POLARSSL_MPI_MAX_SIZE
Maximum number of bytes for usable MPIs.
int rsa_check_privkey(const rsa_context *ctx)
Check a private RSA key.
int mpi_gcd(mpi *G, const mpi *A, const mpi *B)
Greatest common divisor: G = gcd(A, B)
void sha1(const unsigned char *input, size_t ilen, unsigned char output[20])
Output = SHA-1( input buffer )
int md_starts(md_context_t *ctx)
Set-up the given context for a new message digest.
int mpi_fill_random(mpi *X, size_t size, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Fill an MPI X with size bytes of random.
int rsa_rsassa_pkcs1_v15_verify(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, const unsigned char *sig)
Perform a PKCS#1 v1.5 verification (RSASSA-PKCS1-v1_5-VERIFY)
int rsa_rsaes_pkcs1_v15_encrypt(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t ilen, const unsigned char *input, unsigned char *output)
Perform a PKCS#1 v1.5 encryption (RSAES-PKCS1-v1_5-ENCRYPT)
int rsa_rsaes_oaep_decrypt(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, const unsigned char *label, size_t label_len, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len)
Perform a PKCS#1 v2.1 OAEP decryption (RSAES-OAEP-DECRYPT)
int md_init_ctx(md_context_t *ctx, const md_info_t *md_info)
Initialises and fills the message digest context structure with the appropriate values.
Configuration options (set of defines)
int rsa_check_pubkey(const rsa_context *ctx)
Check a public RSA key.
int rsa_rsassa_pss_verify(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, const unsigned char *sig)
Perform a PKCS#1 v2.1 PSS verification (RSASSA-PSS-VERIFY)
int mpi_div_mpi(mpi *Q, mpi *R, const mpi *A, const mpi *B)
Division by mpi: A = Q * B + R.
int oid_get_md_alg(const asn1_buf *oid, md_type_t *md_alg)
Translate hash algorithm OID into md_type.
static unsigned char md_get_size(const md_info_t *md_info)
Returns the size of the message digest output.
int rsa_pkcs1_decrypt(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len)
Generic wrapper to perform a PKCS#1 decryption using the mode from the context.
int mpi_lset(mpi *X, t_sint z)
Set value from integer.
#define POLARSSL_ERR_RSA_RNG_FAILED
The random generator failed to generate non-zeros.
void mpi_init(mpi *X)
Initialize one MPI.
int mpi_cmp_mpi(const mpi *X, const mpi *Y)
Compare signed values.
Object Identifier (OID) database.
const md_info_t * md_info
Information about the associated message digest.
int rsa_rsaes_pkcs1_v15_decrypt(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t *olen, const unsigned char *input, unsigned char *output, size_t output_max_len)
Perform a PKCS#1 v1.5 decryption (RSAES-PKCS1-v1_5-DECRYPT)
int mpi_add_mpi(mpi *X, const mpi *A, const mpi *B)
Signed addition: X = A + B.
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 rsa_free(rsa_context *ctx)
Free the components of an RSA key.
int rsa_private(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, const unsigned char *input, unsigned char *output)
Do an RSA private key operation.
int rsa_pkcs1_encrypt(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, size_t ilen, const unsigned char *input, unsigned char *output)
Generic wrapper to perform a PKCS#1 encryption using the mode from the context.
#define POLARSSL_ERR_RSA_INVALID_PADDING
Input data contains invalid padding and is rejected.
unsigned char * p
ASN1 data, e.g.
int mpi_inv_mod(mpi *X, const mpi *A, const mpi *N)
Modular inverse: X = A^-1 mod N.
void mpi_free(mpi *X)
Unallocate one MPI.
int mpi_exp_mod(mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR)
Sliding-window exponentiation: X = A^E mod N.
int rsa_rsassa_pss_sign(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
Perform a PKCS#1 v2.1 PSS signature (RSASSA-PSS-SIGN)
int rsa_pkcs1_verify(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, const unsigned char *sig)
Generic wrapper to perform a PKCS#1 verification using the mode from the context. ...
#define POLARSSL_ERR_RSA_VERIFY_FAILED
The PKCS#1 verification failed.
int(* polarssl_mutex_free)(threading_mutex_t *mutex)
int mpi_gen_prime(mpi *X, size_t nbits, int dh_flag, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng)
Prime number generation.
size_t mpi_msb(const mpi *X)
Return the number of bits up to and including the most significant '1' bit'.
#define POLARSSL_MPI_MAX_BITS
Maximum number of bits for usable MPIs.
int rsa_pkcs1_sign(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
Generic wrapper to perform a PKCS#1 signature using the mode from the context.
int rsa_rsassa_pkcs1_v15_sign(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, int mode, md_type_t md_alg, unsigned int hashlen, const unsigned char *hash, unsigned char *sig)
Perform a PKCS#1 v1.5 signature (RSASSA-PKCS1-v1_5-SIGN)
int mpi_read_string(mpi *X, int radix, const char *s)
Import from an ASCII string.
Generic message digest wrapper.
int mpi_read_binary(mpi *X, const unsigned char *buf, size_t buflen)
Import X from unsigned binary data, big endian.
Type-length-value structure that allows for ASN1 using DER.
The RSA public-key cryptosystem.
size_t len
ASN1 length, e.g.
#define POLARSSL_ERR_RSA_BAD_INPUT_DATA
Bad input parameters to function.
#define POLARSSL_ERR_RSA_PRIVATE_FAILED
The private key operation failed.
void rsa_set_padding(rsa_context *ctx, int padding, int hash_id)
Set padding for an already initialized RSA context.
#define POLARSSL_MD_MAX_SIZE
int(* polarssl_mutex_unlock)(threading_mutex_t *mutex)
SHA-1 cryptographic hash function.
#define POLARSSL_ERR_RSA_KEY_CHECK_FAILED
Key failed to pass the libraries validity check.
int mpi_copy(mpi *X, const mpi *Y)
Copy the contents of Y into X.
int rsa_gen_key(rsa_context *ctx, int(*f_rng)(void *, unsigned char *, size_t), void *p_rng, unsigned int nbits, int exponent)
Generate an RSA keypair.
void rsa_init(rsa_context *ctx, int padding, int hash_id)
Initialize an RSA context.
int mpi_mod_mpi(mpi *R, const mpi *A, const mpi *B)
Modulo: R = A mod B.
int oid_get_oid_by_md(md_type_t md_alg, const char **oid, size_t *olen)
Translate md_type into hash algorithm OID.
int asn1_get_tag(unsigned char **p, const unsigned char *end, size_t *len, int tag)
Get the tag and length of the tag.
int mpi_write_binary(const mpi *X, unsigned char *buf, size_t buflen)
Export X into unsigned binary data, big endian.
int(* polarssl_mutex_init)(threading_mutex_t *mutex)
int size
Output length of the digest function.
#define ASN1_OCTET_STRING
#define POLARSSL_ERR_RSA_KEY_GEN_FAILED
Something failed during generation of a key.
int md_finish(md_context_t *ctx, unsigned char *output)
Generic message digest final digest.
int mpi_mul_mpi(mpi *X, const mpi *A, const mpi *B)
Baseline multiplication: X = A * B.
#define POLARSSL_ERR_RSA_PUBLIC_FAILED
The public key operation failed.
int mpi_sub_mpi(mpi *X, const mpi *A, const mpi *B)
Signed subtraction: X = A - B.
int md_free_ctx(md_context_t *ctx)
Free the message-specific context of ctx.
int mpi_sub_int(mpi *X, const mpi *A, t_sint b)
Signed subtraction: X = A - b.
Message digest information.
int md_update(md_context_t *ctx, const unsigned char *input, size_t ilen)
Generic message digest process buffer.
Generic message digest context.
int rsa_public(rsa_context *ctx, const unsigned char *input, unsigned char *output)
Do an RSA public key operation.