Lines Matching +full:- +full:e
1 // SPDX-License-Identifier: BSD-2-Clause
105 rsa->E = *(mbedtls_mpi *)key->e; in rsa_complete_from_key_pair()
106 rsa->N = *(mbedtls_mpi *)key->n; in rsa_complete_from_key_pair()
107 rsa->D = *(mbedtls_mpi *)key->d; in rsa_complete_from_key_pair()
108 rsa->len = mbedtls_mpi_size(&rsa->N); in rsa_complete_from_key_pair()
110 if (key->p && crypto_bignum_num_bytes(key->p)) { in rsa_complete_from_key_pair()
111 rsa->P = *(mbedtls_mpi *)key->p; in rsa_complete_from_key_pair()
112 rsa->Q = *(mbedtls_mpi *)key->q; in rsa_complete_from_key_pair()
113 rsa->QP = *(mbedtls_mpi *)key->qp; in rsa_complete_from_key_pair()
114 rsa->DP = *(mbedtls_mpi *)key->dp; in rsa_complete_from_key_pair()
115 rsa->DQ = *(mbedtls_mpi *)key->dq; in rsa_complete_from_key_pair()
117 mbedtls_mpi_init_mempool(&rsa->P); in rsa_complete_from_key_pair()
118 mbedtls_mpi_init_mempool(&rsa->Q); in rsa_complete_from_key_pair()
119 mbedtls_mpi_init_mempool(&rsa->QP); in rsa_complete_from_key_pair()
120 mbedtls_mpi_init_mempool(&rsa->DP); in rsa_complete_from_key_pair()
121 mbedtls_mpi_init_mempool(&rsa->DQ); in rsa_complete_from_key_pair()
123 lmd_res = mbedtls_rsa_deduce_primes(&rsa->N, &rsa->E, &rsa->D, in rsa_complete_from_key_pair()
124 &rsa->P, &rsa->Q); in rsa_complete_from_key_pair()
127 -lmd_res); in rsa_complete_from_key_pair()
131 lmd_res = mbedtls_rsa_deduce_crt(&rsa->P, &rsa->Q, &rsa->D, in rsa_complete_from_key_pair()
132 &rsa->DP, &rsa->DQ, &rsa->QP); in rsa_complete_from_key_pair()
135 -lmd_res); in rsa_complete_from_key_pair()
142 mbedtls_mpi_free(&rsa->P); in rsa_complete_from_key_pair()
143 mbedtls_mpi_free(&rsa->Q); in rsa_complete_from_key_pair()
144 mbedtls_mpi_free(&rsa->QP); in rsa_complete_from_key_pair()
145 mbedtls_mpi_free(&rsa->DP); in rsa_complete_from_key_pair()
146 mbedtls_mpi_free(&rsa->DQ); in rsa_complete_from_key_pair()
167 mbedtls_mpi_init(&rsa->E); in mbd_rsa_free()
168 mbedtls_mpi_init(&rsa->N); in mbd_rsa_free()
169 mbedtls_mpi_init(&rsa->D); in mbd_rsa_free()
170 if (key->p && crypto_bignum_num_bytes(key->p)) { in mbd_rsa_free()
171 mbedtls_mpi_init(&rsa->P); in mbd_rsa_free()
172 mbedtls_mpi_init(&rsa->Q); in mbd_rsa_free()
173 mbedtls_mpi_init(&rsa->QP); in mbd_rsa_free()
174 mbedtls_mpi_init(&rsa->DP); in mbd_rsa_free()
175 mbedtls_mpi_init(&rsa->DQ); in mbd_rsa_free()
182 mbedtls_rsa_context *rsa = ctx->pk_ctx; in mbd_pk_free()
200 s->e = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
201 if (!s->e) in sw_crypto_acipher_alloc_rsa_keypair()
203 s->d = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
204 if (!s->d) in sw_crypto_acipher_alloc_rsa_keypair()
206 s->n = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
207 if (!s->n) in sw_crypto_acipher_alloc_rsa_keypair()
209 s->p = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
210 if (!s->p) in sw_crypto_acipher_alloc_rsa_keypair()
212 s->q = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
213 if (!s->q) in sw_crypto_acipher_alloc_rsa_keypair()
215 s->qp = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
216 if (!s->qp) in sw_crypto_acipher_alloc_rsa_keypair()
218 s->dp = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
219 if (!s->dp) in sw_crypto_acipher_alloc_rsa_keypair()
221 s->dq = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_keypair()
222 if (!s->dq) in sw_crypto_acipher_alloc_rsa_keypair()
239 s->e = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_public_key()
240 if (!s->e) in sw_crypto_acipher_alloc_rsa_public_key()
242 s->n = crypto_bignum_allocate(key_size_bits); in sw_crypto_acipher_alloc_rsa_public_key()
243 if (!s->n) in sw_crypto_acipher_alloc_rsa_public_key()
247 crypto_bignum_free(&s->e); in sw_crypto_acipher_alloc_rsa_public_key()
258 crypto_bignum_free(&s->n); in sw_crypto_acipher_free_rsa_public_key()
259 crypto_bignum_free(&s->e); in sw_crypto_acipher_free_rsa_public_key()
269 crypto_bignum_free(&s->e); in sw_crypto_acipher_free_rsa_keypair()
270 crypto_bignum_free(&s->d); in sw_crypto_acipher_free_rsa_keypair()
271 crypto_bignum_free(&s->n); in sw_crypto_acipher_free_rsa_keypair()
272 crypto_bignum_free(&s->p); in sw_crypto_acipher_free_rsa_keypair()
273 crypto_bignum_free(&s->q); in sw_crypto_acipher_free_rsa_keypair()
274 crypto_bignum_free(&s->qp); in sw_crypto_acipher_free_rsa_keypair()
275 crypto_bignum_free(&s->dp); in sw_crypto_acipher_free_rsa_keypair()
276 crypto_bignum_free(&s->dq); in sw_crypto_acipher_free_rsa_keypair()
290 uint32_t e = 0; in sw_crypto_acipher_gen_rsa_key() local
300 mbedtls_mpi_write_binary((mbedtls_mpi *)key->e, in sw_crypto_acipher_gen_rsa_key()
301 (unsigned char *)&e, sizeof(uint32_t)); in sw_crypto_acipher_gen_rsa_key()
303 e = TEE_U32_FROM_BIG_ENDIAN(e); in sw_crypto_acipher_gen_rsa_key()
305 key_size, (int)e); in sw_crypto_acipher_gen_rsa_key()
313 crypto_bignum_copy(key->e, (void *)&rsa.E); in sw_crypto_acipher_gen_rsa_key()
314 crypto_bignum_copy(key->d, (void *)&rsa.D); in sw_crypto_acipher_gen_rsa_key()
315 crypto_bignum_copy(key->n, (void *)&rsa.N); in sw_crypto_acipher_gen_rsa_key()
316 crypto_bignum_copy(key->p, (void *)&rsa.P); in sw_crypto_acipher_gen_rsa_key()
318 crypto_bignum_copy(key->q, (void *)&rsa.Q); in sw_crypto_acipher_gen_rsa_key()
319 crypto_bignum_copy(key->qp, (void *)&rsa.QP); in sw_crypto_acipher_gen_rsa_key()
320 crypto_bignum_copy(key->dp, (void *)&rsa.DP); in sw_crypto_acipher_gen_rsa_key()
321 crypto_bignum_copy(key->dq, (void *)&rsa.DQ); in sw_crypto_acipher_gen_rsa_key()
352 rsa.E = *(mbedtls_mpi *)key->e; in sw_crypto_acipher_rsanopad_encrypt()
353 rsa.N = *(mbedtls_mpi *)key->n; in sw_crypto_acipher_rsanopad_encrypt()
365 memcpy(buf + rsa.len - src_len, src, src_len); in sw_crypto_acipher_rsanopad_encrypt()
369 FMSG("mbedtls_rsa_public() returned 0x%x", -lmd_res); in sw_crypto_acipher_rsanopad_encrypt()
374 /* Remove the zero-padding (leave one zero if buff is all zeroes) */ in sw_crypto_acipher_rsanopad_encrypt()
376 while ((offset < rsa.len - 1) && (buf[offset] == 0)) in sw_crypto_acipher_rsanopad_encrypt()
379 if (*dst_len < rsa.len - offset) { in sw_crypto_acipher_rsanopad_encrypt()
380 *dst_len = rsa.len - offset; in sw_crypto_acipher_rsanopad_encrypt()
384 *dst_len = rsa.len - offset; in sw_crypto_acipher_rsanopad_encrypt()
389 mbedtls_mpi_init(&rsa.E); in sw_crypto_acipher_rsanopad_encrypt()
426 memcpy(buf + rsa.len - src_len, src, src_len); in sw_crypto_acipher_rsanopad_decrypt()
430 FMSG("mbedtls_rsa_private() returned 0x%x", -lmd_res); in sw_crypto_acipher_rsanopad_decrypt()
435 /* Remove the zero-padding (leave one zero if buff is all zeroes) */ in sw_crypto_acipher_rsanopad_decrypt()
437 while ((offset < rsa.len - 1) && (buf[offset] == 0)) in sw_crypto_acipher_rsanopad_decrypt()
440 if (*dst_len < rsa.len - offset) { in sw_crypto_acipher_rsanopad_decrypt()
441 *dst_len = rsa.len - offset; in sw_crypto_acipher_rsanopad_decrypt()
445 *dst_len = rsa.len - offset; in sw_crypto_acipher_rsanopad_decrypt()
504 mod_size = crypto_bignum_num_bytes(key->n); in sw_crypto_acipher_rsaes_decrypt()
505 blen = mod_size - 11; in sw_crypto_acipher_rsaes_decrypt()
538 lmd_res = pk_info->decrypt_func(&ctx, src, src_len, buf, &blen, in sw_crypto_acipher_rsaes_decrypt()
541 FMSG("decrypt_func() returned 0x%x", -lmd_res); in sw_crypto_acipher_rsaes_decrypt()
603 rsa->E = *(mbedtls_mpi *)key->e; in sw_crypto_acipher_rsaes_encrypt()
604 rsa->N = *(mbedtls_mpi *)key->n; in sw_crypto_acipher_rsaes_encrypt()
606 mod_size = crypto_bignum_num_bytes(key->n); in sw_crypto_acipher_rsaes_encrypt()
613 rsa->len = mod_size; in sw_crypto_acipher_rsaes_encrypt()
636 lmd_res = pk_info->encrypt_func(&ctx, src, src_len, dst, dst_len, in sw_crypto_acipher_rsaes_encrypt()
639 FMSG("encrypt_func() returned 0x%x", -lmd_res); in sw_crypto_acipher_rsaes_encrypt()
646 mbedtls_mpi_init(&rsa->E); in sw_crypto_acipher_rsaes_encrypt()
647 mbedtls_mpi_init(&rsa->N); in sw_crypto_acipher_rsaes_encrypt()
723 mod_size = crypto_bignum_num_bytes(key->n); in sw_crypto_acipher_rsassa_sign()
729 rsa->len = mod_size; in sw_crypto_acipher_rsassa_sign()
740 lmd_res = pk_info->sign_func(&ctx, md_algo, msg, msg_len, sig, in sw_crypto_acipher_rsassa_sign()
743 FMSG("sign_func failed, returned 0x%x", -lmd_res); in sw_crypto_acipher_rsassa_sign()
801 rsa->E = *(mbedtls_mpi *)key->e; in sw_crypto_acipher_rsassa_verify()
802 rsa->N = *(mbedtls_mpi *)key->n; in sw_crypto_acipher_rsassa_verify()
814 bigint_size = crypto_bignum_num_bytes(key->n); in sw_crypto_acipher_rsassa_verify()
820 rsa->len = bigint_size; in sw_crypto_acipher_rsassa_verify()
855 lmd_res = pk_info->verify_func(&ctx, md_algo, msg, msg_len, in sw_crypto_acipher_rsassa_verify()
861 FMSG("verify_func failed, returned 0x%x", -lmd_res); in sw_crypto_acipher_rsassa_verify()
873 mbedtls_mpi_init(&rsa->E); in sw_crypto_acipher_rsassa_verify()
874 mbedtls_mpi_init(&rsa->N); in sw_crypto_acipher_rsassa_verify()