59d304027c
This allows different backends to store additional state information in the secret key while the rest of the codebase remains agnostic. In particular, this prepares for a common xmss_core.h API for both the standard and the BDS-traversal-based implementations.
73 rindas
2.7 KiB
C
73 rindas
2.7 KiB
C
#ifndef XMSS_CORE_H
|
|
#define XMSS_CORE_H
|
|
|
|
#include "params.h"
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
unsigned long long xmss_core_sk_bytes(const xmss_params *params);
|
|
|
|
/*
|
|
* Generates a XMSS key pair for a given parameter set.
|
|
* Format sk: [(32bit) index || SK_SEED || SK_PRF || PUB_SEED || root]
|
|
* Format pk: [root || PUB_SEED], omitting algorithm OID.
|
|
*/
|
|
int xmss_core_keypair(const xmss_params *params,
|
|
unsigned char *pk, unsigned char *sk);
|
|
|
|
/**
|
|
* Signs a message. Returns an array containing the signature followed by the
|
|
* message and an updated secret key.
|
|
*/
|
|
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);
|
|
|
|
/**
|
|
* Verifies a given message signature pair under a given public key.
|
|
* Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
|
|
*/
|
|
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);
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
unsigned long long xmssmt_core_sk_bytes(const xmss_params *params);
|
|
|
|
/*
|
|
* Generates a XMSSMT key pair for a given parameter set.
|
|
* Format sk: [(ceil(h/8) bit) index || SK_SEED || SK_PRF || PUB_SEED]
|
|
* Format pk: [root || PUB_SEED] omitting algorithm OID.
|
|
*/
|
|
int xmssmt_core_keypair(const xmss_params *params,
|
|
unsigned char *pk, unsigned char *sk);
|
|
|
|
/**
|
|
* Signs a message. Returns an array containing the signature followed by the
|
|
* message and an updated secret key.
|
|
*/
|
|
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);
|
|
|
|
/**
|
|
* Verifies a given message signature pair under a given public key.
|
|
* Note that this assumes a pk without an OID, i.e. [root || PUB_SEED]
|
|
*/
|
|
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);
|
|
|
|
#endif
|