| c225295b | 20-Dec-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: LTC mpi_desc.c: use mempool_alloc() instead of malloc()
Replace the calls to malloc() and free() with calls to mempool_alloc() and mempool_free() in order to guarantee that we don't have to re
core: LTC mpi_desc.c: use mempool_alloc() instead of malloc()
Replace the calls to malloc() and free() with calls to mempool_alloc() and mempool_free() in order to guarantee that we don't have to return TEE_ERROR_OUT_OF_MEMORY and cause a panic in the TA.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b7563bab | 29-Sep-2022 |
Jerome Forissier <jerome.forissier@linaro.org> |
libtomcrypt: ctr_encrypt(): adjust for OP-TEE CE accelerated routines
Commit 8411e6ad673d ("Squashed commit upgrading to libtomcrypt-1.18.2-develop-20220913") is missing a local change in ctr_encryp
libtomcrypt: ctr_encrypt(): adjust for OP-TEE CE accelerated routines
Commit 8411e6ad673d ("Squashed commit upgrading to libtomcrypt-1.18.2-develop-20220913") is missing a local change in ctr_encrypt.c which should have been carried over from the previous import branch, see commit 5a913ee74d3c ("Squashed commit upgrading to libtomcrypt-1.18.2-develop-20180819"). The missing code is from commit c54b6344cc4e ("core: crypto: cleanup and fix CE accelerated AES CTR"). Most of that commit was made irrelevant after the move of accelerated code out of core/lib/libtomcrypt/src, except for the bits that touch ctr_encrypt() in core/lib/libtomcrypt/src/modes/ctr/ctr_encrypt.c.
Re-introduce the needed change. Fixes failures in xtest 4003 when CFG_CRYPTO_WITH_CE=y.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 2d7740f6 | 03-Jun-2022 |
Sohaib ul Hassan <sohaib.ul.hassan@unikie.com> |
core: libtomcrypt: Remove prng_state* NULL pointer check from x25519_make_key()
Calling x25519_make_key(prng_state *prng, int wprng, curve25519_key *key) checks if prng_state is NULL. This would req
core: libtomcrypt: Remove prng_state* NULL pointer check from x25519_make_key()
Calling x25519_make_key(prng_state *prng, int wprng, curve25519_key *key) checks if prng_state is NULL. This would require the caller to pass a valid pointer. Initializing prng_state in some configurations can get very large. For instance, xtest for X25519 key generation causes the TA to panic due to stack overrun
F/TC:? 0 trace_syscall:151 syscall #54 (syscall_obj_generate_key) E/TC:1 Dead canary at end of 'stack_abt[3]' (0xe1a01fc) E/TC:1 Panic at core/kernel/thread.c:124 <thread_check_canaries> E/TC:1 TEE load address @ 0xe100000 E/TC:1 Call stack: E/TC:1 0x0e108934 print_kernel_stack at optee_os/core/arch/arm/kernel/unwind_arm64.c:80 E/TC:1 0x0e113f24 __do_panic at optee_os/core/kernel/panic.c:24 E/TC:1 0x0e116eb4 thread_check_canaries at optee_os/core/kernel/thread.c:115 E/TC:1 0x0e106a60 thread_handle_std_smc at optee_os/core/arch/arm/kernel/thread_optee_smc.c:56
OP-TEE registers a custom prng descriptor (prng_crypto_desc) used for LTC asymmetric crypto operations and prng_state is not used.
The LTC_ARGCHK(prng != NULL) check is not present in the LTC key generation functions for ECC, RSA, DH and DSA implementations.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Sohaib ul Hassan <sohaib.ul.hassan@unikie.com>
show more ...
|
| ecf9194d | 09-Mar-2022 |
Jerome Forissier <jerome@forissier.org> |
core: ltc: sm2: use proper curve during key generation
TEE_GenerateKey() generates an invalid key pair for SM2: the point is not on the curve, it is on the NIST P256 curve instead. Fix this by looki
core: ltc: sm2: use proper curve during key generation
TEE_GenerateKey() generates an invalid key pair for SM2: the point is not on the curve, it is on the NIST P256 curve instead. Fix this by looking up the proper curve name before key generation.
Link: https://github.com/OP-TEE/optee_os/issues/5211 Signed-off-by: Jerome Forissier <jerome@forissier.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| d803b885 | 01-Dec-2021 |
Dominique Martinet <dominique.martinet@atmark-techno.com> |
libtomcrypt/sha256_accel: fix stringop-overflow error
Attempting to build optee-os with gcc11 fails with the following error ---- In function ‘sha256_compress_nblocks’, inlined from ‘sha256_comp
libtomcrypt/sha256_accel: fix stringop-overflow error
Attempting to build optee-os with gcc11 fails with the following error ---- In function ‘sha256_compress_nblocks’, inlined from ‘sha256_compress’ at core/lib/libtomcrypt/sha256_accel.c:81:11, inlined from ‘sha256_done’ at core/lib/libtomcrypt/sha256_accel.c:158:5: core/lib/libtomcrypt/sha256_accel.c:75:5: error: ‘crypto_accel_sha256_compress’ accessing 32 bytes in a region of size 20 [-Werror=stringop-overflow=] 75 | crypto_accel_sha256_compress(state, buf, blocks); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ core/lib/libtomcrypt/sha256_accel.c: In function ‘sha256_done’: core/lib/libtomcrypt/sha256_accel.c:75:5: note: referencing argument 1 of type ‘uint32_t *’ {aka ‘unsigned int *’} In file included from core/lib/libtomcrypt/sha256_accel.c:41: core/include/crypto/crypto_accel.h:45:6: note: in a call to function ‘crypto_accel_sha256_compress’ 45 | void crypto_accel_sha256_compress(uint32_t state[8], const void *src, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ----
Indeed, the 'state' argument here is taken from sha1.state which is a uint32_t state[5], so 20 bytes long instead of the uint32_t state[8] crypto_accel_sha256_compress expects.
OTOH we're in a sha256 function, and sha256.state conveniently is of the correct size, so use sha256.state as appropriate instead.
Note that hash_state is a union and sha{1,256}.state are at the same offset, so this is actually a no-op change.
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> Acked-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome@forissier.org>
show more ...
|
| ab2e0039 | 19-Feb-2021 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: assert result in crypto_bignum_copy()
Adds an assert() that mbedtls_mpi_copy() succeeds in crypto_bignum_copy().
This fixes coverity scan: CID 1501791 (#1 of 1): Unchecked return value (CHEC
core: assert result in crypto_bignum_copy()
Adds an assert() that mbedtls_mpi_copy() succeeds in crypto_bignum_copy().
This fixes coverity scan: CID 1501791 (#1 of 1): Unchecked return value (CHECKED_RETURN)
Reviewed-by: Jerome Forissier <jerome@forissier.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|