Since there's a tweak being introduced, this should be reflected in the name of the functions.master
@@ -83,9 +83,9 @@ int hash_message(const xmss_params *params, unsigned char *out, | |||
/** | |||
* We assume the left half is in in[0]...in[n-1] | |||
*/ | |||
int hash_h(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]) | |||
int thash_h(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]) | |||
{ | |||
unsigned char buf[4 * params->n]; | |||
unsigned char bitmask[2 * params->n]; | |||
@@ -115,9 +115,9 @@ int hash_h(const xmss_params *params, | |||
return core_hash(params, out, buf, 4 * params->n); | |||
} | |||
int hash_f(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]) | |||
int thash_f(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]) | |||
{ | |||
unsigned char buf[3 * params->n]; | |||
unsigned char bitmask[params->n]; | |||
@@ -15,13 +15,13 @@ int h_msg(const xmss_params *params, | |||
const unsigned char *in, unsigned long long inlen, | |||
const unsigned char *key, const unsigned int keylen); | |||
int hash_h(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]); | |||
int thash_h(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]); | |||
int hash_f(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]); | |||
int thash_f(const xmss_params *params, | |||
unsigned char *out, const unsigned char *in, | |||
const unsigned char *pub_seed, uint32_t addr[8]); | |||
int hash_message(const xmss_params *params, unsigned char *out, | |||
const unsigned char *R, const unsigned char *root, | |||
@@ -43,7 +43,7 @@ static void gen_chain(const xmss_params *params, | |||
/* Iterate 'steps' calls to the hash function. */ | |||
for (i = start; i < (start+steps) && i < params->wots_w; i++) { | |||
set_hash_addr(addr, i); | |||
hash_f(params, out, out, pub_seed, addr); | |||
thash_f(params, out, out, pub_seed, addr); | |||
} | |||
} | |||
@@ -68,7 +68,7 @@ void l_tree(const xmss_params *params, | |||
for (i = 0; i < parent_nodes; i++) { | |||
set_tree_index(addr, i); | |||
/* Hashes the nodes at (i*2)*params->n and (i*2)*params->n + 1 */ | |||
hash_h(params, wots_pk + i*params->n, | |||
thash_h(params, wots_pk + i*params->n, | |||
wots_pk + (i*2)*params->n, pub_seed, addr); | |||
} | |||
/* If the row contained an odd number of nodes, the last node was not | |||
@@ -117,11 +117,11 @@ static void compute_root(const xmss_params *params, unsigned char *root, | |||
/* Pick the right or left neighbor, depending on parity of the node. */ | |||
if (leafidx & 1) { | |||
hash_h(params, buffer + params->n, buffer, pub_seed, addr); | |||
thash_h(params, buffer + params->n, buffer, pub_seed, addr); | |||
memcpy(buffer, auth_path, params->n); | |||
} | |||
else { | |||
hash_h(params, buffer, buffer, pub_seed, addr); | |||
thash_h(params, buffer, buffer, pub_seed, addr); | |||
memcpy(buffer + params->n, auth_path, params->n); | |||
} | |||
auth_path += params->n; | |||
@@ -131,7 +131,7 @@ static void compute_root(const xmss_params *params, unsigned char *root, | |||
set_tree_height(addr, params->tree_height - 1); | |||
leafidx >>= 1; | |||
set_tree_index(addr, leafidx); | |||
hash_h(params, root, buffer, pub_seed, addr); | |||
thash_h(params, root, buffer, pub_seed, addr); | |||
} | |||
/** | |||
@@ -69,7 +69,7 @@ static void treehash(const xmss_params *params, | |||
from the fact that we address the hash function calls. */ | |||
set_tree_height(node_addr, heights[offset - 1]); | |||
set_tree_index(node_addr, tree_idx); | |||
hash_h(params, stack + (offset-2)*params->n, | |||
thash_h(params, stack + (offset-2)*params->n, | |||
stack + (offset-2)*params->n, pub_seed, node_addr); | |||
offset--; | |||
/* Note that the top-most node is now one layer higher. */ | |||
@@ -269,7 +269,7 @@ static void treehash_init(const xmss_params *params, | |||
} | |||
set_tree_height(node_addr, stacklevels[stackoffset-1]); | |||
set_tree_index(node_addr, (idx >> (stacklevels[stackoffset-1]+1))); | |||
hash_h(params, stack+(stackoffset-2)*params->n, stack+(stackoffset-2)*params->n, pub_seed, node_addr); | |||
thash_h(params, stack+(stackoffset-2)*params->n, stack+(stackoffset-2)*params->n, pub_seed, node_addr); | |||
stacklevels[stackoffset-2]++; | |||
stackoffset--; | |||
} | |||
@@ -310,7 +310,7 @@ static void treehash_update(const xmss_params *params, | |||
memcpy(nodebuffer, state->stack + (state->stackoffset-1)*params->n, params->n); | |||
set_tree_height(node_addr, nodeheight); | |||
set_tree_index(node_addr, (treehash->next_idx >> (nodeheight+1))); | |||
hash_h(params, nodebuffer, nodebuffer, pub_seed, node_addr); | |||
thash_h(params, nodebuffer, nodebuffer, pub_seed, node_addr); | |||
nodeheight++; | |||
treehash->stackusage--; | |||
state->stackoffset--; | |||
@@ -422,7 +422,7 @@ static char bds_state_update(const xmss_params *params, | |||
} | |||
set_tree_height(node_addr, state->stacklevels[state->stackoffset-1]); | |||
set_tree_index(node_addr, (idx >> (state->stacklevels[state->stackoffset-1]+1))); | |||
hash_h(params, state->stack+(state->stackoffset-2)*params->n, state->stack+(state->stackoffset-2)*params->n, pub_seed, node_addr); | |||
thash_h(params, state->stack+(state->stackoffset-2)*params->n, state->stack+(state->stackoffset-2)*params->n, pub_seed, node_addr); | |||
state->stacklevels[state->stackoffset-2]++; | |||
state->stackoffset--; | |||
@@ -482,7 +482,7 @@ static void bds_round(const xmss_params *params, | |||
else { | |||
set_tree_height(node_addr, (tau-1)); | |||
set_tree_index(node_addr, leaf_idx >> tau); | |||
hash_h(params, state->auth + tau * params->n, buf, pub_seed, node_addr); | |||
thash_h(params, state->auth + tau * params->n, buf, pub_seed, node_addr); | |||
for (i = 0; i < tau; i++) { | |||
if (i < params->tree_height - params->bds_k) { | |||
memcpy(state->auth + i * params->n, state->treehash[i].node, params->n); | |||