Skip to content

Commit

Permalink
core: libtomcrypt: Remove prng_state* NULL pointer check from x25519_…
Browse files Browse the repository at this point in the history
…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 OP-TEE#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>
  • Loading branch information
sohhass authored and jenswi-linaro committed Apr 24, 2024
1 parent edb8618 commit e8f42d8
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion core/lib/libtomcrypt/src/pk/x25519/x25519_make_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ int x25519_make_key(prng_state *prng, int wprng, curve25519_key *key)
{
int err;

LTC_ARGCHK(prng != NULL);
LTC_ARGCHK(key != NULL);

if ((err = prng_is_valid(wprng)) != CRYPT_OK) {
Expand Down

0 comments on commit e8f42d8

Please sign in to comment.