/mbedtls-3.5.0/library/ |
D | bignum_mod.c | 38 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_residue_setup() argument 42 if (p_limbs != N->limbs || !mbedtls_mpi_core_lt_ct(p, N->p, N->limbs)) { in mbedtls_mpi_mod_residue_setup() 46 r->limbs = N->limbs; in mbedtls_mpi_mod_residue_setup() 62 void mbedtls_mpi_mod_modulus_init(mbedtls_mpi_mod_modulus *N) in mbedtls_mpi_mod_modulus_init() argument 64 if (N == NULL) { in mbedtls_mpi_mod_modulus_init() 68 N->p = NULL; in mbedtls_mpi_mod_modulus_init() 69 N->limbs = 0; in mbedtls_mpi_mod_modulus_init() 70 N->bits = 0; in mbedtls_mpi_mod_modulus_init() 71 N->int_rep = MBEDTLS_MPI_MOD_REP_INVALID; in mbedtls_mpi_mod_modulus_init() 74 void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *N) in mbedtls_mpi_mod_modulus_free() argument [all …]
|
D | bignum_mod_raw.c | 40 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_cond_assign() argument 43 mbedtls_mpi_core_cond_assign(X, A, N->limbs, assign); in mbedtls_mpi_mod_raw_cond_assign() 48 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_cond_swap() argument 51 mbedtls_mpi_core_cond_swap(X, Y, N->limbs, swap); in mbedtls_mpi_mod_raw_cond_swap() 55 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_read() argument 64 ret = mbedtls_mpi_core_read_le(X, N->limbs, in mbedtls_mpi_mod_raw_read() 68 ret = mbedtls_mpi_core_read_be(X, N->limbs, in mbedtls_mpi_mod_raw_read() 79 if (!mbedtls_mpi_core_lt_ct(X, N->p, N->limbs)) { in mbedtls_mpi_mod_raw_read() 90 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_write() argument 97 return mbedtls_mpi_core_write_le(A, N->limbs, in mbedtls_mpi_mod_raw_write() [all …]
|
D | bignum_mod_raw.h | 114 const mbedtls_mpi_mod_modulus *N, 140 const mbedtls_mpi_mod_modulus *N, 163 const mbedtls_mpi_mod_modulus *N, 185 const mbedtls_mpi_mod_modulus *N, 216 const mbedtls_mpi_mod_modulus *N); 250 const mbedtls_mpi_mod_modulus *N, 301 const mbedtls_mpi_uint *N, 334 const mbedtls_mpi_mod_modulus *N); 354 const mbedtls_mpi_mod_modulus *N); 371 const mbedtls_mpi_mod_modulus *N); [all …]
|
D | bignum_mod.h | 170 const mbedtls_mpi_mod_modulus *N, 190 void mbedtls_mpi_mod_modulus_init(mbedtls_mpi_mod_modulus *N); 206 int mbedtls_mpi_mod_modulus_setup(mbedtls_mpi_mod_modulus *N, 221 void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *N); 261 const mbedtls_mpi_mod_modulus *N); 294 const mbedtls_mpi_mod_modulus *N); 323 const mbedtls_mpi_mod_modulus *N); 360 const mbedtls_mpi_mod_modulus *N); 394 const mbedtls_mpi_mod_modulus *N, 425 const mbedtls_mpi_mod_modulus *N, [all …]
|
D | rsa_alt_helpers.c | 62 int mbedtls_rsa_deduce_primes(mbedtls_mpi const *N, in mbedtls_rsa_deduce_primes() argument 91 if (mbedtls_mpi_cmp_int(N, 0) <= 0 || in mbedtls_rsa_deduce_primes() 93 mbedtls_mpi_cmp_mpi(D, N) >= 0 || in mbedtls_rsa_deduce_primes() 95 mbedtls_mpi_cmp_mpi(E, N) >= 0) { in mbedtls_rsa_deduce_primes() 124 if (N->p[0] % 8 == 1) { in mbedtls_rsa_deduce_primes() 132 MBEDTLS_MPI_CHK(mbedtls_mpi_gcd(P, &K, N)); in mbedtls_rsa_deduce_primes() 139 MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&K, &K, &T, N, in mbedtls_rsa_deduce_primes() 151 MBEDTLS_MPI_CHK(mbedtls_mpi_gcd(P, &K, N)); in mbedtls_rsa_deduce_primes() 154 mbedtls_mpi_cmp_mpi(P, N) == -1) { in mbedtls_rsa_deduce_primes() 160 MBEDTLS_MPI_CHK(mbedtls_mpi_div_mpi(Q, NULL, N, P)); in mbedtls_rsa_deduce_primes() [all …]
|
D | bignum_core.c | 454 mbedtls_mpi_uint mbedtls_mpi_core_montmul_init(const mbedtls_mpi_uint *N) in mbedtls_mpi_core_montmul_init() argument 456 mbedtls_mpi_uint x = N[0]; in mbedtls_mpi_core_montmul_init() 458 x += ((N[0] + 2) & 4) << 1; in mbedtls_mpi_core_montmul_init() 461 x *= (2 - (N[0] * x)); in mbedtls_mpi_core_montmul_init() 471 const mbedtls_mpi_uint *N, in mbedtls_mpi_core_montmul() argument 484 (void) mbedtls_mpi_core_mla(T, AN_limbs + 2, N, AN_limbs, u1); in mbedtls_mpi_core_montmul() 500 mbedtls_mpi_uint borrow = mbedtls_mpi_core_sub(X, T, N, AN_limbs); in mbedtls_mpi_core_montmul() 520 const mbedtls_mpi *N) in mbedtls_mpi_core_get_mont_r2_unsafe() argument 525 MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(X, N->n * 2 * biL)); in mbedtls_mpi_core_get_mont_r2_unsafe() 526 MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(X, X, N)); in mbedtls_mpi_core_get_mont_r2_unsafe() [all …]
|
D | rsa.c | 74 const mbedtls_mpi *N, in mbedtls_rsa_import() argument 80 if ((N != NULL && (ret = mbedtls_mpi_copy(&ctx->N, N)) != 0) || in mbedtls_rsa_import() 88 if (N != NULL) { in mbedtls_rsa_import() 89 ctx->len = mbedtls_mpi_size(&ctx->N); in mbedtls_rsa_import() 96 unsigned char const *N, size_t N_len, in mbedtls_rsa_import_raw() argument 104 if (N != NULL) { in mbedtls_rsa_import_raw() 105 MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->N, N, N_len)); in mbedtls_rsa_import_raw() 106 ctx->len = mbedtls_mpi_size(&ctx->N); in mbedtls_rsa_import_raw() 148 if (ctx->len != mbedtls_mpi_size(&ctx->N) || in rsa_check_context() 159 if (mbedtls_mpi_cmp_int(&ctx->N, 0) <= 0 || in rsa_check_context() [all …]
|
D | bignum.c | 1569 static void mpi_montg_init(mbedtls_mpi_uint *mm, const mbedtls_mpi *N) in mpi_montg_init() argument 1571 *mm = mbedtls_mpi_core_montmul_init(N->p); in mpi_montg_init() 1596 const mbedtls_mpi *N, mbedtls_mpi_uint mm, in mpi_montmul() argument 1599 mbedtls_mpi_core_montmul(A->p, A->p, B->p, B->n, N->p, N->n, mm, T->p); in mpi_montmul() 1607 static void mpi_montred(mbedtls_mpi *A, const mbedtls_mpi *N, in mpi_montred() argument 1616 mpi_montmul(A, &U, N, mm, T); in mpi_montred() 1652 const mbedtls_mpi *E, const mbedtls_mpi *N, in mbedtls_mpi_exp_mod() argument 1667 MPI_VALIDATE_RET(N != NULL); in mbedtls_mpi_exp_mod() 1669 if (mbedtls_mpi_cmp_int(N, 0) <= 0 || (N->p[0] & 1) == 0) { in mbedtls_mpi_exp_mod() 1678 mbedtls_mpi_bitlen(N) > MBEDTLS_MPI_MAX_BITS) { in mbedtls_mpi_exp_mod() [all …]
|
D | bignum_core.h | 410 mbedtls_mpi_uint mbedtls_mpi_core_montmul_init(const mbedtls_mpi_uint *N); 450 const mbedtls_mpi_uint *N, size_t AN_limbs, 469 const mbedtls_mpi *N); 547 const mbedtls_mpi_uint *N, 602 const mbedtls_mpi_uint *N, size_t AN_limbs, 695 const mbedtls_mpi_uint *N, 732 const mbedtls_mpi_uint *N,
|
/mbedtls-3.5.0/tests/suites/ |
D | test_suite_bignum_mod.misc.data | 15 Test mpi_mod_mul #1 N->limbs != A->limbs 18 Test mpi_mod_mul #2 N->limbs != B->limbs 21 Test mpi_mod_mul #3 N->limbs != X->limbs 27 mpi_mod_sub base case for negative testing (N, a, b all >= 1 limb) 48 mbedtls_mpi_mod_inv non-Mont. form - base case for negative testing (N, A, A^-1) 60 mbedtls_mpi_mod_inv 32-bit Mont. form - base case for negative testing, A = 1 (N, mont(A), mont(A^-… 76 mbedtls_mpi_mod_inv 64-bit Mont. form - base case for negative testing, A = 1 (N, mont(A), mont(A^-… 99 mpi_mod_add base case for negative testing (N, a, b all >= 1 limb) 165 Test mbedtls_mpi_mod_io #1 N: "11" A: "119". 168 Test mbedtls_mpi_mod_io #2 N: "11" A: "136". [all …]
|
D | test_suite_ccm.data | 177 CCM encrypt and tag AES-128 (P=0, N=13, A=0, T=16) 181 CCM encrypt and tag NIST VTT AES-128 #1 (P=24, N=13, A=32, T=4) 185 CCM encrypt and tag NIST VTT AES-128 #2 (P=24, N=13, A=32, T=6) 189 CCM encrypt and tag NIST VTT AES-128 #3 (P=24, N=13, A=32, T=8) 193 CCM encrypt and tag NIST VTT AES-128 #4 (P=24, N=13, A=32, T=10) 197 CCM encrypt and tag NIST VTT AES-128 #5 (P=24, N=13, A=32, T=12) 201 CCM encrypt and tag NIST VTT AES-128 #6 (P=24, N=13, A=32, T=14) 205 CCM encrypt and tag NIST VTT AES-128 #7 (P=24, N=13, A=32, T=16) 209 CCM encrypt and tag NIST VTT AES-192 #1 (P=24, N=13, A=32, T=4) 213 CCM encrypt and tag NIST VTT AES-192 #2 (P=24, N=13, A=32, T=6) [all …]
|
D | test_suite_cipher.ccm.data | 1 AES-128-CCM test vector NIST #1 (P=0, N=7, A=0, T=4) 5 AES-128-CCM test vector NIST #2 (P=0, N=7, A=0, T=4) 9 AES-128-CCM test vector NIST #3 (P=0, N=7, A=0, T=16) 13 AES-128-CCM test vector NIST #4 (P=0, N=7, A=0, T=16) 17 AES-128-CCM test vector NIST #5 (P=0, N=13, A=0, T=4) 21 AES-128-CCM test vector NIST #6 (P=0, N=13, A=0, T=4) 25 AES-128-CCM test vector NIST #7 (P=0, N=13, A=0, T=16) 29 AES-128-CCM test vector NIST #8 (P=0, N=13, A=0, T=16) 33 AES-128-CCM test vector NIST #9 (P=24, N=7, A=0, T=4) 37 AES-128-CCM test vector NIST #10 (P=24, N=7, A=0, T=4) [all …]
|
D | test_suite_pkcs1_v21.function | 19 mbedtls_mpi N, E; 26 mbedtls_mpi_init(&N); mbedtls_mpi_init(&E); 35 TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0); 37 TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, NULL, NULL, NULL, &E) == 0); 54 mbedtls_mpi_free(&N); mbedtls_mpi_free(&E); 69 mbedtls_mpi N, P, Q, E; 72 mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); 87 TEST_ASSERT(mbedtls_mpi_read_binary(&N, input_N->x, input_N->len) == 0); 90 TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, &P, &Q, NULL, &E) == 0); 114 mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); [all …]
|
D | test_suite_rsa.data | 291 RSA Check Private key #4 (No N) 318 RSA Check Public key #2 (Even N) 324 RSA Check Public key #4 (N exactly 128 bits) 327 RSA Check Public key #5 (N smaller than 128 bits) 330 RSA Check Public key #6 (N exactly 8192 bits) 334 RSA Check Public key #7 (N larger than 8192 bits) 349 RSA Check Public key #9 (E has size N-2) 352 RSA Check Public key #10 (E has size N) 358 RSA Check Public-Private key #2 (Public no N) 361 RSA Check Public-Private key #3 (Private no N) [all …]
|
D | test_suite_rsa.function | 169 mbedtls_mpi N, P, Q, E; 172 mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); 183 TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0); 186 TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, &P, &Q, NULL, &E) == 0); 202 mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); 215 mbedtls_mpi N, E; 217 mbedtls_mpi_init(&N); mbedtls_mpi_init(&E); 222 TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0); 224 TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, NULL, NULL, NULL, &E) == 0); 232 mbedtls_mpi_free(&N); mbedtls_mpi_free(&E); [all …]
|
D | test_suite_bignum_mod_raw.function | 280 mbedtls_mpi_uint *N = NULL; 293 TEST_EQUAL(mbedtls_test_read_mpi_core(&N, &limbs_N, input_N), 0); 306 &m, N, limbs, 339 mbedtls_free(N); 349 mbedtls_mpi_uint *N = NULL; 360 TEST_EQUAL(mbedtls_test_read_mpi_core(&N, &limbs_N, input_N), 0); 372 /* Check that 0 <= X < 2N */ 373 mbedtls_mpi_uint c = mbedtls_mpi_core_sub(tmp, X, N, limbs); 374 TEST_ASSERT(c || mbedtls_mpi_core_lt_ct(tmp, N, limbs)); 377 &m, N, limbs, [all …]
|
D | test_suite_pkcs1_v15.function | 22 mbedtls_mpi N, E; 29 mbedtls_mpi_init(&N); mbedtls_mpi_init(&E); 42 TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0); 44 TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, NULL, NULL, NULL, &E) == 0); 63 mbedtls_mpi_free(&N); mbedtls_mpi_free(&E); 78 mbedtls_mpi N, P, Q, E; 81 mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); 95 TEST_ASSERT(mbedtls_test_read_mpi(&N, input_N) == 0); 98 TEST_ASSERT(mbedtls_rsa_import(&ctx, &N, &P, &Q, NULL, &E) == 0); 123 mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); [all …]
|
D | test_suite_bignum_random.function | 208 mbedtls_mpi_mod_modulus N; 209 mbedtls_mpi_mod_modulus_init(&N); 211 TEST_EQUAL(mbedtls_test_read_mpi_modulus(&N, max_hex, rep), 0); 212 ASSERT_ALLOC(R_core, N.limbs); 213 ASSERT_ALLOC(R_mod_raw, N.limbs); 214 ASSERT_ALLOC(R_mod_digits, N.limbs); 215 TEST_EQUAL(mbedtls_mpi_mod_residue_setup(&R_mod, &N, 216 R_mod_digits, N.limbs), 221 min, N.p, N.limbs, 225 min, &N, [all …]
|
D | test_suite_bignum_mod.function | 352 mbedtls_mpi_mod_residue i = { NULL, 0 }; /* expected inverse wrt N */ 356 mbedtls_mpi_mod_modulus N; 357 mbedtls_mpi_mod_modulus_init(&N); 360 test_read_modulus(&N, MBEDTLS_MPI_MOD_REP_MONTGOMERY, input_N)); 365 TEST_EQUAL(0, test_read_residue(&a, &N, input_A, expected_ret != 0)); 366 TEST_EQUAL(0, test_read_residue(&i, &N, input_I, expected_ret != 0)); 368 size_t limbs = N.limbs; 373 TEST_EQUAL(0, mbedtls_mpi_mod_residue_setup(&x, &N, X_raw, limbs)); 375 TEST_EQUAL(expected_ret, mbedtls_mpi_mod_inv(&x, &a, &N)); 381 TEST_EQUAL(0, mbedtls_mpi_mod_inv(&x, &x, &N)); [all …]
|
D | test_suite_bignum_core.function | 754 mbedtls_mpi N, mm; 756 mbedtls_mpi_init(&N); 759 TEST_EQUAL(0, mbedtls_test_read_mpi(&N, input_N)); 771 TEST_EQUAL(1, N.s); 775 mbedtls_mpi_uint result = mbedtls_mpi_core_montmul_init(N.p); 781 mbedtls_mpi_free(&N); 795 mbedtls_mpi A, B, N, X4, X8, T, R; 799 mbedtls_mpi_init(&N); 807 TEST_EQUAL(0, mbedtls_test_read_mpi(&N, input_N)); 824 TEST_EQUAL(1, N.s); [all …]
|
/mbedtls-3.5.0/programs/pkey/ |
D | mpi_demo.c | 43 mbedtls_mpi E, P, Q, N, H, D, X, Y, Z; in main() local 45 mbedtls_mpi_init(&E); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q); mbedtls_mpi_init(&N); in main() 52 MBEDTLS_MPI_CHK(mbedtls_mpi_mul_mpi(&N, &P, &Q)); in main() 55 MBEDTLS_MPI_CHK(mbedtls_mpi_write_file(" N = ", &N, 10, NULL)); in main() 74 MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&Y, &X, &E, &N, NULL)); in main() 75 MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&Z, &Y, &D, &N, NULL)); in main() 86 mbedtls_mpi_free(&E); mbedtls_mpi_free(&P); mbedtls_mpi_free(&Q); mbedtls_mpi_free(&N); in main()
|
D | rsa_genkey.c | 59 mbedtls_mpi N, P, Q, D, E, DP, DQ, QP; in main() local 66 mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q); in main() 93 if ((ret = mbedtls_rsa_export(&rsa, &N, &P, &Q, &D, &E)) != 0 || in main() 104 if ((ret = mbedtls_mpi_write_file("N = ", &N, 16, fpub)) != 0 || in main() 118 if ((ret = mbedtls_mpi_write_file("N = ", &N, 16, fpriv)) != 0 || in main() 143 mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); mbedtls_mpi_free(&Q); in main()
|
D | rsa_encrypt.c | 59 mbedtls_mpi N, E; in main() local 74 mbedtls_mpi_init(&N); mbedtls_mpi_init(&E); in main() 97 if ((ret = mbedtls_mpi_read_file(&N, 16, f)) != 0 || in main() 106 if ((ret = mbedtls_rsa_import(&rsa, &N, NULL, NULL, NULL, &E)) != 0) { in main() 153 mbedtls_mpi_free(&N); mbedtls_mpi_free(&E); in main()
|
/mbedtls-3.5.0/tests/src/ |
D | bignum_helpers.c | 89 int mbedtls_test_read_mpi_modulus(mbedtls_mpi_mod_modulus *N, in mbedtls_test_read_mpi_modulus() argument 95 if (N->limbs != 0) { in mbedtls_test_read_mpi_modulus() 102 ret = mbedtls_mpi_mod_modulus_setup(N, p, limbs, int_rep); in mbedtls_test_read_mpi_modulus() 109 void mbedtls_test_mpi_mod_modulus_free_with_limbs(mbedtls_mpi_mod_modulus *N) in mbedtls_test_mpi_mod_modulus_free_with_limbs() argument 111 mbedtls_free((mbedtls_mpi_uint *) N->p); in mbedtls_test_mpi_mod_modulus_free_with_limbs() 112 mbedtls_mpi_mod_modulus_free(N); in mbedtls_test_mpi_mod_modulus_free_with_limbs()
|
/mbedtls-3.5.0/programs/fuzz/ |
D | fuzz_pubkey.c | 18 mbedtls_mpi N, P, Q, D, E, DP, DQ, QP; in LLVMFuzzerTestOneInput() local 21 mbedtls_mpi_init(&N); mbedtls_mpi_init(&P); mbedtls_mpi_init(&Q); in LLVMFuzzerTestOneInput() 26 if (mbedtls_rsa_export(rsa, &N, NULL, NULL, NULL, &E) != 0) { in LLVMFuzzerTestOneInput() 29 if (mbedtls_rsa_export(rsa, &N, &P, &Q, &D, &E) != MBEDTLS_ERR_RSA_BAD_INPUT_DATA) { in LLVMFuzzerTestOneInput() 36 mbedtls_mpi_free(&N); mbedtls_mpi_free(&P); mbedtls_mpi_free(&Q); in LLVMFuzzerTestOneInput()
|