summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorEtienne Carriere <etienne.carriere@linaro.org>2020-11-05 16:36:58 +0100
committerJérôme Forissier <jerome@forissier.org>2020-11-19 14:12:13 +0100
commit301ade763bdcc8dac5a819f5fc6e9d7d5ac6989b (patch)
tree63415b4fcb7c917a9913963c1bc4bd35ea266195 /core
parenta8fb1651777edc48702e166c7a8c5827b92c4a8e (diff)
core: ltc: fix return value in crypto API SM2 PKA decrypt
Fix calloc() failure case in core crypto API function for SM2 PKE decryption. Prior this change the function failed but return 0/OK. This change sets the return value to TEE_ERROR_OUT_OF_MEMORY before reaching the function exit sequence. Fixes: f9a78287dd12 (core: ltc: add support for SM2 PKE) Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome@forissier.org>
Diffstat (limited to 'core')
-rw-r--r--core/lib/libtomcrypt/sm2-pke.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/lib/libtomcrypt/sm2-pke.c b/core/lib/libtomcrypt/sm2-pke.c
index 9d1d8958..ae189cc4 100644
--- a/core/lib/libtomcrypt/sm2-pke.c
+++ b/core/lib/libtomcrypt/sm2-pke.c
@@ -246,8 +246,10 @@ TEE_Result sm2_ltc_pke_decrypt(struct ecc_keypair *key, const uint8_t *src,
*dst_len = out_len;
if (out_len < C2_len) {
eom = calloc(1, C2_len - out_len);
- if (!eom)
+ if (!eom) {
+ res = TEE_ERROR_OUT_OF_MEMORY;
goto out;
+ }
for (i = out_len; i < C2_len; i++)
eom[i - out_len] = src[C1_len + i] ^ t[i];
}