2017-10-19 15:04:42 +01:00
|
|
|
#ifndef XMSS_PARAMS_H
|
|
|
|
#define XMSS_PARAMS_H
|
2017-10-16 14:15:56 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-10-23 13:10:39 +01:00
|
|
|
/* These are merely internal identifiers for the supported hash functions. */
|
2017-10-16 14:15:56 +01:00
|
|
|
#define XMSS_SHA2 0
|
|
|
|
#define XMSS_SHAKE 1
|
|
|
|
|
2017-10-23 13:10:39 +01:00
|
|
|
/* This is a result of the OID definitions in the draft; needed for parsing. */
|
2017-10-16 14:15:56 +01:00
|
|
|
#define XMSS_OID_LEN 4
|
|
|
|
|
2017-10-23 13:10:39 +01:00
|
|
|
/* This structure will be populated when calling xmss[mt]_parse_oid. */
|
2017-10-16 14:15:56 +01:00
|
|
|
typedef struct {
|
|
|
|
unsigned int func;
|
|
|
|
unsigned int n;
|
2020-04-14 20:18:01 +01:00
|
|
|
unsigned int padding_len;
|
2017-10-16 14:15:56 +01:00
|
|
|
unsigned int wots_w;
|
|
|
|
unsigned int wots_log_w;
|
|
|
|
unsigned int wots_len1;
|
|
|
|
unsigned int wots_len2;
|
|
|
|
unsigned int wots_len;
|
2017-10-24 16:51:56 +01:00
|
|
|
unsigned int wots_sig_bytes;
|
2017-10-16 14:15:56 +01:00
|
|
|
unsigned int full_height;
|
|
|
|
unsigned int tree_height;
|
|
|
|
unsigned int d;
|
2017-10-24 16:51:56 +01:00
|
|
|
unsigned int index_bytes;
|
|
|
|
unsigned int sig_bytes;
|
|
|
|
unsigned int pk_bytes;
|
2017-10-26 15:54:06 +01:00
|
|
|
unsigned long long sk_bytes;
|
2017-10-16 14:15:56 +01:00
|
|
|
unsigned int bds_k;
|
|
|
|
} xmss_params;
|
|
|
|
|
2017-10-23 13:10:39 +01:00
|
|
|
/**
|
|
|
|
* Accepts strings such as "XMSS-SHA2_10_256"
|
|
|
|
* and outputs OIDs such as 0x01000001.
|
2017-11-01 13:33:07 +00:00
|
|
|
* Returns -1 when the parameter set is not found, 0 otherwise
|
2017-10-23 13:10:39 +01:00
|
|
|
*/
|
2018-02-05 09:22:17 +00:00
|
|
|
int xmss_str_to_oid(uint32_t *oid, const char *s);
|
2017-10-23 13:10:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accepts takes strings such as "XMSSMT-SHA2_20/2_256"
|
|
|
|
* and outputs OIDs such as 0x01000001.
|
2017-11-01 13:33:07 +00:00
|
|
|
* Returns -1 when the parameter set is not found, 0 otherwise
|
2017-10-23 13:10:39 +01:00
|
|
|
*/
|
2018-02-05 09:22:17 +00:00
|
|
|
int xmssmt_str_to_oid(uint32_t *oid, const char *s);
|
2017-10-17 16:11:18 +01:00
|
|
|
|
2017-10-23 13:10:39 +01:00
|
|
|
/**
|
|
|
|
* Accepts OIDs such as 0x01000001, and configures params accordingly.
|
2017-11-01 13:33:07 +00:00
|
|
|
* Returns -1 when the OID is not found, 0 otherwise.
|
2017-10-23 13:10:39 +01:00
|
|
|
*/
|
2017-10-16 14:15:56 +01:00
|
|
|
int xmss_parse_oid(xmss_params *params, const uint32_t oid);
|
2017-10-23 13:10:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Accepts OIDs such as 0x01000001, and configures params accordingly.
|
2017-11-01 13:33:07 +00:00
|
|
|
* Returns -1 when the OID is not found, 0 otherwise.
|
2017-10-23 13:10:39 +01:00
|
|
|
*/
|
2017-10-16 14:15:56 +01:00
|
|
|
int xmssmt_parse_oid(xmss_params *params, const uint32_t oid);
|
|
|
|
|
2018-09-03 08:49:44 +01:00
|
|
|
|
|
|
|
/* Given a params struct where the following properties have been initialized;
|
|
|
|
- full_height; the height of the complete (hyper)tree
|
|
|
|
- n; the number of bytes of hash function output
|
|
|
|
- d; the number of layers (d > 1 implies XMSSMT)
|
|
|
|
- func; one of {XMSS_SHA2, XMSS_SHAKE}
|
|
|
|
- wots_w; the Winternitz parameter
|
|
|
|
- optionally, bds_k; the BDS traversal trade-off parameter,
|
|
|
|
this function initializes the remainder of the params structure. */
|
|
|
|
int xmss_xmssmt_initialize_params(xmss_params *params);
|
|
|
|
|
2017-10-16 14:15:56 +01:00
|
|
|
#endif
|