Skip to content

Commit de9256c

Browse files
tejlmandcarlescufi
authored andcommitted
cracen: safeguard static cracen functions.
Safeguard `cracen_signature_set_hashalgo_from_digestsz()` and `cracen_signature_set_hashalgo()` inside `PSA_MAX_RSA_KEY_BITS > 0`. Safeguard `can_sign()` inside > CONFIG_PSA_WANT_ALG_PURE_EDDSA || `CONFIG_PSA_WANT_ALG_ED25519PH || > CONFIG_PSA_WANT_ALG_ECDSA || CONFIG_PSA_WANT_ALG_HMAC All calls to `cracen_signature_set_hashalgo()` and `cracen_signature_set_hashalgo_from_digestsz()` are safeguarded in `PSA_MAX_RSA_KEY_BITS > 0` resulting in unused function warning because those static functions will never be used when the condition is not met. Similar for calls to `can_sign()`. Fixes: > ...subsys/nrf_security/src/drivers/cracen/cracenpsa/src/sign.c:41:12: > warning: unused function > 'cracen_signature_set_hashalgo' [-Wunused-function] > 41 | static int cracen_signature_set_hashalgo(... > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 warning generated. > ...subsys/nrf_security/src/drivers/cracen/cracenpsa/src/sign.c:46:12: > warning: unused function > 'cracen_signature_set_hashalgo_from_digestsz' [-Wunused-function] > 46 | static int cracen_signature_set_hashalgo_from_digestsz(... > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 warning generated. > ...subsys/nrf_security/src/drivers/cracen/cracenpsa/src/kmu.c:297:13: > warning: unused function 'can_sign' [-Wunused-function] > 297 | static bool can_sign(const psa_key_attributes_t *key_attr) > | ^~~~~~~~ > 1 warning generated. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 12fadf8 commit de9256c

File tree

2 files changed

+5
-0
lines changed
  • subsys/nrf_security/src/drivers/cracen/cracenpsa/src

2 files changed

+5
-0
lines changed

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/kmu.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,14 @@ static psa_status_t get_kmu_slot_id_and_metadata(mbedtls_svc_key_id_t key_id,
294294
return read_primary_slot_metadata(*slot_id, metadata);
295295
}
296296

297+
#if defined(CONFIG_PSA_WANT_ALG_PURE_EDDSA) || defined(CONFIG_PSA_WANT_ALG_ED25519PH) || \
298+
defined CONFIG_PSA_WANT_ALG_ECDSA || defined(CONFIG_PSA_WANT_ALG_HMAC)
297299
static bool can_sign(const psa_key_attributes_t *key_attr)
298300
{
299301
return (psa_get_key_usage_flags(key_attr) & PSA_KEY_USAGE_SIGN_MESSAGE) ||
300302
(psa_get_key_usage_flags(key_attr) & PSA_KEY_USAGE_SIGN_HASH);
301303
}
304+
#endif /* defined(CONFIG_PSA_WANT_ALG_PURE_EDDSA) || define(CONFIG_PSA_WANT_ALG_ED25519PH) */
302305

303306
/**
304307
* @brief Check provisioning state, and delete slots that were not completely provisioned.

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/sign.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#define SI_PSA_IS_KEY_FLAG(flag, attr) ((flag) == (psa_get_key_usage_flags((attr)) & (flag)))
3939
#define SI_PSA_IS_KEY_TYPE(flag, attr) ((flag) == (psa_get_key_type((attr)) & (flag)))
4040

41+
#if PSA_MAX_RSA_KEY_BITS > 0
4142
static int cracen_signature_set_hashalgo(const struct sxhashalg **hashalg, psa_algorithm_t alg)
4243
{
4344
return hash_get_algo(PSA_ALG_SIGN_GET_HASH(alg), hashalg);
@@ -81,6 +82,7 @@ static int cracen_signature_set_hashalgo_from_digestsz(const struct sxhashalg **
8182

8283
return SX_OK;
8384
}
85+
#endif /* PSA_MAX_RSA_KEY_BITS > 0 */
8486

8587
static int cracen_signature_prepare_ec_prvkey(struct si_sig_privkey *privkey, char *key_buffer,
8688
size_t key_buffer_size,

0 commit comments

Comments
 (0)