Skip to content

Commit

Permalink
Enforce idx from unsigned int to uint32_t. (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducnguyen-sb committed Nov 15, 2023
1 parent 3953cbf commit b9df808
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/sig_stfl/xmss/external/xmss_core_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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<<height), i;
unsigned char *stack = calloc((height+1)*params->n, sizeof(unsigned char));
unsigned int *stacklevels = malloc((height + 1)*sizeof(unsigned int));
unsigned int stackoffset=0;
unsigned int nodeh;

lastnode = idx+(1<<height);

for (i = 0; i < params->tree_height-params->bds_k; i++) {
state->treehash[i].h = i;
state->treehash[i].completed = 1;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b9df808

Please sign in to comment.