2015-08-21 14:06:07 +01:00
|
|
|
/*
|
2016-09-22 15:31:41 +01:00
|
|
|
xmss_fast.h version 20160722
|
2016-02-16 15:31:18 +00:00
|
|
|
Andreas Hülsing
|
|
|
|
Joost Rijneveld
|
2015-08-21 14:06:07 +01:00
|
|
|
Public domain.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "wots.h"
|
|
|
|
|
|
|
|
#ifndef XMSS_H
|
|
|
|
#define XMSS_H
|
|
|
|
typedef struct{
|
2016-02-02 13:06:43 +00:00
|
|
|
unsigned int level;
|
2015-08-21 14:06:07 +01:00
|
|
|
unsigned long long subtree;
|
2016-02-02 13:06:43 +00:00
|
|
|
unsigned int subleaf;
|
2015-08-21 14:06:07 +01:00
|
|
|
} leafaddr;
|
|
|
|
|
2015-08-27 08:39:06 +01:00
|
|
|
typedef struct{
|
2016-02-02 13:06:43 +00:00
|
|
|
unsigned int h;
|
|
|
|
unsigned int next_idx;
|
|
|
|
unsigned int stackusage;
|
2015-08-27 08:39:06 +01:00
|
|
|
unsigned char completed;
|
|
|
|
unsigned char *node;
|
|
|
|
} treehash_inst;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned char *stack;
|
2016-02-02 13:06:43 +00:00
|
|
|
unsigned int stackoffset;
|
2015-08-27 08:39:06 +01:00
|
|
|
unsigned char *stacklevels;
|
|
|
|
unsigned char *auth;
|
|
|
|
unsigned char *keep;
|
|
|
|
treehash_inst *treehash;
|
|
|
|
unsigned char *retain;
|
2016-02-02 13:06:43 +00:00
|
|
|
unsigned int next_leaf;
|
2015-08-27 08:39:06 +01:00
|
|
|
} bds_state;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize BDS state struct
|
|
|
|
* parameter names are the same as used in the description of the BDS traversal
|
|
|
|
*/
|
2015-09-21 12:24:42 +01:00
|
|
|
void xmss_set_bds_state(bds_state *state, unsigned char *stack, int stackoffset, unsigned char *stacklevels, unsigned char *auth, unsigned char *keep, treehash_inst *treehash, unsigned char *retain, int next_leaf);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Generates a XMSS key pair for a given parameter set.
|
2016-07-11 10:15:16 +01:00
|
|
|
* Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
|
2015-08-21 14:06:07 +01:00
|
|
|
* Format pk: [root || PUB_SEED] omitting algo oid.
|
|
|
|
*/
|
2017-06-02 13:10:24 +01:00
|
|
|
int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Signs a message.
|
|
|
|
* Returns
|
|
|
|
* 1. an array containing the signature followed by the message AND
|
|
|
|
* 2. an updated secret key!
|
|
|
|
*
|
|
|
|
*/
|
2017-06-02 13:10:24 +01:00
|
|
|
int xmss_sign(unsigned char *sk, bds_state *state, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Verifies a given message signature pair under a given public key.
|
|
|
|
*
|
|
|
|
* Note: msg and msglen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sig_msg which has the form (sig||msg).
|
|
|
|
*/
|
2017-06-02 13:10:24 +01:00
|
|
|
int xmss_sign_open(unsigned char *msg,unsigned long long *msglen, const unsigned char *sig_msg,unsigned long long sig_msg_len, const unsigned char *pk);
|
2015-08-21 14:06:07 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generates a XMSSMT key pair for a given parameter set.
|
2016-07-11 10:15:16 +01:00
|
|
|
* Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root]
|
2015-08-21 14:06:07 +01:00
|
|
|
* Format pk: [root || PUB_SEED] omitting algo oid.
|
|
|
|
*/
|
2017-06-02 13:10:24 +01:00
|
|
|
int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Signs a message.
|
|
|
|
* Returns
|
|
|
|
* 1. an array containing the signature followed by the message AND
|
|
|
|
* 2. an updated secret key!
|
|
|
|
*
|
|
|
|
*/
|
2017-06-02 13:10:24 +01:00
|
|
|
int xmssmt_sign(unsigned char *sk, bds_state *state, unsigned char *wots_sigs, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Verifies a given message signature pair under a given public key.
|
|
|
|
*/
|
2017-06-02 13:10:24 +01:00
|
|
|
int xmssmt_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk);
|
2015-08-21 14:06:07 +01:00
|
|
|
#endif
|
|
|
|
|