| 394baaf7 | 06-Nov-2025 |
Vladislavas Putys <vputys@witekio.com> |
core: ltc: rsa_verify_hash: fix panic on hash length difference
Fixing coupled conditions in rsa_verify_hash_ex(): inc1 was set to 1 in situations when ftmn_set_check_res_memcmp() was not executed a
core: ltc: rsa_verify_hash: fix panic on hash length difference
Fixing coupled conditions in rsa_verify_hash_ex(): inc1 was set to 1 in situations when ftmn_set_check_res_memcmp() was not executed and leading to a panic in FTMN_CALLEE_DONE_CHECK()
Signed-off-by: Vladislavas Putys <vputys@witekio.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| d1957bb3 | 24-Jan-2025 |
Jerome Forissier <jerome.forissier@linaro.org> |
ltc: ctr: fix counter increment when LTC_FAST is defined
In CTR mode the counter needs to be incremented upon completion of each block. Unfortunately, if there is no crypto acceleration (accel_ctr_e
ltc: ctr: fix counter increment when LTC_FAST is defined
In CTR mode the counter needs to be incremented upon completion of each block. Unfortunately, if there is no crypto acceleration (accel_ctr_encrypt == NULL) and if LTC_FAST is defined, this does not happen. Add the missing call to fix the issue.
Reported-by: Jork Loeser <jork.loeser@microsoft.com> Closes: https://lists.trustedfirmware.org/archives/list/op-tee@lists.trustedfirmware.org/thread/J4MMZPCM2MNKC2KWAXZUMTVEJP56U6OI/ Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 04e46975 | 16-Dec-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
tree-wide: use ROUNDUP_DIV() where applicable
Use ROUNDUP_DIV() instead of ROUNDUP(..., size) / size where applicable.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Je
tree-wide: use ROUNDUP_DIV() where applicable
Use ROUNDUP_DIV() instead of ROUNDUP(..., size) / size where applicable.
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| eaa924ef | 02-Dec-2024 |
Matej Zachar <zachar.matej@gmail.com> |
core: ltc: Ed25519 sign correctly returns TEE_ERROR_SHORT_BUFFER
Returns TEE_ERROR_SHORT_BUFFER when there is not enough space to hold signature so applications using the API can determine the requi
core: ltc: Ed25519 sign correctly returns TEE_ERROR_SHORT_BUFFER
Returns TEE_ERROR_SHORT_BUFFER when there is not enough space to hold signature so applications using the API can determine the required buffer size when supplying 0 sized signature buffer.
This is happening from PKCS#11 TA when client library uses 1. method from "5.2 Conventions for functions returning output in a variable-length buffer" defined in PKCS#11 v3.0 spec.
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Signed-off-by: Matej Zachar <zachar.matej@gmail.com>
show more ...
|
| b339ffbd | 08-Jul-2024 |
Abhishek Revadekar <abhishek.rvdkr@yahoo.com> |
core: lib: fix undefined behavior shift_out_of_bounds in libtomcrypt
Replace 'i64' with 'u64' data type for variables requiring bitwise shift operations.
xtest error log - 4007_ed25519: --- $ xtest
core: lib: fix undefined behavior shift_out_of_bounds in libtomcrypt
Replace 'i64' with 'u64' data type for variables requiring bitwise shift operations.
xtest error log - 4007_ed25519: --- $ xtest 4007_ed25519
E/TC:? 0 Undefined behavior shift_out_of_bounds at core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:55 col 12 E/TC:0 0 Panic at core/kernel/ubsan.c:193 <__ubsan_handle_shift_out_of_bounds> E/TC:0 0 TEE load address @ 0x8e100000 E/TC:0 0 Call stack: E/TC:0 0 0x8e10d6c0 print_kernel_stack at optee_os/core/arch/arm/kernel/unwind_arm64.c:89 E/TC:0 0 0x8e130c7c __do_panic at optee_os/core/kernel/panic.c:73 E/TC:0 0 0x8e134c9c __ubsan_handle_shift_out_of_bounds at optee_os/core/kernel/ubsan.c:193 E/TC:0 0 0x8e1cc740 car25519 at optee_os/core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:55 (discriminator 1) E/TC:0 0 0x8e1cccbc M at optee_os/core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:135 E/TC:0 0 0x8e1cced8 add at optee_os/core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:261 E/TC:0 0 0x8e1ce594 scalarmult at optee_os/core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:294 E/TC:0 0 0x8e1ce6ac scalarbase at optee_os/core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:307 E/TC:0 0 0x8e1cf184 tweetnacl_crypto_sk_to_pk at optee_os/core/lib/libtomcrypt/src/pk/ec25519/tweetnacl.c:317 E/TC:0 0 0x8e1c063c ed25519_make_key at optee_os/core/lib/libtomcrypt/src/pk/ed25519/ed25519_make_key.c:25 (discriminator 2) E/TC:0 0 0x8e1bfef8 crypto_acipher_gen_ed25519_key at optee_os/core/lib/libtomcrypt/ed25519.c:64 E/TC:0 0 0x8e16b228 tee_svc_obj_generate_key_ed25519 at optee_os/core/tee/tee_svc_cryp.c:2312 E/TC:0 0 0x8e108110 scall_do_call at optee_os/core/arch/arm/kernel/arch_scall_a64.S:140 E/TC:0 0 0x8e107544 thread_scall_handler at optee_os/core/arch/arm/kernel/thread.c:1138 E/TC:0 0 0x8e1048b4 el0_svc at optee_os/core/arch/arm/kernel/thread_a64.S:850 ---
Signed-off-by: Abhishek Revadekar <abhishek.rvdkr@yahoo.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 29be83da | 25-Jun-2024 |
Etienne Carriere <etienne.carriere@foss.st.com> |
libtomcrypt: fix calloc() against GCC 14 -Wcalloc-transposed-args
Fix use of XCALLOC() macro against GCC 14 directive -Wcalloc-transposed-args that makes GCC to complain with an warning/error trace
libtomcrypt: fix calloc() against GCC 14 -Wcalloc-transposed-args
Fix use of XCALLOC() macro against GCC 14 directive -Wcalloc-transposed-args that makes GCC to complain with an warning/error trace message like:
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
This change was proposed and merged in mainline libtomcrypt repository.
No functional change.
Link: https://github.com/libtom/libtomcrypt/pull/647 Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Gatien Chevallier <gatien.chevallier@foss.st.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 86ee543b | 07-Mar-2024 |
Sami Tolvanen <samitolvanen@google.com> |
core: pass TEE_ATTR_RSA_OAEP_MGF_HASH to RSA-OAEP implementations
OP-TEE currently doesn't support using a different hash for MGF1 with RSA-OAEP. However, this is required for AOSP compatibility (e.
core: pass TEE_ATTR_RSA_OAEP_MGF_HASH to RSA-OAEP implementations
OP-TEE currently doesn't support using a different hash for MGF1 with RSA-OAEP. However, this is required for AOSP compatibility (e.g. in EncryptionOperationsTest.RsaOaepWithMGFDigestSuccess [1]).
Pass the MGF1 attribute to crypto implementations. Note that only libtomcrypt supports this feature at the moment, so other implementations will either fail or fall back to libtomcrypt when passed a different MGF1 hash.
Link: https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/main/security/keymint/aidl/vts/functional/KeyMintTest.cpp#5552 [1] Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| f6be0e13 | 30-May-2024 |
Jacob Kroon <jacobkr@axis.com> |
core: ltc: Fix building with mbedtls
Fix building OP-TEE with:
make PLATFORM=vexpress \ PLATFORM_FLAVOR=juno \ CFG_CRYPTOLIB_NAME=mbedtls \ CFG_CRYPTOLIB_DIR=lib/libmbedtls ... core/
core: ltc: Fix building with mbedtls
Fix building OP-TEE with:
make PLATFORM=vexpress \ PLATFORM_FLAVOR=juno \ CFG_CRYPTOLIB_NAME=mbedtls \ CFG_CRYPTOLIB_DIR=lib/libmbedtls ... core/lib/libtomcrypt/aes_accel.c: In function ‘aes_ctr_encrypt_nblocks’: core/lib/libtomcrypt/aes_accel.c:182:21: error: ‘CTR_COUNTER_LITTLE_ENDIAN’ undeclared (first use in this function) 182 | if (mode == CTR_COUNTER_LITTLE_ENDIAN) {
Signed-off-by: Jacob Kroon <jacobkr@axis.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 2a65ecaf | 06-May-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
Squashed commit upgrading to libtomcrypt-1.18.2-develop-20240412
Squash merging branch import/libtomcrypt-1.18.2-develop-20240412
165e1fe7816a ("core: ltc: update for libtomcrypt changes") ff29487
Squashed commit upgrading to libtomcrypt-1.18.2-develop-20240412
Squash merging branch import/libtomcrypt-1.18.2-develop-20240412
165e1fe7816a ("core: ltc: update for libtomcrypt changes") ff294871020d ("core: ltc: rsa_verify_hash: fix panic on hash mismatch") 43363afc3d5e ("core: ltc: add fault mitigation in crypto_acipher_rsassa_verify()") d3040d8bc691 ("libtomcrypt: Remove prng_state* NULL pointer check from ed25519_make_key()") a1e9686a20cf ("libtomcrypt: ctr_encrypt(): adjust for OP-TEE CE accelerated routines") eba1524a3989 ("libtomcrypt: define LTC_MPI at the same time as LTC_DER") e8f42d80d27f ("core: libtomcrypt: Remove prng_state* NULL pointer check from x25519_make_key()") edb8618bfe6c ("core: ltc: add SM2 curve parameters") 1713825bebd1 ("core: ltc: make key in accel_ecb_encrypt() and accel_ecb_decrypt() const") 53d2509130ce ("core: ltc: fix 'switch case misses default'") 5c7e0de468d1 ("core: ltc: add custom DH key generation function dh_make_key()") cba20f6a156e ("core: ltc: tomcrypt_custom.h: OP-TEE thread support") 7f247add8fd9 ("libtomcrypt: implement zeromem() with memzero_explicit()") 96ac368c5e68 ("LTC: add GHASH acceleration") 79bd5cb8391c ("ltc: make cipher_descriptor a pointer to descriptors") a9f0d677e922 ("ltc: make hash_descriptor a pointer to descriptors") 82feb7ac9709 ("ltc: make prng_descriptor a pointer to descriptors") ae75124e3113 ("libtomcrypt: tomcrypt_private.h: add HASH_PROCESS_NBLOCKS") a4281f43ea65 ("ECC: optimize the pool of temporary variables") b32f84118399 ("Import LibTomCrypt v1.18.2 branch "develop" (Apr 12, 2024)") 035c58eeb602 ("Remove LibTomCrypt")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
show more ...
|
| 5c4fcb77 | 12-Apr-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ltc: sub.mk: reorganize and simplify
Reorganize the LTC sub.mk by collecting configuration and files in groups by algorithm or feature.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.or
core: ltc: sub.mk: reorganize and simplify
Reorganize the LTC sub.mk by collecting configuration and files in groups by algorithm or feature.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 19a31ec4 | 12-Apr-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ltc: merge sub.mk's into a single sub.mk
Merge all sub.mk's below core/lib/libtomcrypt/src at the end of core/lib/libtomcrypt/sub.mk.
It gives an easier overview of what is compiled, but it a
core: ltc: merge sub.mk's into a single sub.mk
Merge all sub.mk's below core/lib/libtomcrypt/src at the end of core/lib/libtomcrypt/sub.mk.
It gives an easier overview of what is compiled, but it also makes it easier when syncing core/lib/libtomcrypt/src with LTC upstream since it's out of the way.
Unused sub.mk's are removed.
Removes the now unused _CFG_CORE_LTC_CIPHER, _CFG_CORE_LTC_AUTHENC and _CFG_CORE_LTC_MAC from core/crypto.mk.
The global LTC build flag -Wno-declaration-after-statement is removed and only supplied to the few source files that need it.
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| b4d33ca3 | 31-Jan-2024 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ltc: add missing string_ext.h include
Add a missing include <string_ext.h> needed to fix: core/lib/libtomcrypt/gcm.c: In function ‘crypto_aes_gcm_dec_final’: core/lib/libtomcrypt/gcm.c:198:13:
core: ltc: add missing string_ext.h include
Add a missing include <string_ext.h> needed to fix: core/lib/libtomcrypt/gcm.c: In function ‘crypto_aes_gcm_dec_final’: core/lib/libtomcrypt/gcm.c:198:13: error: implicit declaration of function ‘consttime_memcmp’ [-Werror=implicit-function-declaration] 198 | if (consttime_memcmp(dst_tag, tag, tag_len) != 0)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 32b31808 | 06-Oct-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
Squashed commit upgrading to mbedtls-3.4.0
Squash merging branch import/mbedtls-3.4.0
8225713449d3 ("libmbedtls: fix unrecognized compiler option") f03730842d7b ("core: ltc: configure internal MD5"
Squashed commit upgrading to mbedtls-3.4.0
Squash merging branch import/mbedtls-3.4.0
8225713449d3 ("libmbedtls: fix unrecognized compiler option") f03730842d7b ("core: ltc: configure internal MD5") 2b0d0c50127c ("core: ltc: configure internal SHA-1 and SHA-224") 0e48a6e17630 ("libmedtls: core: update to mbedTLS 3.4.0 API") 049882b143af ("libutee: update to mbedTLS 3.4.0 API") 982307bf6169 ("core: LTC mpi_desc.c: update to mbedTLS 3.4.0 API") 33218e9eff7b ("ta: pkcs11: update to mbedTLS 3.4.0 API") 6956420cc064 ("libmbedtls: fix cipher_wrap.c for NIST AES Key Wrap mode") ad67ef0b43fd ("libmbedtls: fix cipher_wrap.c for chacha20 and chachapoly") 7300f4d97bbf ("libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pkcs1_v15_verify()") cec89b62a86d ("libmbedtls: add fault mitigation in mbedtls_rsa_rsassa_pss_verify_ext()") e7e048796c44 ("libmbedtls: add SM2 curve") 096beff2cd31 ("libmbedtls: mbedtls_mpi_exp_mod(): optimize mempool usage") 7108668efd3f ("libmbedtls: mbedtls_mpi_exp_mod(): reduce stack usage") 0ba4eb8d0572 ("libmbedtls: mbedtls_mpi_exp_mod() initialize W") 3fd6ecf00382 ("libmbedtls: fix no CRT issue") d5ea7e9e9aa7 ("libmbedtls: add interfaces in mbedtls for context memory operation") 2b0fb3f1fa3d ("libmedtls: mpi_miller_rabin: increase count limit") 2c3301ab99bb ("libmbedtls: add mbedtls_mpi_init_mempool()") 9a111f0da04b ("libmbedtls: make mbedtls_mpi_mont*() available") 804fe3a374f5 ("mbedtls: configure mbedtls to reach for config") b28a41531427 ("mbedtls: remove default include/mbedtls/config.h") dfafe507bbef ("Import mbedtls-3.4.0")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Tested-by: Jerome Forissier <jerome.forissier@linaro.org> (vexpress-qemu_armv8a)
show more ...
|
| 8d4ddb4c | 28-Jul-2023 |
Vitor Sato Eschholz <vsatoes@baylibre.com> |
core: ltc: rsa_verify_hash: fix panic on hash mismatch
When running a test with CFG_FAULT_MITIGATION=y and with a corrupted message, hash verification fails and panic TEE core:
F/TC:? 0 trace_sysca
core: ltc: rsa_verify_hash: fix panic on hash mismatch
When running a test with CFG_FAULT_MITIGATION=y and with a corrupted message, hash verification fails and panic TEE core:
F/TC:? 0 trace_syscall:149 syscall #40 (syscall_asymm_verify) E/TC:2 0 Panic at lib/libutils/ext/fault_mitigation.c:87 <___ftmn_callee_done_check> E/TC:2 0 TEE load address @ 0x43200000 E/TC:2 0 Call stack: E/TC:2 0 0x4320a9f0 print_kernel_stack at optee-os/core/arch/arm/kernel/unwind_arm64.c:91 E/TC:2 0 0x432203fc __do_panic at optee-os/core/kernel/panic.c:26 (discriminator 32) E/TC:2 0 0x4327d324 ___ftmn_callee_done_check at optee-os/lib/libutils/ext/fault_mitigation.c:87 E/TC:2 0 0x43263aac __ftmn_callee_done_check at optee-os/lib/libutils/ext/include/fault_mitigation.h:349 E/TC:2 0 0x43258408 sw_crypto_acipher_rsassa_verify at optee-os/core/lib/libtomcrypt/rsa.c:669 E/TC:2 0 0x43247ecc syscall_asymm_verify at optee-os/core/tee/tee_svc_cryp.c:4420 E/TC:2 0 0x43206d18 scall_do_call at optee-os/core/arch/arm/kernel/arch_scall_a64.S:140 E/TC:2 0 0x43206798 thread_scall_handler at optee-os/core/arch/arm/kernel/thread.c:1115 E/TC:2 0 0x432043e8 el0_svc at optee-os/core/arch/arm/kernel/thread_a64.S:850
When CFG_FAULT_MITIGATION flag is enabled, ftmn_set_check_res_memcmp() is used on the verification of RSA hash. ftmn.check.res is set with the return value of the hash comparison. Since memcmp() is used, this can be 0, when hash matches, or any non-zero number when hash does not match.
However, the value stored on ftmn.check.res is later compared with the result of the signature comparison (!*stat), which can assume only two values, 1==valid or 0==invalid.
With that, when ftmn_set_check_res_memcmp() returns any non-zero number, force ftmn.check.res to 1 so that it matches the check with later FTMN_CALLEE_DONE_CHECK().
Signed-off-by: Felix Freimann <felix.freimann@mediatek.com> Signed-off-by: Vitor Sato Eschholz <vsatoes@baylibre.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| 46e25a17 | 14-Jul-2023 |
loubaihui <loubaihui1@huawei.com> |
crypto: rename struct x25519_keypair
Since X25519 and X448 have the same key pair structure, so we rename struct x25519_keypair as struct montgomery_keypair.
Signed-off-by: loubaihui <loubaihui1@hu
crypto: rename struct x25519_keypair
Since X25519 and X448 have the same key pair structure, so we rename struct x25519_keypair as struct montgomery_keypair.
Signed-off-by: loubaihui <loubaihui1@huawei.com> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| e2ec831c | 03-Jul-2023 |
Jihwan Park <jihwp@amazon.com> |
core: crypto_bignum_free(): add indirection and set pointer to NULL
To prevent human mistake, crypto_bignum_free() sets the location of the bignum pointer to NULL after freeing it.
Signed-off-by: J
core: crypto_bignum_free(): add indirection and set pointer to NULL
To prevent human mistake, crypto_bignum_free() sets the location of the bignum pointer to NULL after freeing it.
Signed-off-by: Jihwan Park <jihwp@amazon.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
show more ...
|
| 44220a36 | 15-Mar-2023 |
Safae Ouajih <souajih@baylibre.com> |
libtomcrypt: fix pkcs_1_v1_5_decode() when empty message
In case of EME-PKCS1-v1_5 decoding, the encoded message format is as follow : EM = 0x00 || 0x02 || PS || 0x00 || M. When using an empty messa
libtomcrypt: fix pkcs_1_v1_5_decode() when empty message
In case of EME-PKCS1-v1_5 decoding, the encoded message format is as follow : EM = 0x00 || 0x02 || PS || 0x00 || M. When using an empty message, the 0x00 octet that separates the padding string and message is located at the end. Thus, update the condition to pass the check in case of empty message.
This fixes the following AOSP cts test: Module: CtsKeystoreTestCases Test: testEmptyPlaintextEncryptsAndDecrypts Link: https://android.googlesource.com/platform/cts/+/refs/tags/android-cts-12.0_r6/tests/tests/keystore/src/android/keystore/cts/CipherTest.java
Signed-off-by: Safae Ouajih <souajih@baylibre.com> [jf: upstream commit caf350028833] Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| 1478437e | 10-Mar-2023 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ltc: use SHA-3 crypto accelerated function
Uses the recently provided accelerated SHA-3 function in LTC
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <j
core: ltc: use SHA-3 crypto accelerated function
Uses the recently provided accelerated SHA-3 function in LTC
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
show more ...
|
| f5c3d85a | 01-Dec-2020 |
Julien Masson <jmasson@baylibre.com> |
core: crypto: add support MD5 hashes in RSA sign/verify/cipher
Introduce support of using MD5 hashes in RSA sign/verify/cipher operations, which is required by AOSP Keymaster.
This is verified in
core: crypto: add support MD5 hashes in RSA sign/verify/cipher
Introduce support of using MD5 hashes in RSA sign/verify/cipher operations, which is required by AOSP Keymaster.
This is verified in VerificationOperationsTest.RsaSuccess VTS Test [1], which checks usage of such digests: NONE, MD5, SHA1, SHA_2_224, SHA_2_256, SHA_2_384, SHA_2_512.
This patch has been inspired by commit[2]:
Link: [1] https://android.googlesource.com/platform/hardware/interfaces/+/master/keymaster/3.0/vts/functional/keymaster_hidl_hal_test.cpp Link: [2] https://github.com/OP-TEE/optee_os/commit/199d0b7310d1705661a106358f1f0b46e4c5c587 ("core: crypto: add support MD5 hashes in RSA sign/verify") Signed-off-by: Julien Masson <jmasson@baylibre.com> Signed-off-by: Safae Ouajih <souajih@baylibre.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| c4cab13e | 20-Feb-2023 |
Clement Faure <clement.faure@nxp.com> |
core: crypto: fix memory leak in Ed25519 support
The software implementation of ED25519 algorithm has a memory leak in the key and key pair allocation. Upon every public key allocation, a key pair i
core: crypto: fix memory leak in Ed25519 support
The software implementation of ED25519 algorithm has a memory leak in the key and key pair allocation. Upon every public key allocation, a key pair is allocated (public and private components). When freeing the public key, only the public component is freed. To reproduce the issue:
$ while xtest 4016; do :; done
Until the following error:
* regression_4016 Test TEE Internal API ED25519 sign/verify E/LD: copy_section_headers:1124 sys_copy_from_ta_bin E/TC:? 0 ldelf_init_with_ldelf:131 ldelf failed with res: 0xffff000c /usr/src/debug/optee-test/master.imx-r0/host/xtest/regression_4000.c:6062: xtest_teec_open_session(&session, &crypt_user_ta_uuid, ((void *)0), &ret_orig) has an unexpected value: 0xffff000c = TEEC_ERROR_OUT_OF_MEMORY, expected 0x0 = TEEC_SUCCESS regression_4016 FAILED
To fix the memory leak, a separate public key allocation function must be defined along a ED25519 public key structure.
Fixes: 0aaad418ac8b ("core: crypto: add Ed25519 support") Signed-off-by: Clement Faure <clement.faure@nxp.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 7dfcefda | 02-Dec-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: LTC: conditionally enable SHA-3 implementation
Enables SHA-3 implementation in libtomcrypt and add OP-TEE wrappers.
Adds LTC fallback for mbedtls configurations since mbedtls doesn't support
core: LTC: conditionally enable SHA-3 implementation
Enables SHA-3 implementation in libtomcrypt and add OP-TEE wrappers.
Adds LTC fallback for mbedtls configurations since mbedtls doesn't support SHA-3 yet.
Implementation of the crypto_hmac_*_alloc_ctx() functions is updated to only add a full implementation if the corresponding hash function also is configured.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| fe2fd3ff | 24-Nov-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
GP131: Add TEE_ALG_ECDH_DERIVE_SHARED_SECRET and TEE_ALG_ECDSA_SHA*
Adds the defines - TEE_ALG_ECDH_DERIVE_SHARED_SECRET - TEE_ALG_ECDSA_SHA1 - TEE_ALG_ECDSA_SHA224 - TEE_ALG_ECDSA_SHA256 - TEE_ALG_
GP131: Add TEE_ALG_ECDH_DERIVE_SHARED_SECRET and TEE_ALG_ECDSA_SHA*
Adds the defines - TEE_ALG_ECDH_DERIVE_SHARED_SECRET - TEE_ALG_ECDSA_SHA1 - TEE_ALG_ECDSA_SHA224 - TEE_ALG_ECDSA_SHA256 - TEE_ALG_ECDSA_SHA386 - TEE_ALG_ECDSA_SHA512 from TEE Internal Core API version 1.3.1 to replace the previous now deprecated defines: - TEE_ALG_ECDSA_P192 - TEE_ALG_ECDSA_P224 - TEE_ALG_ECDSA_P256 - TEE_ALG_ECDSA_P384 - TEE_ALG_ECDSA_P521 - TEE_ALG_ECDH_P192 - TEE_ALG_ECDH_P224 - TEE_ALG_ECDH_P256 - TEE_ALG_ECDH_P384 - TEE_ALG_ECDH_P521
The new defines have new values and the values from the old defines are not reused.
The syscall ABI maintains compatibility by handling both the old and new values in parallel from now on.
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| b836852d | 08-Dec-2022 |
Etienne Carriere <etienne.carriere@linaro.org> |
core: use IS_ENABLED2()
Replaces use of IS_ENABLED() with IS_ENABLED2() where applicable.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@
core: use IS_ENABLED2()
Replaces use of IS_ENABLED() with IS_ENABLED2() where applicable.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
show more ...
|
| 65d11b31 | 23-Dec-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: ltc: use SHA-512 crypto accelerated function
Uses the recently provided accelerated SHA-512 function in LTC.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wikla
core: ltc: use SHA-512 crypto accelerated function
Uses the recently provided accelerated SHA-512 function in LTC.
Acked-by: Jerome Forissier <jerome.forissier@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|
| 2373e1b9 | 01-Sep-2022 |
Jens Wiklander <jens.wiklander@linaro.org> |
core: add overflow checks in crypto_aes_ccm_init()
aad_len and payload_len are of the type size_t which has a greater range than int which is used for the corresponding arguments when passed to ccm_
core: add overflow checks in crypto_aes_ccm_init()
aad_len and payload_len are of the type size_t which has a greater range than int which is used for the corresponding arguments when passed to ccm_init(). So to guard against wrapped or truncated values check that the variables can be in a int first before calling ccm_init().
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Acked-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
show more ...
|