5 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/wots.h"
11 #include "sw/device/lib/testing/test_framework/check.h"
13 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/hash.h"
14 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/params.h"
15 #include "sw/device/silicon_creator/lib/sigverify/sphincsplus/thash.h"
17 OTTF_DEFINE_TEST_CONFIG();
20 kSpxWotsMsgBytes = ((kSpxWotsLen1 * kSpxWotsLogW + 7) / 8),
22 (kSpxWotsMsgBytes +
sizeof(uint32_t) - 1) /
sizeof(uint32_t),
26 static uint32_t kTestSig[kSpxWotsWords] = {0};
27 static uint32_t kTestMsg[kSpxWotsMsgWords] = {0};
42 static uint32_t kExpectedLeaf[kSpxNWords] = {0x14199738, 0x8d0ae722, 0x27ba271f,
46 static rom_error_t pk_from_sig_test(
void) {
47 RETURN_IF_ERROR(spx_hash_initialize(&kTestCtx));
50 uint32_t wots_pk[kSpxWotsPkWords];
51 wots_pk_from_sig(kTestSig, kTestMsg, &kTestCtx, &kTestAddr, wots_pk);
57 spx_addr_type_set(&wots_pk_addr, kSpxAddrTypeWotsPk);
58 spx_addr_keypair_copy(&wots_pk_addr, &kTestAddr);
59 uint32_t actual_leaf[kSpxNWords];
60 thash(wots_pk, kSpxWotsLen, &kTestCtx, &wots_pk_addr, actual_leaf);
63 CHECK_ARRAYS_EQ(actual_leaf, kExpectedLeaf,
ARRAYSIZE(kExpectedLeaf));
72 unsigned char *test_sig_bytes = (
unsigned char *)kTestSig;
73 for (
size_t i = 0; i < kSpxWotsBytes; i++) {
74 test_sig_bytes[i] = i & 255;
78 unsigned char *test_msg_bytes = (
unsigned char *)kTestMsg;
79 for (
size_t i = 0; i < kSpxWotsMsgBytes; i++) {
80 test_msg_bytes[i] = (kSpxWotsMsgBytes - i) & 255;
84 spx_addr_layer_set(&kTestAddr, 0xa3);
85 spx_addr_tree_set(&kTestAddr, 0xafaeadacabaaa9a8);
86 spx_addr_type_set(&kTestAddr, kSpxAddrTypeWots);
87 spx_addr_keypair_set(&kTestAddr, 0xb4b5b6b7);
91 return status_ok(result);