From 9f512fa8dc5e1ab99b3513d6e77e5bad0546e39e Mon Sep 17 00:00:00 2001 From: Andreas Date: Thu, 22 Sep 2016 16:31:41 +0200 Subject: [PATCH] v06 --- hash.c | 15 ++++-------- hash.h | 2 +- hash_address.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ hash_address.h | 2 +- test/test_xmssmt.c | 2 +- wots.c | 2 +- wots.h | 2 +- xmss.c | 2 +- xmss.h | 2 +- xmss_commons.c | 2 +- xmss_commons.h | 2 +- xmss_fast.c | 2 +- xmss_fast.h | 2 +- 13 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 hash_address.c diff --git a/hash.c b/hash.c index e421f45..4f713c6 100644 --- a/hash.c +++ b/hash.c @@ -1,5 +1,5 @@ /* -hash.c version 20160708 +hash.c version 20160722 Andreas Hülsing Joost Rijneveld Public domain. @@ -115,17 +115,10 @@ int hash_f(unsigned char *out, const unsigned char *in, const unsigned char *pub unsigned char byte_addr[32]; unsigned int i; - setKeyAndMask(addr, 0); - printf("\naddr before: "); - for(i = 0; i< 8; i++){ - printf("%08x",addr[i]); - } - addr_to_byte(byte_addr, addr); - printf("\naddr after: "); - hexdump(byte_addr,32); - printf("\n"); + setKeyAndMask(addr, 0); + addr_to_byte(byte_addr, addr); prf(key, byte_addr, pub_seed, n); - // Use MSB order + setKeyAndMask(addr, 1); addr_to_byte(byte_addr, addr); prf(bitmask, byte_addr, pub_seed, n); diff --git a/hash.h b/hash.h index fbe594d..2fed730 100644 --- a/hash.h +++ b/hash.h @@ -1,5 +1,5 @@ /* -hash.h version 20160217 +hash.h version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/hash_address.c b/hash_address.c new file mode 100644 index 0000000..38c30b5 --- /dev/null +++ b/hash_address.c @@ -0,0 +1,58 @@ +/* +hash_address.c version 20160722 +Andreas Hülsing +Joost Rijneveld +Public domain. +*/ +#include + +void setLayerADRS(uint32_t adrs[8], uint32_t layer){ + adrs[0] = layer; +} + +void setTreeADRS(uint32_t adrs[8], uint64_t tree){ + adrs[1] = (uint32_t) (tree >> 32); + adrs[2] = (uint32_t) tree; +} + +void setType(uint32_t adrs[8], uint32_t type){ + adrs[3] = type; + int i; + for(i = 4; i < 8; i++){ + adrs[i] = 0; + } +} + +void setKeyAndMask(uint32_t adrs[8], uint32_t keyAndMask){ + adrs[7] = keyAndMask; +} + +// OTS + +void setOTSADRS(uint32_t adrs[8], uint32_t ots){ + adrs[4] = ots; +} + +void setChainADRS(uint32_t adrs[8], uint32_t chain){ + adrs[5] = chain; +} + +void setHashADRS(uint32_t adrs[8], uint32_t hash){ + adrs[6] = hash; +} + +// L-tree + +void setLtreeADRS(uint32_t adrs[8], uint32_t ltree){ + adrs[4] = ltree; +} + +// Hash Tree & L-tree + +void setTreeHeight(uint32_t adrs[8], uint32_t treeHeight){ + adrs[5] = treeHeight; +} + +void setTreeIndex(uint32_t adrs[8], uint32_t treeIndex){ + adrs[6] = treeIndex; +} \ No newline at end of file diff --git a/hash_address.h b/hash_address.h index cce1bbe..73cbfd6 100644 --- a/hash_address.h +++ b/hash_address.h @@ -1,5 +1,5 @@ /* -hash_address.h version 20160707 +hash_address.h version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/test/test_xmssmt.c b/test/test_xmssmt.c index ade53fa..29827bb 100644 --- a/test/test_xmssmt.c +++ b/test/test_xmssmt.c @@ -38,7 +38,7 @@ int main() // check pub_seed in SK for (i = 0; i < n; i++) { if (pk[n+i] != sk[params->index_len+2*n+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); - if (pk[i] != sk[4+3*n+i]) printf("pk.root != sk.root %llu",i); + if (pk[i] != sk[params->index_len+3*n+i]) printf("pk.root != sk.root %llu",i); } printf("pk checked\n"); diff --git a/wots.c b/wots.c index 9ea1420..52b3712 100644 --- a/wots.c +++ b/wots.c @@ -1,5 +1,5 @@ /* -wots.c version 20160217 +wots.c version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/wots.h b/wots.h index bcce6a5..6e5c8f7 100644 --- a/wots.h +++ b/wots.h @@ -1,5 +1,5 @@ /* -wots.h version 20160217 +wots.h version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/xmss.c b/xmss.c index a123cfe..966f2c3 100644 --- a/xmss.c +++ b/xmss.c @@ -1,5 +1,5 @@ /* -xmss.c version 20160217 +xmss.c version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/xmss.h b/xmss.h index 9ae2659..a51c2b8 100644 --- a/xmss.h +++ b/xmss.h @@ -1,5 +1,5 @@ /* -xmss.h version 20160217 +xmss.h version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/xmss_commons.c b/xmss_commons.c index 617dc7e..51171af 100644 --- a/xmss_commons.c +++ b/xmss_commons.c @@ -1,5 +1,5 @@ /* -xmss_commons.c 20160217 +xmss_commons.c 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/xmss_commons.h b/xmss_commons.h index f5e6d7a..32fd4e2 100644 --- a/xmss_commons.h +++ b/xmss_commons.h @@ -1,5 +1,5 @@ /* -xmss_commons.h 20160217 +xmss_commons.h 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/xmss_fast.c b/xmss_fast.c index 46a450a..53ea3eb 100644 --- a/xmss_fast.c +++ b/xmss_fast.c @@ -1,5 +1,5 @@ /* -xmss_fast.c version 20160217 +xmss_fast.c version 20160722 Andreas Hülsing Joost Rijneveld Public domain. diff --git a/xmss_fast.h b/xmss_fast.h index ec66910..922f908 100644 --- a/xmss_fast.h +++ b/xmss_fast.h @@ -1,5 +1,5 @@ /* -xmss_fast.h version 20160217 +xmss_fast.h version 20160722 Andreas Hülsing Joost Rijneveld Public domain.