• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CRYPT_SLH_DSA_XMSS_H
17 #define CRYPT_SLH_DSA_XMSS_H
18 
19 #include "hitls_build.h"
20 #ifdef HITLS_CRYPTO_SLH_DSA
21 
22 #include <stdint.h>
23 #include "crypt_slh_dsa.h"
24 
25 /**
26  * @brief Sign a message using XMSS
27  *
28  * @param sig Output XMSS signature
29  * @param sigLen Length of the signature
30  * @param msg Input message to sign
31  * @param msgLen Length of the message
32  * @param idx Index of the used WOTS+ key pair
33  * @param adrs Address structure for domain separation
34  * @param ctx SLH-DSA context
35  * @return int 0 on success, error code otherwise
36  */
37 int32_t XmssSign(const uint8_t *msg, size_t msgLen, uint32_t idx, SlhDsaAdrs *adrs, const CryptSlhDsaCtx *ctx,
38                  uint8_t *sig, uint32_t *sigLen);
39 
40 /**
41  * @brief Compute an internal node of the XMSS tree
42  *
43  * @param node Output internal node
44  * @param idx Node index at the given height
45  * @param height Node height in the tree
46  * @param adrs Address structure for domain separation
47  * @param ctx SLH-DSA context
48  * @return int 0 on success, error code otherwise
49  */
50 int32_t XmssNode(uint8_t *node, uint32_t idx, uint32_t height, SlhDsaAdrs *adrs, const CryptSlhDsaCtx *ctx);
51 
52 /**
53  * @brief Compute a public key from a signature and message
54  *
55  * @param idx Index of the used WOTS+ key pair
56  * @param sig Signature
57  * @param sigLen Length of the signature
58  * @param msg Message
59  * @param msgLen Length of the message
60  * @param adrs Address structure for domain separation
61  * @param ctx SLH-DSA context
62  * @param pk Output public key, the length is n
63  * @return int 0 on success, error code otherwise
64  */
65 int32_t XmssPkFromSig(uint32_t idx, const uint8_t *sig, uint32_t sigLen, const uint8_t *msg, uint32_t msgLen,
66                       SlhDsaAdrs *adrs, const CryptSlhDsaCtx *ctx, uint8_t *pk);
67 
68 #endif // HITLS_CRYPTO_SLH_DSA
69 #endif // CRYPT_SLH_DSA_XMSS_H