| /optee_os/lib/libmbedtls/mbedtls/library/ |
| H A D | bignum_mod_raw.c | 28 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_cond_assign() argument 31 mbedtls_mpi_core_cond_assign(X, A, N->limbs, mbedtls_ct_bool(assign)); in mbedtls_mpi_mod_raw_cond_assign() 36 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_cond_swap() argument 39 mbedtls_mpi_core_cond_swap(X, Y, N->limbs, mbedtls_ct_bool(swap)); in mbedtls_mpi_mod_raw_cond_swap() 43 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_read() argument 52 ret = mbedtls_mpi_core_read_le(X, N->limbs, in mbedtls_mpi_mod_raw_read() 56 ret = mbedtls_mpi_core_read_be(X, N->limbs, in mbedtls_mpi_mod_raw_read() 67 if (!mbedtls_mpi_core_lt_ct(X, N->p, N->limbs)) { in mbedtls_mpi_mod_raw_read() 78 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_raw_write() argument 85 return mbedtls_mpi_core_write_le(A, N->limbs, in mbedtls_mpi_mod_raw_write() [all …]
|
| H A D | bignum_mod.c | 26 const mbedtls_mpi_mod_modulus *N, in mbedtls_mpi_mod_residue_setup() argument 30 if (p_limbs != N->limbs || !mbedtls_mpi_core_lt_ct(p, N->p, N->limbs)) { in mbedtls_mpi_mod_residue_setup() 34 r->limbs = N->limbs; in mbedtls_mpi_mod_residue_setup() 50 void mbedtls_mpi_mod_modulus_init(mbedtls_mpi_mod_modulus *N) in mbedtls_mpi_mod_modulus_init() argument 52 if (N == NULL) { in mbedtls_mpi_mod_modulus_init() 56 N->p = NULL; in mbedtls_mpi_mod_modulus_init() 57 N->limbs = 0; in mbedtls_mpi_mod_modulus_init() 58 N->bits = 0; in mbedtls_mpi_mod_modulus_init() 59 N->int_rep = MBEDTLS_MPI_MOD_REP_INVALID; in mbedtls_mpi_mod_modulus_init() 62 void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *N) in mbedtls_mpi_mod_modulus_free() argument [all …]
|
| H A D | bignum_mod_raw.h | 102 const mbedtls_mpi_mod_modulus *N, 128 const mbedtls_mpi_mod_modulus *N, 151 const mbedtls_mpi_mod_modulus *N, 173 const mbedtls_mpi_mod_modulus *N, 198 const mbedtls_mpi_mod_modulus *N); 232 const mbedtls_mpi_mod_modulus *N, 279 const mbedtls_mpi_uint *N, 305 const mbedtls_mpi_mod_modulus *N); 322 const mbedtls_mpi_mod_modulus *N); 339 const mbedtls_mpi_mod_modulus *N); [all …]
|
| H A D | bignum_mod.h | 163 const mbedtls_mpi_mod_modulus *N, 183 void mbedtls_mpi_mod_modulus_init(mbedtls_mpi_mod_modulus *N); 196 int mbedtls_mpi_mod_modulus_setup(mbedtls_mpi_mod_modulus *N, 212 int mbedtls_mpi_mod_optred_modulus_setup(mbedtls_mpi_mod_modulus *N, 227 void mbedtls_mpi_mod_modulus_free(mbedtls_mpi_mod_modulus *N); 261 const mbedtls_mpi_mod_modulus *N); 291 const mbedtls_mpi_mod_modulus *N); 320 const mbedtls_mpi_mod_modulus *N); 350 const mbedtls_mpi_mod_modulus *N); 381 const mbedtls_mpi_mod_modulus *N, [all …]
|
| H A D | rsa_alt_helpers.c | 50 int mbedtls_rsa_deduce_primes(mbedtls_mpi const *N, in mbedtls_rsa_deduce_primes() argument 79 if (mbedtls_mpi_cmp_int(N, 0) <= 0 || in mbedtls_rsa_deduce_primes() 81 mbedtls_mpi_cmp_mpi(D, N) >= 0 || in mbedtls_rsa_deduce_primes() 83 mbedtls_mpi_cmp_mpi(E, N) >= 0) { in mbedtls_rsa_deduce_primes() 112 if (N->p[0] % 8 == 1) { in mbedtls_rsa_deduce_primes() 120 MBEDTLS_MPI_CHK(mbedtls_mpi_gcd(P, &K, N)); in mbedtls_rsa_deduce_primes() 127 MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(&K, &K, &T, N, in mbedtls_rsa_deduce_primes() 139 MBEDTLS_MPI_CHK(mbedtls_mpi_gcd(P, &K, N)); in mbedtls_rsa_deduce_primes() 142 mbedtls_mpi_cmp_mpi(P, N) == -1) { in mbedtls_rsa_deduce_primes() 148 MBEDTLS_MPI_CHK(mbedtls_mpi_div_mpi(Q, NULL, N, P)); in mbedtls_rsa_deduce_primes() [all …]
|
| H A D | bignum_core.c | 513 mbedtls_mpi_uint mbedtls_mpi_core_montmul_init(const mbedtls_mpi_uint *N) in mbedtls_mpi_core_montmul_init() argument 515 mbedtls_mpi_uint x = N[0]; in mbedtls_mpi_core_montmul_init() 517 x += ((N[0] + 2) & 4) << 1; in mbedtls_mpi_core_montmul_init() 520 x *= (2 - (N[0] * x)); in mbedtls_mpi_core_montmul_init() 530 const mbedtls_mpi_uint *N, in mbedtls_mpi_core_montmul() argument 543 (void) mbedtls_mpi_core_mla(T, AN_limbs + 2, N, AN_limbs, u1); in mbedtls_mpi_core_montmul() 559 mbedtls_mpi_uint borrow = mbedtls_mpi_core_sub(X, T, N, AN_limbs); in mbedtls_mpi_core_montmul() 583 const mbedtls_mpi *N) in mbedtls_mpi_core_get_mont_r2_unsafe() argument 588 MBEDTLS_MPI_CHK(mbedtls_mpi_shift_l(X, N->n * 2 * biL)); in mbedtls_mpi_core_get_mont_r2_unsafe() 589 MBEDTLS_MPI_CHK(mbedtls_mpi_mod_mpi(X, X, N)); in mbedtls_mpi_core_get_mont_r2_unsafe() [all …]
|
| H A D | bignum_core.h | 472 mbedtls_mpi_uint mbedtls_mpi_core_montmul_init(const mbedtls_mpi_uint *N); 512 const mbedtls_mpi_uint *N, size_t AN_limbs, 531 const mbedtls_mpi *N); 609 const mbedtls_mpi_uint *N, 664 const mbedtls_mpi_uint *N, size_t AN_limbs, 698 const mbedtls_mpi_uint *N, size_t AN_limbs, 783 const mbedtls_mpi_uint *N, 820 const mbedtls_mpi_uint *N,
|
| H A D | rsa.c | 575 const mbedtls_mpi *N, in mbedtls_rsa_import() argument 581 if ((N != NULL && (ret = mbedtls_mpi_copy(&ctx->N, N)) != 0) || in mbedtls_rsa_import() 589 if (N != NULL) { in mbedtls_rsa_import() 590 ctx->len = mbedtls_mpi_size(&ctx->N); in mbedtls_rsa_import() 597 unsigned char const *N, size_t N_len, in mbedtls_rsa_import_raw() argument 605 if (N != NULL) { in mbedtls_rsa_import_raw() 606 MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ctx->N, N, N_len)); in mbedtls_rsa_import_raw() 607 ctx->len = mbedtls_mpi_size(&ctx->N); in mbedtls_rsa_import_raw() 649 if (ctx->len != mbedtls_mpi_size(&ctx->N) || in rsa_check_context() 660 if (mbedtls_mpi_cmp_int(&ctx->N, 0) <= 0 || in rsa_check_context() [all …]
|
| H A D | bignum.c | 1669 void mbedtls_mpi_montg_init(mbedtls_mpi_uint *mm, const mbedtls_mpi *N) in mbedtls_mpi_montg_init() argument 1671 *mm = mbedtls_mpi_core_montmul_init(N->p); in mbedtls_mpi_montg_init() 1698 const mbedtls_mpi *N, mbedtls_mpi_uint mm, in mbedtls_mpi_montmul() argument 1701 mbedtls_mpi_core_montmul(A->p, A->p, B->p, B->n, N->p, N->n, mm, T->p); in mbedtls_mpi_montmul() 1712 void mbedtls_mpi_montred(mbedtls_mpi *A, const mbedtls_mpi *N, in mbedtls_mpi_montred() argument 1721 mbedtls_mpi_montmul(A, &U, N, mm, T); in mbedtls_mpi_montred() 1730 const mbedtls_mpi *N, mbedtls_mpi *prec_RR) in mbedtls_mpi_exp_mod_optionally_safe() argument 1734 if (mbedtls_mpi_cmp_int(N, 0) <= 0 || (N->p[0] & 1) == 0) { in mbedtls_mpi_exp_mod_optionally_safe() 1743 mbedtls_mpi_bitlen(N) > MBEDTLS_MPI_MAX_BITS) { in mbedtls_mpi_exp_mod_optionally_safe() 1758 size_t T_limbs = mbedtls_mpi_core_exp_mod_working_limbs(N->n, E->n); in mbedtls_mpi_exp_mod_optionally_safe() [all …]
|
| H A D | ecp_curves.c | 4570 ecp_mpi_load(&grp->N, n, nlen); in ecp_group_load() 4577 grp->nbits = mbedtls_mpi_bitlen(&grp->N); in ecp_group_load() 4678 MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&grp->N, in ecp_use_curve25519() 4680 MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&grp->N, 252, 1)); in ecp_use_curve25519() 4738 MBEDTLS_MPI_CHK(mbedtls_mpi_set_bit(&grp->N, 446, 1)); in ecp_use_curve448() 4741 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&grp->N, &grp->N, &Ns)); in ecp_use_curve448() 4901 #define A(i) N->p + (i) * WIDTH 4909 static int ecp_mod_p192(mbedtls_mpi *N) in ecp_mod_p192() argument 4916 MBEDTLS_MPI_CHK(mbedtls_mpi_grow(N, 6 * WIDTH)); in ecp_mod_p192() 4918 p = N->p; in ecp_mod_p192() [all …]
|
| /optee_os/lib/libutils/compiler-rt/lib/builtins/ |
| H A D | int_div_impl.inc | 17 const unsigned N = sizeof(fixuint_t) * CHAR_BIT; 19 unsigned sr = (d ? clz(d) : N) - (n ? clz(n) : N); 20 // 0 <= sr <= N - 1 or sr is very large. 21 if (sr > N - 1) // n < d 23 if (sr == N - 1) // d == 1 26 // 1 <= sr <= N - 1. Shifts do not trigger UB. 28 n <<= N - sr; 31 r = (r << 1) | (n >> (N - 1)); 36 const fixint_t s = (fixint_t)(d - r - 1) >> (N - 1); 46 const unsigned N = sizeof(fixuint_t) * CHAR_BIT; [all …]
|
| H A D | int_util.h | 44 #define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat) argument 45 #define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat) argument
|
| H A D | int_mulo_impl.inc | 20 const int N = (int)(sizeof(fixint_t) * CHAR_BIT); 21 const fixint_t MIN = (fixint_t)((fixuint_t)1 << (N - 1)); 35 fixint_t sa = a >> (N - 1); 37 fixint_t sb = b >> (N - 1);
|
| /optee_os/core/lib/libtomcrypt/src/math/ |
| H A D | rand_bn.c | 10 int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng) in rand_bn_bits() argument 15 LTC_ARGCHK(N != NULL); in rand_bn_bits() 35 if ((res = mp_read_unsigned_bin(N, buf, bytes)) != CRYPT_OK) goto cleanup; in rand_bn_bits() 50 int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng) in rand_bn_upto() argument 54 LTC_ARGCHK(N != NULL); in rand_bn_upto() 59 res = rand_bn_bits(N, bits, prng, wprng); in rand_bn_upto() 61 } while (mp_cmp_d(N, 0) != LTC_MP_GT || mp_cmp(N, limit) != LTC_MP_LT); in rand_bn_upto()
|
| H A D | rand_prime.c | 14 int rand_prime(void *N, long len, prng_state *prng, int wprng) in rand_prime() argument 19 LTC_ARGCHK(N != NULL); in rand_prime() 57 if ((err = mp_read_unsigned_bin(N, buf, len)) != CRYPT_OK) { in rand_prime() 63 if ((err = mp_prime_is_prime(N, LTC_MILLER_RABIN_REPS, &res)) != CRYPT_OK) { in rand_prime()
|
| /optee_os/core/lib/libtomcrypt/src/pk/rsa/ |
| H A D | rsa_exptmod.c | 61 if (mp_cmp(key->N, tmp) == LTC_MP_LT) { in rsa_exptmod() 70 err = mp_rand(rnd, mp_get_digit_count(key->N)); in rsa_exptmod() 76 err = mp_invmod(rnd, key->N, rndi); in rsa_exptmod() 82 err = mp_exptmod( rnd, key->e, key->N, rnd); in rsa_exptmod() 88 err = mp_mulmod( tmp, rnd, key->N, tmp); in rsa_exptmod() 105 …if ((err = mp_exptmod(tmp, key->d, key->N, tmp)) != CRYPT_OK) { goto … in rsa_exptmod() 124 err = mp_mulmod( tmp, rndi, key->N, tmp); in rsa_exptmod() 132 …if ((err = mp_exptmod(tmp, key->e, key->N, tmpa)) != CRYPT_OK) { goto… in rsa_exptmod() 139 …if ((err = mp_exptmod(tmp, key->e, key->N, tmp)) != CRYPT_OK) { got… in rsa_exptmod() 143 x = (unsigned long)mp_unsigned_bin_size(key->N); in rsa_exptmod() [all …]
|
| H A D | rsa_set.c | 20 int rsa_set_key(const unsigned char *N, unsigned long Nlen, in rsa_set_key() argument 28 LTC_ARGCHK(N != NULL); in rsa_set_key() 34 …if ((err = mp_read_unsigned_bin(key->N , (unsigned char *)N , Nlen)) != CRYPT_OK) { goto LBL_ER… in rsa_set_key()
|
| H A D | rsa_export.c | 42 LTC_ASN1_INTEGER, 1UL, key->N, in rsa_export() 59 tmplen = (unsigned long)(mp_count_bits(key->N) / 8) * 2 + 8; in rsa_export() 72 LTC_ASN1_INTEGER, 1UL, key->N, in rsa_export()
|
| /optee_os/core/lib/libtomcrypt/src/encauth/ocb3/ |
| H A D | ocb3_test.c | 179 const unsigned char N[] = { 0xBB,0xAA,0x99,0x88,0x77,0x66,0x55,0x44, in ocb3_test() 249 N, sizeof(N), in ocb3_test() 263 N, sizeof(N), in ocb3_test() 278 if ((err = ocb3_init(&ocb, idx, K, sizeof(K), N, sizeof(N), 12)) != CRYPT_OK) return err; in ocb3_test() 286 if ((err = ocb3_init(&ocb, idx, K, sizeof(K), N, sizeof(N), 12)) != CRYPT_OK) return err; in ocb3_test()
|
| /optee_os/lib/libmbedtls/core/ |
| H A D | sm2-dsa.c | 67 res = mbed_gen_random_upto(&k, &grp.N); in sm2_mbedtls_dsa_sign() 86 mres = mbedtls_mpi_mod_mpi(&r, &r, &grp.N); in sm2_mbedtls_dsa_sign() 96 !mbedtls_mpi_cmp_mpi(&tmp, &grp.N)); in sm2_mbedtls_dsa_sign() 103 mres = mbedtls_mpi_inv_mod(&s, &s, &grp.N); in sm2_mbedtls_dsa_sign() 109 mres = mbedtls_mpi_mod_mpi(&tmp, &tmp, &grp.N); in sm2_mbedtls_dsa_sign() 118 mres = mbedtls_mpi_mod_mpi(&s, &s, &grp.N); in sm2_mbedtls_dsa_sign() 194 mbedtls_mpi_cmp_mpi(&rprime, &grp.N) >= 0) { in sm2_mbedtls_dsa_verify() 202 mbedtls_mpi_cmp_mpi(&sprime, &grp.N) >= 0) { in sm2_mbedtls_dsa_verify() 217 mres = mbedtls_mpi_mod_mpi(&t, &t, &grp.N); in sm2_mbedtls_dsa_verify() 249 mres = mbedtls_mpi_mod_mpi(&R, &R, &grp.N); in sm2_mbedtls_dsa_verify()
|
| /optee_os/core/lib/libtomcrypt/src/ciphers/ |
| H A D | multi2.c | 74 static void s_encrypt(ulong32 *p, int N, const ulong32 *uk) in s_encrypt() argument 78 s_pi1(p); if (++n == N) break; in s_encrypt() 79 s_pi2(p, uk+t); if (++n == N) break; in s_encrypt() 80 s_pi3(p, uk+t); if (++n == N) break; in s_encrypt() 81 s_pi4(p, uk+t); if (++n == N) break; in s_encrypt() 86 static void s_decrypt(ulong32 *p, int N, const ulong32 *uk) in s_decrypt() argument 89 for (t = 4*(((N-1)>>2)&1), n = N; ; ) { in s_decrypt() 125 skey->multi2.N = num_rounds; in multi2_setup() 153 s_encrypt(p, skey->multi2.N, skey->multi2.uk); in multi2_ecb_encrypt() 174 s_decrypt(p, skey->multi2.N, skey->multi2.uk); in multi2_ecb_decrypt()
|
| H A D | anubis.c | 884 int N, R, i, pos, r; in s_anubis_setup() local 902 N = skey->anubis.keyBits >> 5; in s_anubis_setup() 907 skey->anubis.R = R = 8 + N; in s_anubis_setup() 916 for (i = 0, pos = 0; i < N; i++, pos += 4) { in s_anubis_setup() 931 K0 = T4[(kappa[N - 1] >> 24) & 0xff]; in s_anubis_setup() 932 K1 = T4[(kappa[N - 1] >> 16) & 0xff]; in s_anubis_setup() 933 K2 = T4[(kappa[N - 1] >> 8) & 0xff]; in s_anubis_setup() 934 K3 = T4[(kappa[N - 1] ) & 0xff]; in s_anubis_setup() 935 for (i = N - 2; i >= 0; i--) { in s_anubis_setup() 978 for (i = 0; i < N; i++) { in s_anubis_setup() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/stream/sober128/ |
| H A D | sober128_stream.c | 17 #define N 17 macro 40 #define OFF(zero, i) (((zero)+(i)) % N) 54 for (i = 1; i < N; ++i) { in cycle() 57 R[N-1] = t; in cycle() 84 for (i = 0; i < N; ++i) { in s128_savestate() 95 for (i = 0; i < N; ++i) { in s128_reloadstate() 169 for (i = 2; i < N; ++i) { in sober128_stream_setup() 263 while (inlen >= N*4) { in sober128_stream_crypt() 281 out += 4*N; in sober128_stream_crypt() 282 in += 4*N; in sober128_stream_crypt() [all …]
|
| /optee_os/core/lib/libtomcrypt/src/misc/hkdf/ |
| H A D | hkdf.c | 37 unsigned char N; in hkdf_expand() local 72 N = 0; in hkdf_expand() 76 T[Tlen - 1] = ++N; in hkdf_expand() 90 XMEMCPY(T, out + hashsize * (N-1), hashsize); in hkdf_expand() 91 if (N == 1) { in hkdf_expand()
|
| /optee_os/core/lib/libtomcrypt/src/pk/dsa/ |
| H A D | dsa_generate_pqg.c | 25 unsigned long L, N, n, outbytes, seedbytes, counter, j, i; in s_dsa_make_params() local 71 N = (unsigned long)group_size * 8; in s_dsa_make_params() 77 if (N <= 160) { mr_tests_q = 19; } in s_dsa_make_params() 78 else if (N <= 224) { mr_tests_q = 24; } in s_dsa_make_params() 86 if (N <= 160) { mr_tests_q = 40; } in s_dsa_make_params() 87 else if (N <= 224) { mr_tests_q = 56; } in s_dsa_make_params() 99 if (N > hash_descriptor[hash]->hashsize * 8) { in s_dsa_make_params() 116 if ((err = mp_2expt(t2N1, N-1)) != CRYPT_OK) { goto cleanup; } in s_dsa_make_params()
|