Browse Source

Abstract address types into macro constants

master
Joost Rijneveld 7 years ago
parent
commit
4111393912
No known key found for this signature in database GPG Key ID: A4FE39CF49CBC553
3 changed files with 16 additions and 12 deletions
  1. +4
    -0
      hash_address.h
  2. +6
    -6
      xmss_commons.c
  3. +6
    -6
      xmss_core.c

+ 4
- 0
hash_address.h View File

@@ -3,6 +3,10 @@


#include <stdint.h> #include <stdint.h>


#define XMSS_ADDR_TYPE_OTS 0
#define XMSS_ADDR_TYPE_LTREE 1
#define XMSS_ADDR_TYPE_HASHTREE 2

void set_layer_addr(uint32_t addr[8], uint32_t layer); void set_layer_addr(uint32_t addr[8], uint32_t layer);


void set_tree_addr(uint32_t addr[8], uint64_t tree); void set_tree_addr(uint32_t addr[8], uint64_t tree);


+ 6
- 6
xmss_commons.c View File

@@ -201,9 +201,9 @@ int xmss_core_sign_open(const xmss_params *params,
uint32_t ltree_addr[8] = {0}; uint32_t ltree_addr[8] = {0};
uint32_t node_addr[8] = {0}; uint32_t node_addr[8] = {0};


set_type(ots_addr, 0);
set_type(ltree_addr, 1);
set_type(node_addr, 2);
set_type(ots_addr, XMSS_ADDR_TYPE_OTS);
set_type(ltree_addr, XMSS_ADDR_TYPE_LTREE);
set_type(node_addr, XMSS_ADDR_TYPE_HASHTREE);


*mlen = smlen - params->bytes; *mlen = smlen - params->bytes;


@@ -264,9 +264,9 @@ int xmssmt_core_sign_open(const xmss_params *params,
uint32_t ltree_addr[8] = {0}; uint32_t ltree_addr[8] = {0};
uint32_t node_addr[8] = {0}; uint32_t node_addr[8] = {0};


set_type(ots_addr, 0);
set_type(ltree_addr, 1);
set_type(node_addr, 2);
set_type(ots_addr, XMSS_ADDR_TYPE_OTS);
set_type(ltree_addr, XMSS_ADDR_TYPE_LTREE);
set_type(node_addr, XMSS_ADDR_TYPE_HASHTREE);


*mlen = smlen - params->bytes; *mlen = smlen - params->bytes;




+ 6
- 6
xmss_core.c View File

@@ -39,9 +39,9 @@ static void treehash(const xmss_params *params,
copy_subtree_addr(ltree_addr, subtree_addr); copy_subtree_addr(ltree_addr, subtree_addr);
copy_subtree_addr(node_addr, subtree_addr); copy_subtree_addr(node_addr, subtree_addr);


set_type(ots_addr, 0);
set_type(ltree_addr, 1);
set_type(node_addr, 2);
set_type(ots_addr, XMSS_ADDR_TYPE_OTS);
set_type(ltree_addr, XMSS_ADDR_TYPE_LTREE);
set_type(node_addr, XMSS_ADDR_TYPE_HASHTREE);


for (idx = 0; idx < (uint32_t)(1 << params->tree_height); idx++) { for (idx = 0; idx < (uint32_t)(1 << params->tree_height); idx++) {
/* Add the next leaf node to the stack. */ /* Add the next leaf node to the stack. */
@@ -119,7 +119,7 @@ int xmss_core_sign(const xmss_params *params,
unsigned char idx_bytes_32[32]; unsigned char idx_bytes_32[32];


uint32_t ots_addr[8] = {0}; uint32_t ots_addr[8] = {0};
set_type(ots_addr, 0);
set_type(ots_addr, XMSS_ADDR_TYPE_OTS);


/* Read and use the current index from the secret key. */ /* Read and use the current index from the secret key. */
idx = (unsigned long)bytes_to_ull(sk, params->index_len); idx = (unsigned long)bytes_to_ull(sk, params->index_len);
@@ -212,7 +212,7 @@ int xmssmt_core_sign(const xmss_params *params,
uint32_t idx_leaf; uint32_t idx_leaf;


uint32_t ots_addr[8] = {0}; uint32_t ots_addr[8] = {0};
set_type(ots_addr, 0);
set_type(ots_addr, XMSS_ADDR_TYPE_OTS);


/* Read and use the current index from the secret key. */ /* Read and use the current index from the secret key. */
idx = (unsigned long)bytes_to_ull(sk, params->index_len); idx = (unsigned long)bytes_to_ull(sk, params->index_len);
@@ -233,7 +233,7 @@ int xmssmt_core_sign(const xmss_params *params,
hash_message(params, mhash, sm, pub_root, idx, m, mlen); hash_message(params, mhash, sm, pub_root, idx, m, mlen);
sm += params->n; sm += params->n;


set_type(ots_addr, 0);
set_type(ots_addr, XMSS_ADDR_TYPE_OTS);


for (i = 0; i < params->d; i++) { for (i = 0; i < params->d; i++) {
idx_leaf = (idx & ((1 << params->tree_height)-1)); idx_leaf = (idx & ((1 << params->tree_height)-1));


Loading…
Cancel
Save