Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ target_include_directories(eboot_hal PUBLIC ${EBLDR_INCLUDE_DIR})
# ---- Core boot logic ----
add_library(eboot_core STATIC
core/bootctl.c
core/boot_log.c
core/image_verify.c
core/slot_manager.c
core/boot_policy.c
Expand All @@ -107,7 +106,9 @@ add_library(eboot_core STATIC
core/bmc_handoff.c
core/os_adapter.c
core/ed25519_verify.c
core/sha512.c
core/keystore.c
core/rollback.c
core/debug_lock.c
core/fw_decrypt.c
core/image_tlv.c
Expand Down
26 changes: 14 additions & 12 deletions core/ed25519_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "eos_crypto_boot.h"
#include "eos_types.h"
#include <string.h>
#include "eos_sha512.h"


/* ================================================================
* Field arithmetic mod p = 2^255 - 19
Expand Down Expand Up @@ -428,19 +428,21 @@ int eos_ed25519_verify(const uint8_t signature[64],
eos_sha512_final(&ctx, k);
reduce_hash(k);

/* Step 3: Compute k = SHA-256(R || A || M) reduced mod L */
/* Step 3: Compute k = SHA-512(R || A || M) reduced mod L */
uint8_t k_hash[64];
sha512_ctx_t ctx;
/* Compute [k](-A) + [S]B, which equals R for a valid signature. */
gf kA[4], sB[4];
scalarmult(kA, A, k);
scalarbase(sB, &signature[32]);
point_add(kA, (const gf *)sB);

uint8_t recovered[32];
point_pack(recovered, kA);

uint8_t diff = 0;
for (int i = 0; i < 32; i++) diff |= (uint8_t)(recovered[i] ^ signature[i]);

sha512_init(&ctx);
sha512_update(&ctx, signature, 32); /* R */
sha512_update(&ctx, public_key, 32); /* A */
sha512_update(&ctx, message, msg_len); /* M */
sha512_final(&ctx, k_hash);
/* Wipe the challenge scalar rather than leave it in boot-path memory. */
memset(k, 0, sizeof(k));

uint8_t k[32];
sc_reduce(k, k_hash);

return diff == 0 ? EOS_OK : EOS_ERR_SIGNATURE;
}
1 change: 0 additions & 1 deletion core/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ static int recovery_handle_write(eos_slot_t slot, uint32_t offset, uint16_t len)
/* offset/len come straight from the wire; without this check a
* recovery client can write past the slot boundary into the other
* slot, boot-control blocks, or the boot log. */
uint32_t slot_size = eos_hal_slot_size(slot);
if (slot_size == 0 || (uint64_t)offset + len > (uint64_t)slot_size)
return recovery_send_nack();

Expand Down
Loading