xmss-KAT-generator/xmss.h

85 lines
2.7 KiB
C
Raw Normal View History

/*
2016-09-22 15:31:41 +01:00
xmss.h version 20160722
Andreas Hülsing
Joost Rijneveld
Public domain.
*/
2015-08-11 11:08:27 +01:00
#include "wots.h"
#ifndef XMSS_H
#define XMSS_H
typedef struct{
unsigned int level;
2015-08-11 11:08:27 +01:00
unsigned long long subtree;
unsigned int subleaf;
2015-08-11 11:08:27 +01:00
} leafaddr;
typedef struct{
2015-08-12 13:37:49 +01:00
wots_params wots_par;
unsigned int n;
unsigned int h;
unsigned char hash_alg;
2015-08-11 11:08:27 +01:00
} xmss_params;
2015-08-12 13:37:49 +01:00
typedef struct{
xmss_params xmss_par;
unsigned int n;
unsigned int h;
unsigned int d;
unsigned int index_len;
2015-08-12 13:37:49 +01:00
} xmssmt_params;
2015-08-11 11:08:27 +01:00
/**
* Initializes parameter set.
* Needed, for any of the other methods.
*/
void xmss_set_params(xmss_params *params, int n, int h, int w, unsigned char hash_alg);
2015-08-12 13:37:49 +01:00
/**
* Initialize xmssmt_params struct
* parameter names are the same as in the draft
*
* Especially h is the total tree height, i.e. the XMSS trees have height h/d
*/
void xmssmt_set_params(xmssmt_params *params, int n, int h, int d, int w, unsigned char hash_alg);
2015-08-11 11:08:27 +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-11 11:08:27 +01:00
* Format pk: [root || PUB_SEED] omitting algo oid.
*/
int xmss_keypair(unsigned char *pk, unsigned char *sk, xmss_params *params);
/**
* Signs a message.
* Returns
* 1. an array containing the signature followed by the message AND
* 2. an updated secret key!
*
*/
2015-08-12 13:37:49 +01:00
int xmss_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen, const xmss_params *params);
2015-08-11 11:08:27 +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).
*/
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, const xmss_params *params);
2015-08-12 13:37:49 +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-12 13:37:49 +01:00
* Format pk: [root || PUB_SEED] omitting algo oid.
*/
int xmssmt_keypair(unsigned char *pk, unsigned char *sk, xmssmt_params *params);
/**
* Signs a message.
* Returns
* 1. an array containing the signature followed by the message AND
* 2. an updated secret key!
*
*/
int xmssmt_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen, const xmssmt_params *params);
/**
* Verifies a given message signature pair under a given public key.
*/
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, const xmssmt_params *params);
2015-08-11 11:08:27 +01:00
#endif