2017-08-01 14:20:30 +01:00
|
|
|
#ifndef XMSS_CORE_H
|
|
|
|
#define XMSS_CORE_H
|
2015-08-11 11:08:27 +01:00
|
|
|
|
2017-10-19 15:17:07 +01:00
|
|
|
#include "params.h"
|
|
|
|
|
2017-10-26 15:54:06 +01:00
|
|
|
/**
|
|
|
|
* Given a set of parameters, this function returns the size of the secret key.
|
|
|
|
* This is implementation specific, as varying choices in tree traversal will
|
|
|
|
* result in varying requirements for state storage.
|
2018-09-03 08:49:44 +01:00
|
|
|
*
|
|
|
|
* This function handles both XMSS and XMSSMT parameter sets.
|
2017-10-26 15:54:06 +01:00
|
|
|
*/
|
2018-09-03 08:49:44 +01:00
|
|
|
unsigned long long xmss_xmssmt_core_sk_bytes(const xmss_params *params);
|
2017-10-26 15:54:06 +01:00
|
|
|
|
2017-10-26 11:10:17 +01:00
|
|
|
/*
|
2015-08-11 11:08:27 +01:00
|
|
|
* Generates a XMSS key pair for a given parameter set.
|
2017-10-26 11:10:17 +01:00
|
|
|
* Format sk: [(32bit) index || SK_SEED || SK_PRF || PUB_SEED || root]
|
|
|
|
* Format pk: [root || PUB_SEED], omitting algorithm OID.
|
2015-08-11 11:08:27 +01:00
|
|
|
*/
|
2017-10-26 11:10:17 +01:00
|
|
|
int xmss_core_keypair(const xmss_params *params,
|
|
|
|
unsigned char *pk, unsigned char *sk);
|
|
|
|
|
2015-08-11 11:08:27 +01:00
|
|
|
/**
|
2017-10-26 11:10:17 +01:00
|
|
|
* Signs a message. Returns an array containing the signature followed by the
|
|
|
|
* message and an updated secret key.
|
2015-08-11 11:08:27 +01:00
|
|
|
*/
|
2017-10-26 11:10:17 +01:00
|
|
|
int xmss_core_sign(const xmss_params *params,
|
|
|
|
unsigned char *sk,
|
|
|
|
unsigned char *sm, unsigned long long *smlen,
|
|
|
|
const unsigned char *m, unsigned long long mlen);
|
|
|
|
|
2015-08-11 11:08:27 +01:00
|
|
|
/**
|
|
|
|
* Verifies a given message signature pair under a given public key.
|
2017-10-26 11:10:17 +01:00
|
|
|
* Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
|
2015-08-11 11:08:27 +01:00
|
|
|
*/
|
2017-10-26 11:10:17 +01:00
|
|
|
int xmss_core_sign_open(const xmss_params *params,
|
|
|
|
unsigned char *m, unsigned long long *mlen,
|
|
|
|
const unsigned char *sm, unsigned long long smlen,
|
|
|
|
const unsigned char *pk);
|
2015-08-11 11:08:27 +01:00
|
|
|
|
2015-08-12 13:37:49 +01:00
|
|
|
/*
|
|
|
|
* Generates a XMSSMT key pair for a given parameter set.
|
2017-11-02 16:00:38 +00:00
|
|
|
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || PUB_SEED || root]
|
2017-10-26 11:10:17 +01:00
|
|
|
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
2015-08-12 13:37:49 +01:00
|
|
|
*/
|
2017-10-26 11:10:17 +01:00
|
|
|
int xmssmt_core_keypair(const xmss_params *params,
|
|
|
|
unsigned char *pk, unsigned char *sk);
|
|
|
|
|
2020-05-24 16:56:45 +01:00
|
|
|
/*
|
|
|
|
* Derives a XMSSMT key pair for a given parameter set.
|
|
|
|
* Seed must be 3*n long.
|
|
|
|
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || root || PUB_SEED]
|
|
|
|
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
|
|
|
*/
|
2020-05-25 12:04:02 +01:00
|
|
|
int xmssmt_core_seed_keypair(const xmss_params *params,
|
|
|
|
unsigned char *pk, unsigned char *sk,
|
|
|
|
unsigned char *seed);
|
2020-05-24 16:56:45 +01:00
|
|
|
|
2015-08-12 13:37:49 +01:00
|
|
|
/**
|
2017-10-26 11:10:17 +01:00
|
|
|
* Signs a message. Returns an array containing the signature followed by the
|
|
|
|
* message and an updated secret key.
|
2015-08-12 13:37:49 +01:00
|
|
|
*/
|
2017-10-26 11:10:17 +01:00
|
|
|
int xmssmt_core_sign(const xmss_params *params,
|
|
|
|
unsigned char *sk,
|
|
|
|
unsigned char *sm, unsigned long long *smlen,
|
|
|
|
const unsigned char *m, unsigned long long mlen);
|
|
|
|
|
2015-08-12 13:37:49 +01:00
|
|
|
/**
|
|
|
|
* Verifies a given message signature pair under a given public key.
|
2017-10-26 11:10:17 +01:00
|
|
|
* Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
|
2015-08-12 13:37:49 +01:00
|
|
|
*/
|
2017-10-26 11:10:17 +01:00
|
|
|
int xmssmt_core_sign_open(const xmss_params *params,
|
|
|
|
unsigned char *m, unsigned long long *mlen,
|
|
|
|
const unsigned char *sm, unsigned long long smlen,
|
|
|
|
const unsigned char *pk);
|
2015-08-11 11:08:27 +01:00
|
|
|
|
2017-10-26 11:10:17 +01:00
|
|
|
#endif
|