5 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/fors.h"
11 #include "sw/device/lib/testing/test_framework/check.h"
13 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/hash.h"
15 OTTF_DEFINE_TEST_CONFIG();
18 static uint32_t kTestSig[kSpxForsWords] = {0};
19 static uint8_t kTestMsg[kSpxForsMsgBytes] = {0};
34 static uint32_t kExpectedPk[kSpxNWords] = {
42 static rom_error_t pk_from_sig_test(
void) {
44 RETURN_IF_ERROR(spx_hash_initialize(&kTestCtx));
47 uint32_t actual_pk[kSpxNWords];
48 fors_pk_from_sig(kTestSig, kTestMsg, &kTestCtx, &kTestAddr, actual_pk);
51 CHECK_ARRAYS_EQ(actual_pk, kExpectedPk, kSpxNWords);
59 unsigned char *test_sig_bytes = (
unsigned char *)kTestSig;
60 for (
size_t i = 0; i < kSpxForsBytes; i++) {
61 test_sig_bytes[i] = i & 255;
65 for (
size_t i = 0; i < kSpxForsMsgBytes; i++) {
66 kTestMsg[i] = (kSpxForsMsgBytes - i) & 255;
70 spx_addr_layer_set(&kTestAddr, 0xa3);
71 spx_addr_tree_set(&kTestAddr, 0xafaeadacabaaa9a8);
72 spx_addr_type_set(&kTestAddr, kSpxAddrTypeForsTree);
73 spx_addr_keypair_set(&kTestAddr, 0xb4b5b6b7);
77 return status_ok(result);