From 0d97f86d986203269e40dd3010e611b1689376a2 Mon Sep 17 00:00:00 2001 From: Duc Nguyen <106774416+ducnguyen-sb@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:41:47 -0500 Subject: [PATCH] Enforce idx from unsigned int to uint32_t. (#1611) --- src/sig_stfl/xmss/external/xmss_core_fast.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/sig_stfl/xmss/external/xmss_core_fast.c b/src/sig_stfl/xmss/external/xmss_core_fast.c index 4dd4c9b41d..deaedefa8a 100644 --- a/src/sig_stfl/xmss/external/xmss_core_fast.c +++ b/src/sig_stfl/xmss/external/xmss_core_fast.c @@ -221,7 +221,6 @@ static void treehash_init(const xmss_params *params, bds_state *state, const unsigned char *sk_seed, const unsigned char *pub_seed, const uint32_t addr[8]) { - unsigned int idx = index; // use three different addresses because at this point we use all three formats in parallel uint32_t ots_addr[8] = {0}; uint32_t ltree_addr[8] = {0}; @@ -235,14 +234,14 @@ static void treehash_init(const xmss_params *params, copy_subtree_addr(node_addr, addr); set_type(node_addr, 2); - uint32_t lastnode, i; + /* The subtree has at most 2^20 leafs, so uint32_t suffices. */ + uint32_t idx = index; + uint32_t lastnode = index +(1<n, sizeof(unsigned char)); unsigned int *stacklevels = malloc((height + 1)*sizeof(unsigned int)); unsigned int stackoffset=0; unsigned int nodeh; - lastnode = idx+(1<tree_height-params->bds_k; i++) { state->treehash[i].h = i; state->treehash[i].completed = 1; @@ -281,9 +280,7 @@ static void treehash_init(const xmss_params *params, i++; } - for (i = 0; i < params->n; i++) { - node[i] = stack[i]; - } + memcpy(node, stack, params->n); OQS_MEM_insecure_free(stacklevels); OQS_MEM_insecure_free(stack);