From c3e4ffdd114a2c3d5f900b42e5d1b4d2b3d4e804 Mon Sep 17 00:00:00 2001 From: Jorge Ramirez-Ortiz Date: Thu, 18 Jan 2024 19:40:10 +0100 Subject: [PATCH] drivers: caam: sm2 operation fallback Fallback to software operations for SM2. Signed-off-by: Jorge Ramirez-Ortiz --- core/drivers/crypto/caam/acipher/caam_ecc.c | 22 +++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/core/drivers/crypto/caam/acipher/caam_ecc.c b/core/drivers/crypto/caam/acipher/caam_ecc.c index b9c2cde8817..6327745da67 100644 --- a/core/drivers/crypto/caam/acipher/caam_ecc.c +++ b/core/drivers/crypto/caam/acipher/caam_ecc.c @@ -143,11 +143,20 @@ static enum caam_ecc_curve get_caam_curve(uint32_t tee_curve) * @size_bits Key size in bits */ static TEE_Result do_allocate_keypair(struct ecc_keypair *key, - uint32_t type __unused, + uint32_t type, size_t size_bits) { ECC_TRACE("Allocate Keypair of %zu bits", size_bits); + switch (type) { + case TEE_TYPE_SM2_PKE_KEYPAIR: + case TEE_TYPE_SM2_DSA_KEYPAIR: + /* Software fallback */ + return TEE_ERROR_NOT_IMPLEMENTED; + default: + break; + } + /* Initialize the key fields to NULL */ memset(key, 0, sizeof(*key)); @@ -184,11 +193,20 @@ static TEE_Result do_allocate_keypair(struct ecc_keypair *key, * @size_bits Key size in bits */ static TEE_Result do_allocate_publickey(struct ecc_public_key *key, - uint32_t type __unused, + uint32_t type, size_t size_bits) { ECC_TRACE("Allocate Public Key of %zu bits", size_bits); + switch (type) { + case TEE_TYPE_SM2_PKE_PUBLIC_KEY: + case TEE_TYPE_SM2_DSA_PUBLIC_KEY: + /* Software fallback */ + return TEE_ERROR_NOT_IMPLEMENTED; + default: + break; + } + /* Initialize the key fields to NULL */ memset(key, 0, sizeof(*key));