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.
|
|
|
|
*/
|
|
|
|
|
2017-08-01 14:20:30 +01:00
|
|
|
#ifndef XMSS_CORE_H
|
|
|
|
#define XMSS_CORE_H
|
2015-08-21 14:06:07 +01:00
|
|
|
|
2017-10-16 10:58:45 +01:00
|
|
|
#include "params.h"
|
|
|
|
|
2015-08-27 08:39:06 +01:00
|
|
|
typedef struct{
|
2017-08-03 16:38:34 +01:00
|
|
|
unsigned int h;
|
|
|
|
unsigned int next_idx;
|
|
|
|
unsigned int stackusage;
|
|
|
|
unsigned char completed;
|
|
|
|
unsigned char *node;
|
2015-08-27 08:39:06 +01:00
|
|
|
} treehash_inst;
|
|
|
|
|
|
|
|
typedef struct {
|
2017-08-03 16:38:34 +01:00
|
|
|
unsigned char *stack;
|
|
|
|
unsigned int stackoffset;
|
|
|
|
unsigned char *stacklevels;
|
|
|
|
unsigned char *auth;
|
|
|
|
unsigned char *keep;
|
|
|
|
treehash_inst *treehash;
|
|
|
|
unsigned char *retain;
|
|
|
|
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
|
|
|
|
*/
|
2017-08-03 16:38:34 +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-10-16 10:58:45 +01:00
|
|
|
int xmss_core_keypair(const xmss_params *params,
|
|
|
|
unsigned char *pk, unsigned char *sk, bds_state *state);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Signs a message.
|
2017-08-03 16:38:34 +01:00
|
|
|
* Returns
|
2015-08-21 14:06:07 +01:00
|
|
|
* 1. an array containing the signature followed by the message AND
|
|
|
|
* 2. an updated secret key!
|
|
|
|
*/
|
2017-10-16 10:58:45 +01:00
|
|
|
int xmss_core_sign(const xmss_params *params,
|
|
|
|
unsigned char *sk, bds_state *state,
|
2017-08-03 16:38:34 +01:00
|
|
|
unsigned char *sm, unsigned long long *smlen,
|
|
|
|
const unsigned char *m, unsigned long long mlen);
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Verifies a given message signature pair under a given public key.
|
2017-08-03 16:38:34 +01:00
|
|
|
*
|
|
|
|
* Note: msg and mlen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sm which has the form (sig||msg).
|
2015-08-21 14:06:07 +01:00
|
|
|
*/
|
2017-10-16 10:58:45 +01:00
|
|
|
int xmss_core_sign_open(const xmss_params *params,
|
|
|
|
unsigned char *m, unsigned long long *mlen,
|
2017-08-03 16:38:34 +01:00
|
|
|
const unsigned char *sm, unsigned long long smlen,
|
|
|
|
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-10-16 10:58:45 +01:00
|
|
|
int xmssmt_core_keypair(const xmss_params *params,
|
|
|
|
unsigned char *pk, unsigned char *sk,
|
2017-08-03 16:38:34 +01:00
|
|
|
bds_state *states, unsigned char *wots_sigs);
|
|
|
|
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Signs a message.
|
2017-08-03 16:38:34 +01:00
|
|
|
* Returns
|
2015-08-21 14:06:07 +01:00
|
|
|
* 1. an array containing the signature followed by the message AND
|
|
|
|
* 2. an updated secret key!
|
|
|
|
*/
|
2017-10-16 10:58:45 +01:00
|
|
|
int xmssmt_core_sign(const xmss_params *params,
|
|
|
|
unsigned char *sk,
|
2017-08-03 16:38:34 +01:00
|
|
|
bds_state *states, unsigned char *wots_sigs,
|
|
|
|
unsigned char *sm, unsigned long long *smlen,
|
|
|
|
const unsigned char *m, unsigned long long mlen);
|
|
|
|
|
2015-08-21 14:06:07 +01:00
|
|
|
/**
|
|
|
|
* Verifies a given message signature pair under a given public key.
|
|
|
|
*/
|
2017-10-16 10:58:45 +01:00
|
|
|
int xmssmt_core_sign_open(const xmss_params *params,
|
|
|
|
unsigned char *m, unsigned long long *mlen,
|
2017-08-03 16:38:34 +01:00
|
|
|
const unsigned char *sm, unsigned long long smlen,
|
|
|
|
const unsigned char *pk);
|
2015-08-21 14:06:07 +01:00
|
|
|
#endif
|