Skip to content

Commit

Permalink
nrf_security: drivers: cracen: Adding extra wait to ed25519
Browse files Browse the repository at this point in the history
Test to see if it fixes bootloader issues

Signed-off-by: Dag Erik Gjørvad <[email protected]>
  • Loading branch information
degjorva committed Jan 21, 2025
1 parent 66dcd8a commit 06eb105
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <cracen/ec_helpers.h>
#include <sxsymcrypt/hash.h>
#include <cracen/mem_helpers.h>
#include "crypmasterregs.h"
#include "hw.h"

/* This is the ASCII string with the
* PHflag 1 and context size 0 appended as defined in:
Expand Down Expand Up @@ -249,18 +251,21 @@ int ed25519_verify_internal(const uint8_t *pubkey, const char *message,
struct sxhash hashopctx;
int status;

status = sx_hash_create(&hashopctx, &sxhashalg_sha2_512, sizeof(hashopctx));

status = sx_hash_create(&hashopctx, &sxhashalg_sha2_512, sizeof(hashopctx));
if (status != 0) {
return status;
}
if (prehash) {
status = sx_hash_feed(&hashopctx, dom2, sizeof(dom2));

if (status != 0) {
return status;
}
}
status = sx_hash_feed(&hashopctx, signature, SX_ED25519_SZ);
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 267 in subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_STATEMENTS

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c:267 trailing statements should be on next line


if (status != 0) {
return status;
Expand All @@ -270,16 +275,23 @@ int ed25519_verify_internal(const uint8_t *pubkey, const char *message,
if (status != 0) {
return status;
}
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 278 in subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_STATEMENTS

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c:278 trailing statements should be on next line

Check failure on line 278 in subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

WHILE_AFTER_BRACE

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c:278 while should follow close brace '}'
status = sx_hash_feed(&hashopctx, message, message_length);
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 280 in subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_STATEMENTS

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c:280 trailing statements should be on next line

if (status != 0) {
return status;
}
status = sx_hash_digest(&hashopctx, workmem);
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 286 in subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

TRAILING_STATEMENTS

subsys/nrf_security/src/drivers/cracen/cracenpsa/src/ed25519.c:286 trailing statements should be on next line


if (status != 0) {
return status;
}
status = sx_hash_wait(&hashopctx);


if (status != 0) {
return status;
}
Expand Down
8 changes: 8 additions & 0 deletions subsys/nrf_security/src/drivers/cracen/cracenpsa/src/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ static int cracen_signature_prepare_ec_pubkey(struct sitask *t, struct si_sig_pu
}
status = ed25519_create_pubkey(key_buffer, pubkey_buffer);
return status;
}
if (alg == PSA_ALG_ED25519PH) {
if (PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(psa_get_key_type(attributes))) {
memcpy(pubkey_buffer, key_buffer, key_buffer_size);
return SX_OK;
}
status = ed25519_create_pubkey(key_buffer, pubkey_buffer);
return status;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ list(APPEND cracen_driver_sources

list(APPEND cracen_driver_include_dirs
${CMAKE_CURRENT_LIST_DIR}/include
${CMAKE_CURRENT_LIST_DIR}/src
)

0 comments on commit 06eb105

Please sign in to comment.