Skip to content

Commit

Permalink
drivers: caam: introduce AE_CCM and AE_GCM compilation flags
Browse files Browse the repository at this point in the history
imx6dl-sabresd, imx6q-sabresd, imx6sx-sdb does not support AES GCM

Signed-off-by: Olivier Masse <olivier.masse@nxp.com>
Signed-off-by: Sahil Malhotra <sahil.malhotra@nxp.com>
  • Loading branch information
omasse-linaro authored and sahilnxp committed Nov 12, 2024
1 parent 111d5ee commit d6dbdbd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
8 changes: 6 additions & 2 deletions core/drivers/crypto/caam/ae/caam_ae.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Constants definition of the AES algorithm
*/
static const struct cipheralg aes_alg[] = {
#if defined(CFG_NXP_CAAM_AE_CCM_DRV)
[TEE_CHAIN_MODE_CCM] = {
.type = OP_ALGO(AES) | ALGO_AAI(AES_CCM),
.size_block = TEE_AES_BLOCK_SIZE,
Expand All @@ -35,6 +36,8 @@ static const struct cipheralg aes_alg[] = {
.initialize = caam_ae_initialize_ccm,
.final = caam_ae_final_ccm,
},
#endif
#if defined(CFG_NXP_CAAM_AE_GCM_DRV)
[TEE_CHAIN_MODE_GCM] = {
.type = OP_ALGO(AES) | ALGO_AAI(AES_GCM),
.size_block = TEE_AES_BLOCK_SIZE,
Expand All @@ -44,6 +47,7 @@ static const struct cipheralg aes_alg[] = {
.initialize = caam_ae_initialize_gcm,
.final = caam_ae_final_gcm,
},
#endif
};

/*
Expand Down Expand Up @@ -90,8 +94,8 @@ static TEE_Result caam_ae_allocate(void **ctx, uint32_t algo)

alg = get_cipheralgo(algo);
if (!alg) {
AE_TRACE("Algorithm not supported");
return TEE_ERROR_NOT_SUPPORTED;
AE_TRACE("Algorithm not implemented");
return TEE_ERROR_NOT_IMPLEMENTED;
}

caam_ctx = caam_calloc(sizeof(*caam_ctx));
Expand Down
4 changes: 2 additions & 2 deletions core/drivers/crypto/caam/ae/sub.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
incdirs-y += ../include

srcs-y += caam_ae.c
srcs-y += caam_ae_gcm.c
srcs-y += caam_ae_ccm.c
srcs-$(CFG_NXP_CAAM_AE_GCM_DRV) += caam_ae_gcm.c
srcs-$(CFG_NXP_CAAM_AE_CCM_DRV) += caam_ae_ccm.c
24 changes: 13 additions & 11 deletions core/drivers/crypto/caam/crypto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CFG_DBG_CAAM_BUF ?= 0x0
caam-drivers = RNG BLOB

# CAAM default drivers connected to the HW crypto API
caam-crypto-drivers = CIPHER HASH HMAC CMAC AE
caam-crypto-drivers = CIPHER HASH HMAC CMAC AE_CCM

ifneq (,$(filter $(PLATFORM_FLAVOR),ls1012ardb ls1043ardb ls1046ardb))
$(call force, CFG_CAAM_BIG_ENDIAN,y)
Expand All @@ -40,7 +40,7 @@ $(call force, CFG_CAAM_SGT_ALIGN,4)
$(call force, CFG_CAAM_64BIT,y)
$(call force, CFG_NXP_CAAM_SGT_V1,y)
$(call force, CFG_CAAM_ITR,n)
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),ls1088ardb ls2088ardb ls1028ardb))
$(call force, CFG_CAAM_LITTLE_ENDIAN,y)
$(call force, CFG_JR_BLOCK_SIZE,0x10000)
Expand All @@ -50,7 +50,7 @@ $(call force, CFG_NXP_CAAM_SGT_V2,y)
$(call force, CFG_CAAM_SGT_ALIGN,4)
$(call force, CFG_CAAM_64BIT,y)
$(call force, CFG_CAAM_ITR,n)
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),lx2160aqds lx2160ardb))
$(call force, CFG_CAAM_LITTLE_ENDIAN,y)
$(call force, CFG_JR_BLOCK_SIZE,0x10000)
Expand All @@ -61,22 +61,22 @@ $(call force, CFG_NXP_CAAM_SGT_V2,y)
$(call force, CFG_CAAM_SGT_ALIGN,4)
$(call force, CFG_CAAM_64BIT,y)
$(call force, CFG_CAAM_ITR,n)
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx8qm-flavorlist) $(mx8qx-flavorlist)))
$(call force, CFG_CAAM_SIZE_ALIGN,4)
$(call force, CFG_JR_BLOCK_SIZE,0x10000)
$(call force, CFG_JR_INDEX,3)
$(call force, CFG_JR_INT,486)
$(call force, CFG_NXP_CAAM_SGT_V1,y)
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx8dxl-flavorlist)))
$(call force, CFG_CAAM_SIZE_ALIGN,4)
$(call force, CFG_JR_BLOCK_SIZE,0x10000)
$(call force, CFG_JR_INDEX,3)
$(call force, CFG_JR_INT,356)
$(call force, CFG_NXP_CAAM_SGT_V1,y)
$(call force, CFG_CAAM_JR_DISABLE_NODE,n)
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx8mm-flavorlist) $(mx8mn-flavorlist) \
$(mx8mp-flavorlist) $(mx8mq-flavorlist)))
$(call force, CFG_JR_BLOCK_SIZE,0x1000)
Expand All @@ -90,30 +90,32 @@ $(call force, CFG_JR_HAB_INDEX,0)
# this issue, controlled by CFG_NXP_CAAM_C2_CTX_REG_WA flag.
$(call force, CFG_NXP_CAAM_C2_CTX_REG_WA,y)
caam-drivers += MP DEK
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx8ulp-flavorlist)))
$(call force, CFG_JR_BLOCK_SIZE,0x1000)
$(call force, CFG_JR_INDEX,2)
$(call force, CFG_JR_INT,114)
$(call force, CFG_NXP_CAAM_SGT_V1,y)
$(call force, CFG_CAAM_ITR,n)
caam-crypto-drivers += AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx7ulp-flavorlist)))
$(call force, CFG_JR_BLOCK_SIZE,0x1000)
$(call force, CFG_JR_INDEX,0)
$(call force, CFG_JR_INT,137)
$(call force, CFG_NXP_CAAM_SGT_V1,y)
$(call force, CFG_CAAM_ITR,n)
caam-crypto-drivers += AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx6ul-flavorlist) $(mx7d-flavorlist) \
$(mx7s-flavorlist)))
$(call force, CFG_JR_BLOCK_SIZE,0x1000)
$(call force, CFG_JR_INDEX,0)
$(call force, CFG_JR_INT,137)
$(call force, CFG_NXP_CAAM_SGT_V1,y)
caam-drivers += MP
caam-crypto-drivers += RSA DSA ECC DH MATH
caam-crypto-drivers += RSA DSA ECC DH MATH AE_GCM
else ifneq (,$(filter $(PLATFORM_FLAVOR),$(mx6q-flavorlist) $(mx6qp-flavorlist) \
$(mx6sx-flavorlist) $(mx6d-flavorlist) $(mx6dl-flavorlist) \
$(mx6s-flavorlist) $(mx8ulp-flavorlist)))
$(mx6s-flavorlist) $(mx8ulp-flavorlist)))
$(call force, CFG_JR_BLOCK_SIZE,0x1000)
$(call force, CFG_JR_INDEX,0)
$(call force, CFG_JR_INT,137)
Expand Down Expand Up @@ -182,8 +184,8 @@ $(call force, CFG_CRYPTO_DRV_CIPHER,y,Mandated by CFG_NXP_CAAM_CIPHER_DRV)
endif

# Enable AE crypto driver
ifeq ($(CFG_NXP_CAAM_AE_DRV), y)
$(call force, CFG_CRYPTO_DRV_AUTHENC,y,Mandated by CFG_NXP_CAAM_AE_DRV)
ifeq ($(call cfg-one-enabled,CFG_NXP_CAAM_AE_CCM_DRV CFG_NXP_CAAM_AE_GCM_DRV),y)
$(call force, CFG_CRYPTO_DRV_AUTHENC,y,Mandated by CFG_NXP_CAAM_AE_CCM/GCM_DRV)
endif

# Enable HASH crypto driver
Expand Down
2 changes: 1 addition & 1 deletion core/drivers/crypto/caam/sub.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ srcs-$(CFG_NXP_CAAM_SM_DRV) += caam_sm.c
srcs-y += caam_key.c
subdirs-$(call cfg-one-enabled, CFG_NXP_CAAM_HASH_DRV CFG_NXP_CAAM_HMAC_DRV) += hash
subdirs-$(call cfg-one-enabled, CFG_NXP_CAAM_CIPHER_DRV CFG_NXP_CAAM_CMAC_DRV) += cipher
subdirs-$(CFG_NXP_CAAM_AE_DRV) += ae
subdirs-$(call cfg-one-enabled, CFG_NXP_CAAM_AE_CCM_DRV CFG_NXP_CAAM_AE_GCM_DRV) += ae
subdirs-y += acipher
subdirs-y += blob
subdirs-$(CFG_NXP_CAAM_MP_DRV) += mp

0 comments on commit d6dbdbd

Please sign in to comment.