1*ffae97bbSchristos /* $NetBSD: xmss_wots.h,v 1.2 2018/04/06 18:59:00 christos Exp $ */ 2ad340bdfSchristos /* $OpenBSD: xmss_wots.h,v 1.3 2018/02/26 12:14:53 dtucker Exp $ */ 3ad340bdfSchristos /* 4ad340bdfSchristos wots.h version 20160722 5ad340bdfSchristos Andreas Hülsing 6ad340bdfSchristos Joost Rijneveld 7ad340bdfSchristos Public domain. 8ad340bdfSchristos */ 9ad340bdfSchristos 10ad340bdfSchristos #ifndef WOTS_H 11ad340bdfSchristos #define WOTS_H 12ad340bdfSchristos 13ad340bdfSchristos /** 14ad340bdfSchristos * WOTS parameter set 15ad340bdfSchristos * 16ad340bdfSchristos * Meaning as defined in draft-irtf-cfrg-xmss-hash-based-signatures-02 17ad340bdfSchristos */ 18ad340bdfSchristos typedef struct { 19ad340bdfSchristos uint32_t len_1; 20ad340bdfSchristos uint32_t len_2; 21ad340bdfSchristos uint32_t len; 22ad340bdfSchristos uint32_t n; 23ad340bdfSchristos uint32_t w; 24ad340bdfSchristos uint32_t log_w; 25ad340bdfSchristos uint32_t keysize; 26ad340bdfSchristos } wots_params; 27ad340bdfSchristos 28ad340bdfSchristos /** 29ad340bdfSchristos * Set the WOTS parameters, 30ad340bdfSchristos * only m, n, w are required as inputs, 31ad340bdfSchristos * len, len_1, and len_2 are computed from those. 32ad340bdfSchristos * 33ad340bdfSchristos * Assumes w is a power of 2 34ad340bdfSchristos */ 35ad340bdfSchristos void wots_set_params(wots_params *params, int n, int w); 36ad340bdfSchristos 37ad340bdfSchristos /** 38ad340bdfSchristos * WOTS key generation. Takes a 32byte seed for the secret key, expands it to a full WOTS secret key and computes the corresponding public key. 39ad340bdfSchristos * For this it takes the seed pub_seed which is used to generate bitmasks and hash keys and the address of this WOTS key pair addr 40ad340bdfSchristos * 41ad340bdfSchristos * params, must have been initialized before using wots_set params for params ! This is not done in this function 42ad340bdfSchristos * 43ad340bdfSchristos * Places the computed public key at address pk. 44ad340bdfSchristos */ 45ad340bdfSchristos void wots_pkgen(unsigned char *pk, const unsigned char *sk, const wots_params *params, const unsigned char *pub_seed, uint32_t addr[8]); 46ad340bdfSchristos 47ad340bdfSchristos /** 48ad340bdfSchristos * Takes a m-byte message and the 32-byte seed for the secret key to compute a signature that is placed at "sig". 49ad340bdfSchristos * 50ad340bdfSchristos */ 51ad340bdfSchristos int wots_sign(unsigned char *sig, const unsigned char *msg, const unsigned char *sk, const wots_params *params, const unsigned char *pub_seed, uint32_t addr[8]); 52ad340bdfSchristos 53ad340bdfSchristos /** 54ad340bdfSchristos * Takes a WOTS signature, a m-byte message and computes a WOTS public key that it places at pk. 55ad340bdfSchristos * 56ad340bdfSchristos */ 57ad340bdfSchristos int wots_pkFromSig(unsigned char *pk, const unsigned char *sig, const unsigned char *msg, const wots_params *params, const unsigned char *pub_seed, uint32_t addr[8]); 58ad340bdfSchristos 59ad340bdfSchristos #endif 60