Skip to content

Commit

Permalink
drivers: caam: sm2 operation fallback
Browse files Browse the repository at this point in the history
Fallback to software operations for SM2.

Reverts the temporary solution implemented in commit '3489781e9072
("drivers: caam: disable CFG_CRYPTO_SM2_* when ECC CAAM driver is
enabled")'.

Signed-off-by: Jorge Ramirez-Ortiz <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
Acked-by: Clement Faure <[email protected]>
  • Loading branch information
ldts committed Jan 24, 2024
1 parent 29b4cb6 commit 51afcd9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
22 changes: 20 additions & 2 deletions core/drivers/crypto/caam/acipher/caam_ecc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down
7 changes: 0 additions & 7 deletions core/drivers/crypto/caam/crypto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,5 @@ ifeq ($(call cfg-one-enabled,CFG_CRYPTO_DRV_RSA CFG_CRYPTO_DRV_ECC \
$(call force, CFG_CRYPTO_DRV_ACIPHER,y,Mandated by CFG_CRYPTO_DRV_{RSA|ECC|DSA|DH})
endif

# Disable SM2 as it is not supported by the CAAM driver
ifeq ($(CFG_NXP_CAAM_ECC_DRV),y)
$(call force,CFG_CRYPTO_SM2_PKE,n)
$(call force,CFG_CRYPTO_SM2_KEP,n)
$(call force,CFG_CRYPTO_SM2_DSA,n)
endif

endif # CFG_CRYPTO_DRIVER
endif # CFG_NXP_CAAM

0 comments on commit 51afcd9

Please sign in to comment.