Skip to content

Commit

Permalink
drivers: caam: cache align Key blob modifier
Browse files Browse the repository at this point in the history
An array was used as Key blob modifier, changed it cache aligned
dynamic memory.

Signed-off-by: Sahil Malhotra <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
  • Loading branch information
sahilnxp authored and jforissier committed Nov 15, 2024
1 parent 132151f commit 116d03a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/drivers/crypto/caam/caam_key.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-2-Clause
/*
* Copyright 2023 NXP
* Copyright 2023-2024 NXP
*/
#include <assert.h>
#include <caam_desc_helper.h>
Expand Down Expand Up @@ -57,8 +57,9 @@
* makes it non-volatile and can be re-created when the chip powers up again.
*/
#define KEY_BLOB_MODIFIER_SIZE 16
static const uint8_t key_blob_modifier[KEY_BLOB_MODIFIER_SIZE] =
"NXP_OPTEE_BLOB";
#define KEY_BLOB_MODIFIER "NXP_KEY_MODIFIER"
static_assert(sizeof(KEY_BLOB_MODIFIER) >= KEY_BLOB_MODIFIER_SIZE);
static uint8_t *key_blob_modifier;

/*
* Serialized CAAM key structure format.
Expand Down Expand Up @@ -379,6 +380,8 @@ enum caam_status caam_key_operation_blob(const struct caamkey *in_key,

KEY_DUMPDESC(desc);

cache_operation(TEE_CACHECLEAN, key_blob_modifier,
KEY_BLOB_MODIFIER_SIZE);
caam_key_cache_op(TEE_CACHECLEAN, in_key);
caam_key_cache_op(TEE_CACHECLEAN, out_key);

Expand Down Expand Up @@ -743,6 +746,12 @@ enum caam_status caam_key_init(void)

assert(alloc_size <= CFG_CORE_BIGNUM_MAX_BITS);

key_blob_modifier = caam_calloc_align(KEY_BLOB_MODIFIER_SIZE);
if (!key_blob_modifier)
return CAAM_FAILURE;

memcpy(key_blob_modifier, KEY_BLOB_MODIFIER, KEY_BLOB_MODIFIER_SIZE);

KEY_TRACE("Max serialized key size %zu", alloc_size);

KEY_TRACE("Default CAAM key generation type %s",
Expand Down

0 comments on commit 116d03a

Please sign in to comment.