31#include "ext_headers.h"
33#if defined __has_include
34#if __has_include("lc_sphincs_shake_256s.h")
36#define LC_SPHINCS_SHAKE_256s_ENABLED
38#if __has_include("lc_sphincs_shake_256f.h")
40#define LC_SPHINCS_SHAKE_256f_ENABLED
42#if __has_include("lc_sphincs_shake_192s.h")
44#define LC_SPHINCS_SHAKE_192s_ENABLED
46#if __has_include("lc_sphincs_shake_192f.h")
48#define LC_SPHINCS_SHAKE_192f_ENABLED
50#if __has_include("lc_sphincs_shake_128s.h")
52#define LC_SPHINCS_SHAKE_128s_ENABLED
54#if __has_include("lc_sphincs_shake_128f.h")
56#define LC_SPHINCS_SHAKE_128f_ENABLED
59#error "Compiler misses __has_include"
130#ifdef LC_SPHINCS_SHAKE_256s_ENABLED
133#ifdef LC_SPHINCS_SHAKE_256f_ENABLED
136#ifdef LC_SPHINCS_SHAKE_192s_ENABLED
139#ifdef LC_SPHINCS_SHAKE_192f_ENABLED
142#ifdef LC_SPHINCS_SHAKE_128s_ENABLED
145#ifdef LC_SPHINCS_SHAKE_128f_ENABLED
157#ifdef LC_SPHINCS_SHAKE_256s_ENABLED
160#ifdef LC_SPHINCS_SHAKE_256f_ENABLED
163#ifdef LC_SPHINCS_SHAKE_192s_ENABLED
166#ifdef LC_SPHINCS_SHAKE_192f_ENABLED
169#ifdef LC_SPHINCS_SHAKE_128s_ENABLED
172#ifdef LC_SPHINCS_SHAKE_128f_ENABLED
184#ifdef LC_SPHINCS_SHAKE_256s_ENABLED
187#ifdef LC_SPHINCS_SHAKE_256f_ENABLED
190#ifdef LC_SPHINCS_SHAKE_192s_ENABLED
193#ifdef LC_SPHINCS_SHAKE_192f_ENABLED
196#ifdef LC_SPHINCS_SHAKE_128s_ENABLED
199#ifdef LC_SPHINCS_SHAKE_128f_ENABLED
488 struct lc_rng_ctx *rng_ctx,
574 const uint8_t *m,
size_t mlen,
576 struct lc_rng_ctx *rng_ctx);
650 struct lc_rng_ctx *rng_ctx);
int lc_hash(const struct lc_hash *hash, const uint8_t *in, size_t inlen, uint8_t *digest)
Calculate message digest - one-shot.
int lc_sphincs_sign_init(struct lc_sphincs_ctx *ctx, const struct lc_sphincs_sk *sk)
Initializes a signature operation.
int lc_sphincs_verify(const struct lc_sphincs_sig *sig, const uint8_t *m, size_t mlen, const struct lc_sphincs_pk *pk)
Verifies signature in one shot.
enum lc_sphincs_type lc_sphincs_sk_type(const struct lc_sphincs_sk *sk)
Obtain Sphincs type from secret key.
int lc_sphincs_pk_ptr(uint8_t **sphincs_key, size_t *sphincs_key_len, struct lc_sphincs_pk *pk)
Obtain the reference to the Sphincs key and its length.
int lc_sphincs_verify_final(const struct lc_sphincs_sig *sig, struct lc_sphincs_ctx *ctx, const struct lc_sphincs_pk *pk)
Verifies signature.
int lc_sphincs_keypair(struct lc_sphincs_pk *pk, struct lc_sphincs_sk *sk, struct lc_rng_ctx *rng_ctx, enum lc_sphincs_type sphincs_type)
Generates Sphincs public and private key.
int lc_sphincs_sign_update(struct lc_sphincs_ctx *ctx, const uint8_t *m, size_t mlen)
Add more data to an already initialized signature state.
int lc_sphincs_verify_ctx(const struct lc_sphincs_sig *sig, struct lc_sphincs_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_sphincs_pk *pk)
Verifies signature with Sphincs context in one shot.
int lc_sphincs_pk_load(struct lc_sphincs_pk *pk, const uint8_t *src_key, size_t src_key_len)
Load a Sphincs public key provided with a buffer into the leancrypto data structure.
int lc_sphincs_sig_ptr(uint8_t **sphincs_sig, size_t *sphincs_sig_len, struct lc_sphincs_sig *sig)
Obtain the reference to the Sphincs signature and its length.
int lc_sphincs_sk_set_keytype_fast(struct lc_sphincs_sk *sk)
Set Sphincs key type to fast.
int lc_sphincs_sign_ctx(struct lc_sphincs_sig *sig, struct lc_sphincs_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_sphincs_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature woth user context in one shot.
void lc_sphincs_ctx_hash(struct lc_sphincs_ctx *ctx, const struct lc_hash *hash)
Set the hash type that was used for pre-hashing the message. The message digest is used with the Hash...
int lc_sphincs_sk_set_keytype_small(struct lc_sphincs_sk *sk)
Set Sphincs key type to small.
LC_PURE unsigned int lc_sphincs_sk_size(enum lc_sphincs_type sphincs_type)
Return the size of the Sphincs secret key.
void lc_sphincs_ctx_userctx(struct lc_sphincs_ctx *ctx, const uint8_t *userctx, size_t userctxlen)
Specify the optional user context string to be applied with the Sphincs signature operation.
int lc_sphincs_sig_load(struct lc_sphincs_sig *sig, const uint8_t *src_sig, size_t src_sig_len)
Load a Sphincs signature provided with a buffer into the leancrypto data structure.
int lc_sphincs_sk_load(struct lc_sphincs_sk *sk, const uint8_t *src_key, size_t src_key_len)
Load a Sphincs secret key provided with a buffer into the leancrypto data structure.
int lc_sphincs_sign_final(struct lc_sphincs_sig *sig, struct lc_sphincs_ctx *ctx, const struct lc_sphincs_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature.
int lc_sphincs_keypair_from_seed(struct lc_sphincs_pk *pk, struct lc_sphincs_sk *sk, const uint8_t *seed, size_t seedlen, enum lc_sphincs_type sphincs_type)
Generates Sphincs public and private key from a given seed.
int lc_sphincs_pk_set_keytype_small(struct lc_sphincs_pk *pk)
Set Sphincs key type to small.
void lc_sphincs_ctx_zero_free(struct lc_sphincs_ctx *ctx)
Zeroizes and frees Sphincs context on heap.
int lc_sphincs_pk_set_keytype_fast(struct lc_sphincs_pk *pk)
Set Sphincs key type to fast.
int lc_sphincs_sk_ptr(uint8_t **sphincs_key, size_t *sphincs_key_len, struct lc_sphincs_sk *sk)
Obtain the reference to the Sphincs key and its length.
int lc_sphincs_ctx_alloc(struct lc_sphincs_ctx **ctx)
Allocates Sphincs context on heap.
int lc_sphincs_verify_init(struct lc_sphincs_ctx *ctx, const struct lc_sphincs_pk *pk)
Initializes a signature verification operation.
int lc_sphincs_sign(struct lc_sphincs_sig *sig, const uint8_t *m, size_t mlen, const struct lc_sphincs_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature in one shot.
LC_PURE unsigned int lc_sphincs_pk_size(enum lc_sphincs_type sphincs_type)
Return the size of the Sphincs public key.
int lc_sphincs_verify_update(struct lc_sphincs_ctx *ctx, const uint8_t *m, size_t mlen)
Add more data to an already initialized signature state.
void lc_sphincs_ctx_zero(struct lc_sphincs_ctx *ctx)
Zeroizes Sphincs context either on heap or on stack.
enum lc_sphincs_type lc_sphincs_pk_type(const struct lc_sphincs_pk *pk)
Obtain Sphincs type from public key.
void lc_sphincs_ctx_internal(struct lc_sphincs_ctx *ctx)
Mark the Sphincs context to execute SLH-DSA.Sign_internal / SLH-DSA.Verify_internal.
LC_PURE unsigned int lc_sphincs_sig_size(enum lc_sphincs_type sphincs_type)
Return the size of the Sphincs signature.
enum lc_sphincs_type lc_sphincs_sig_type(const struct lc_sphincs_sig *sig)
Obtain Sphincs type from signature.
enum lc_sphincs_type sphincs_type
union lc_sphincs_pk::@326231214261337372240341247366131072053320224026 key
union lc_sphincs_sk::@264262264322156246104063265222263154340010311235 key
enum lc_sphincs_type sphincs_type
union lc_sphincs_sig::@053032136164360237044025143141001047257273346115 sig
int lc_sphincs_pct(const struct lc_sphincs_pk *pk, const struct lc_sphincs_sk *sk)
Pairwise consistency check as per FIPS 140 IG.
enum lc_sphincs_type sphincs_type