API参考
载入中...
搜索中...
未找到
xmss_address.h
1
/*
2
* This file is part of the openHiTLS project.
3
*
4
* openHiTLS is licensed under the Mulan PSL v2.
5
* You can use this software according to the terms and conditions of the Mulan PSL v2.
6
* You may obtain a copy of Mulan PSL v2 at:
7
*
8
* http://license.coscl.org.cn/MulanPSL2
9
*
10
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13
* See the Mulan PSL v2 for more details.
14
*/
15
16
#ifndef XMSS_ADDRESS_H
17
#define XMSS_ADDRESS_H
18
19
#include "hitls_build.h"
20
#ifdef HITLS_CRYPTO_XMSS
21
22
#include <stdint.h>
23
24
typedef
struct
CryptAdrsOps CryptAdrsOps;
25
26
/*
27
* XMSS Address Structure (32 bytes, RFC 8391 standard)
28
*
29
* This structure follows the RFC 8391 XMSS address format.
30
* The interpretation of bytes 16-31 depends on the address type:
31
*
32
* Common fields (all types):
33
* | Bytes 0-3 | layer address | Layer index in multi-tree XMSSMT
34
* | Bytes 4-11 | tree address | Tree index within layer
35
* | Bytes 12-15 | type | Address type (OTS=0, LTREE=1, HASH=2)
36
*
37
* Type-specific fields:
38
* - For OTS Hash Address (type=0):
39
* | Bytes 16-19 | OTS address | WOTS+ key pair index (keyPairAddr)
40
* | Bytes 20-23 | chain address | WOTS+ chain index (chainAddr)
41
* | Bytes 24-27 | hash address | WOTS+ hash iteration (hashAddr)
42
* | Bytes 28-31 | keyAndMask | Key/mask index (0, 1, or 2)
43
*
44
* - For L-tree Address (type=1):
45
* | Bytes 16-19 | L-tree addr | L-tree index (keyPairAddr)
46
* | Bytes 20-23 | tree height | Height in L-tree (uses chainAddr field)
47
* | Bytes 24-27 | tree index | Node index in L-tree (uses hashAddr field)
48
* | Bytes 28-31 | keyAndMask | Key/mask index
49
*
50
* - For Tree Hash Address (type=2):
51
* | Bytes 16-19 | padding | Zero padding
52
* | Bytes 20-23 | tree height | Height in tree (uses chainAddr field)
53
* | Bytes 24-27 | tree index | Node index in tree (uses hashAddr field)
54
* | Bytes 28-31 | keyAndMask | Key/mask index
55
*
56
* All fields are stored in big-endian format.
57
*/
58
typedef
union
{
59
struct
{
60
uint8_t layerAddr[4];
// Bytes 0-3: Layer address (for XMSSMT)
61
uint8_t treeAddr[8];
// Bytes 4-11: Tree address
62
uint8_t type[4];
// Bytes 12-15: Address type
63
uint8_t keyPairAddr[4];
// Bytes 16-19: WOTS+ key pair address
64
uint8_t chainAddr[4];
// Bytes 20-23: WOTS+ chain address
65
uint8_t hashAddr[4];
// Bytes 24-27: WOTS+ hash address
66
uint8_t keyAndMask[4];
// Bytes 28-31: Key/mask index
67
} fields;
68
uint8_t bytes[32];
69
} XmssAdrs;
70
71
#define MAX_ADRS_SIZE 32
72
73
/* Address types (RFC 8391 Section 2.5) */
74
#define XMSS_ADRS_TYPE_OTS 0
// WOTS+ address
75
#define XMSS_ADRS_TYPE_LTREE 1
// L-tree address (compress WOTS+ pk)
76
#define XMSS_ADRS_TYPE_HASH 2
// Tree hash address
77
78
/*
79
* Set keyAndMask field (for ROBUST mode)
80
* index: 0 for key, 1 for first bitmask, 2 for second bitmask
81
*
82
* This is the only direct function exposed because it's used internally
83
* by xmss_hash.c which doesn't have access to CryptAdrsOps.
84
*/
85
void
XmssAdrs_SetKeyAndMask(
void
*adrs, uint32_t index);
86
87
/*
88
* Initialize CryptAdrsOps with XMSS address operations
89
*
90
* @param ops [out] Generic address operations table to initialize
91
*
92
* @return CRYPT_SUCCESS on success
93
*/
94
int32_t XmssAdrsOps_Init(CryptAdrsOps *ops);
95
96
#endif
// HITLS_CRYPTO_XMSS
97
#endif
// XMSS_ADDRESS_H
crypto
xmss
src
xmss_address.h
制作者
1.15.0