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 22, 2025
1 parent 66dcd8a commit e29d255
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
29 changes: 25 additions & 4 deletions 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,37 +251,56 @@ 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);

status = sx_hash_feed(&hashopctx, signature, SX_ED25519_SZ/2);
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;
}
status = sx_hash_feed(&hashopctx, pubkey, SX_ED25519_SZ);

status = sx_hash_feed(&hashopctx, signature+16, SX_ED25519_SZ/2);
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 273 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:273 trailing statements should be on next line

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

Check failure on line 279 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:279 trailing statements should be on next line
if (status != 0) {
return status;
}
status = sx_hash_feed(&hashopctx, pubkey+16, SX_ED25519_SZ/2);
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 284 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:284 trailing statements should be on next line
if (status != 0) {
return status;
}
status = sx_hash_feed(&hashopctx, message, message_length);
while ((sx_rdreg(REG_STATUS) & REG_STATUS_BUSY_MASK) != 0);

Check failure on line 289 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:289 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 295 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:295 trailing statements should be on next line


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


if (status != 0) {
return status;
}
Expand Down
4 changes: 2 additions & 2 deletions subsys/nrf_security/src/drivers/cracen/cracenpsa/src/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ static int cracen_signature_prepare_ec_pubkey(struct sitask *t, struct si_sig_pu
status = SX_ERR_INCOMPATIBLE_HW;

if (IS_ENABLED(PSA_NEED_CRACEN_PURE_EDDSA_TWISTED_EDWARDS)) {
if (alg == PSA_ALG_PURE_EDDSA) {
if (alg == PSA_ALG_PURE_EDDSA || 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;
}
}
}

if (IS_ENABLED(PSA_NEED_CRACEN_ECDSA_SECP_R1) ||
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 e29d255

Please sign in to comment.