xref: /dflybsd-src/crypto/openssh/xmss_wots.h (revision ba1276acd1c8c22d225b1bcf370a14c878644f44)
1*ba1276acSMatthew Dillon #ifdef WITH_XMSS
2*ba1276acSMatthew Dillon /* $OpenBSD: xmss_wots.h,v 1.3 2018/02/26 12:14:53 dtucker Exp $ */
3*ba1276acSMatthew Dillon /*
4*ba1276acSMatthew Dillon wots.h version 20160722
5*ba1276acSMatthew Dillon Andreas Hülsing
6*ba1276acSMatthew Dillon Joost Rijneveld
7*ba1276acSMatthew Dillon Public domain.
8*ba1276acSMatthew Dillon */
9*ba1276acSMatthew Dillon 
10*ba1276acSMatthew Dillon #ifndef WOTS_H
11*ba1276acSMatthew Dillon #define WOTS_H
12*ba1276acSMatthew Dillon 
13*ba1276acSMatthew Dillon #ifdef HAVE_STDINT_H
14*ba1276acSMatthew Dillon #include "stdint.h"
15*ba1276acSMatthew Dillon #endif
16*ba1276acSMatthew Dillon 
17*ba1276acSMatthew Dillon /**
18*ba1276acSMatthew Dillon  * WOTS parameter set
19*ba1276acSMatthew Dillon  *
20*ba1276acSMatthew Dillon  * Meaning as defined in draft-irtf-cfrg-xmss-hash-based-signatures-02
21*ba1276acSMatthew Dillon  */
22*ba1276acSMatthew Dillon typedef struct {
23*ba1276acSMatthew Dillon   uint32_t len_1;
24*ba1276acSMatthew Dillon   uint32_t len_2;
25*ba1276acSMatthew Dillon   uint32_t len;
26*ba1276acSMatthew Dillon   uint32_t n;
27*ba1276acSMatthew Dillon   uint32_t w;
28*ba1276acSMatthew Dillon   uint32_t log_w;
29*ba1276acSMatthew Dillon   uint32_t keysize;
30*ba1276acSMatthew Dillon } wots_params;
31*ba1276acSMatthew Dillon 
32*ba1276acSMatthew Dillon /**
33*ba1276acSMatthew Dillon  * Set the WOTS parameters,
34*ba1276acSMatthew Dillon  * only m, n, w are required as inputs,
35*ba1276acSMatthew Dillon  * len, len_1, and len_2 are computed from those.
36*ba1276acSMatthew Dillon  *
37*ba1276acSMatthew Dillon  * Assumes w is a power of 2
38*ba1276acSMatthew Dillon  */
39*ba1276acSMatthew Dillon void wots_set_params(wots_params *params, int n, int w);
40*ba1276acSMatthew Dillon 
41*ba1276acSMatthew Dillon /**
42*ba1276acSMatthew Dillon  * 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.
43*ba1276acSMatthew Dillon  * 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
44*ba1276acSMatthew Dillon  *
45*ba1276acSMatthew Dillon  * params, must have been initialized before using wots_set params for params ! This is not done in this function
46*ba1276acSMatthew Dillon  *
47*ba1276acSMatthew Dillon  * Places the computed public key at address pk.
48*ba1276acSMatthew Dillon  */
49*ba1276acSMatthew Dillon void wots_pkgen(unsigned char *pk, const unsigned char *sk, const wots_params *params, const unsigned char *pub_seed, uint32_t addr[8]);
50*ba1276acSMatthew Dillon 
51*ba1276acSMatthew Dillon /**
52*ba1276acSMatthew Dillon  * Takes a m-byte message and the 32-byte seed for the secret key to compute a signature that is placed at "sig".
53*ba1276acSMatthew Dillon  *
54*ba1276acSMatthew Dillon  */
55*ba1276acSMatthew Dillon 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]);
56*ba1276acSMatthew Dillon 
57*ba1276acSMatthew Dillon /**
58*ba1276acSMatthew Dillon  * Takes a WOTS signature, a m-byte message and computes a WOTS public key that it places at pk.
59*ba1276acSMatthew Dillon  *
60*ba1276acSMatthew Dillon  */
61*ba1276acSMatthew Dillon 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]);
62*ba1276acSMatthew Dillon 
63*ba1276acSMatthew Dillon #endif
64*ba1276acSMatthew Dillon #endif /* WITH_XMSS */
65