1 /* $OpenBSD: xmss_hash_address.c,v 1.2 2018/02/26 03:56:44 dtucker Exp $ */
2 /*
3 hash_address.c version 20160722
4 Andreas Hülsing
5 Joost Rijneveld
6 Public domain.
7 */
8 #include "includes.h"
9 #ifdef WITH_XMSS
10
11 #ifdef HAVE_STDINT_H
12 # include <stdint.h>
13 #endif
14 #include "xmss_hash_address.h" /* prototypes */
15
setLayerADRS(uint32_t adrs[8],uint32_t layer)16 void setLayerADRS(uint32_t adrs[8], uint32_t layer){
17 adrs[0] = layer;
18 }
19
setTreeADRS(uint32_t adrs[8],uint64_t tree)20 void setTreeADRS(uint32_t adrs[8], uint64_t tree){
21 adrs[1] = (uint32_t) (tree >> 32);
22 adrs[2] = (uint32_t) tree;
23 }
24
setType(uint32_t adrs[8],uint32_t type)25 void setType(uint32_t adrs[8], uint32_t type){
26 adrs[3] = type;
27 int i;
28 for(i = 4; i < 8; i++){
29 adrs[i] = 0;
30 }
31 }
32
setKeyAndMask(uint32_t adrs[8],uint32_t keyAndMask)33 void setKeyAndMask(uint32_t adrs[8], uint32_t keyAndMask){
34 adrs[7] = keyAndMask;
35 }
36
37 // OTS
38
setOTSADRS(uint32_t adrs[8],uint32_t ots)39 void setOTSADRS(uint32_t adrs[8], uint32_t ots){
40 adrs[4] = ots;
41 }
42
setChainADRS(uint32_t adrs[8],uint32_t chain)43 void setChainADRS(uint32_t adrs[8], uint32_t chain){
44 adrs[5] = chain;
45 }
46
setHashADRS(uint32_t adrs[8],uint32_t hash)47 void setHashADRS(uint32_t adrs[8], uint32_t hash){
48 adrs[6] = hash;
49 }
50
51 // L-tree
52
setLtreeADRS(uint32_t adrs[8],uint32_t ltree)53 void setLtreeADRS(uint32_t adrs[8], uint32_t ltree){
54 adrs[4] = ltree;
55 }
56
57 // Hash Tree & L-tree
58
setTreeHeight(uint32_t adrs[8],uint32_t treeHeight)59 void setTreeHeight(uint32_t adrs[8], uint32_t treeHeight){
60 adrs[5] = treeHeight;
61 }
62
setTreeIndex(uint32_t adrs[8],uint32_t treeIndex)63 void setTreeIndex(uint32_t adrs[8], uint32_t treeIndex){
64 adrs[6] = treeIndex;
65 }
66 #endif /* WITH_XMSS */
67