Leancrypto 1.7.2
Post-Quantum Cryptographic Library
Data Structures | Enumerations | Functions
lc_sphincs.h File Reference
#include "ext_headers.h"
#include "lc_status.h"
+ Include dependency graph for lc_sphincs.h:

Go to the source code of this file.

Data Structures

struct  lc_sphincs_sk
 Sphincs secret key. More...
 
struct  lc_sphincs_pk
 Sphincs public key. More...
 
struct  lc_sphincs_sig
 Sphincs signature. More...
 
union  lc_sphincs_sk.key
 
union  lc_sphincs_pk.key
 
union  lc_sphincs_sig.sig
 

Enumerations

enum  lc_sphincs_type {
  LC_SPHINCS_UNKNOWN , LC_SPHINCS_SHAKE_256s , LC_SPHINCS_SHAKE_256f , LC_SPHINCS_SHAKE_192s ,
  LC_SPHINCS_SHAKE_192f , LC_SPHINCS_SHAKE_128s , LC_SPHINCS_SHAKE_128f
}
 
enum  lc_sphincs_alg_operation { lc_alg_operation_sphincs_unknown , lc_alg_operation_sphincs_keygen , lc_alg_operation_sphincs_siggen , lc_alg_operation_sphincs_sigver }
 

Functions

int lc_sphincs_ctx_alloc (struct lc_sphincs_ctx **ctx)
 Allocates Sphincs context on heap. More...
 
void lc_sphincs_ctx_zero_free (struct lc_sphincs_ctx *ctx)
 Zeroizes and frees Sphincs context on heap. More...
 
void lc_sphincs_ctx_zero (struct lc_sphincs_ctx *ctx)
 Zeroizes Sphincs context either on heap or on stack. More...
 
void lc_sphincs_ctx_internal (struct lc_sphincs_ctx *ctx)
 Mark the Sphincs context to execute SLH-DSA.Sign_internal / SLH-DSA.Verify_internal. More...
 
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 HashSLH-DSA. The message digest is to be provided via the message pointer in the sign/verify APIs. More...
 
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. More...
 
enum lc_sphincs_type lc_sphincs_sk_type (const struct lc_sphincs_sk *sk)
 Obtain Sphincs type from secret key. More...
 
enum lc_sphincs_type lc_sphincs_pk_type (const struct lc_sphincs_pk *pk)
 Obtain Sphincs type from public key. More...
 
enum lc_sphincs_type lc_sphincs_sig_type (const struct lc_sphincs_sig *sig)
 Obtain Sphincs type from signature. More...
 
LC_PURE unsigned int lc_sphincs_sk_size (enum lc_sphincs_type sphincs_type)
 Return the size of the Sphincs secret key. More...
 
LC_PURE unsigned int lc_sphincs_pk_size (enum lc_sphincs_type sphincs_type)
 Return the size of the Sphincs public key. More...
 
LC_PURE unsigned int lc_sphincs_sig_size (enum lc_sphincs_type sphincs_type)
 Return the size of the Sphincs signature. More...
 
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. More...
 
int lc_sphincs_sk_set_keytype_fast (struct lc_sphincs_sk *sk)
 Set Sphincs key type to fast. More...
 
int lc_sphincs_sk_set_keytype_small (struct lc_sphincs_sk *sk)
 Set Sphincs key type to small. More...
 
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. More...
 
int lc_sphincs_pk_set_keytype_fast (struct lc_sphincs_pk *pk)
 Set Sphincs key type to fast. More...
 
int lc_sphincs_pk_set_keytype_small (struct lc_sphincs_pk *pk)
 Set Sphincs key type to small. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int lc_sphincs_pk_from_sk (struct lc_sphincs_pk *pk, const struct lc_sphincs_sk *sk)
 Generates Sphincs public from private key. More...
 
int lc_sphincs_pct (const struct lc_sphincs_pk *pk, const struct lc_sphincs_sk *sk)
 Pairwise consistency check as per FIPS 140 IG. More...
 
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. More...
 
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. More...
 
int lc_sphincs_sign_init (struct lc_sphincs_ctx *ctx, const struct lc_sphincs_sk *sk)
 Initializes a signature operation. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int lc_sphincs_verify_init (struct lc_sphincs_ctx *ctx, const struct lc_sphincs_pk *pk)
 Initializes a signature verification operation. More...
 
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. More...
 
int lc_sphincs_verify_final (const struct lc_sphincs_sig *sig, struct lc_sphincs_ctx *ctx, const struct lc_sphincs_pk *pk)
 Verifies signature. More...
 
enum lc_alg_status_val lc_sphincs_alg_status (const enum lc_sphincs_type sphincs_type, const enum lc_sphincs_alg_operation operation)
 Obtain algorithm status. More...
 

Data Structure Documentation

◆ lc_sphincs_sk

struct lc_sphincs_sk

Sphincs secret key.

Definition at line 128 of file lc_sphincs.h.

Data Fields
union lc_sphincs_sk.key key
enum lc_sphincs_type sphincs_type

◆ lc_sphincs_pk

struct lc_sphincs_pk

Sphincs public key.

Definition at line 155 of file lc_sphincs.h.

Data Fields
union lc_sphincs_pk.key key
enum lc_sphincs_type sphincs_type

◆ lc_sphincs_sig

struct lc_sphincs_sig

Sphincs signature.

Definition at line 182 of file lc_sphincs.h.

Data Fields
union lc_sphincs_sig.sig sig
enum lc_sphincs_type sphincs_type

◆ lc_sphincs_sk.key

union lc_sphincs_sk.key

Definition at line 130 of file lc_sphincs.h.

◆ lc_sphincs_pk.key

union lc_sphincs_pk.key

Definition at line 157 of file lc_sphincs.h.

◆ lc_sphincs_sig.sig

union lc_sphincs_sig.sig

Definition at line 184 of file lc_sphincs.h.

Enumeration Type Documentation

◆ lc_sphincs_alg_operation

Enumerator
lc_alg_operation_sphincs_unknown 

Unknown operation

lc_alg_operation_sphincs_keygen 

ML-DSA: key generation operation

lc_alg_operation_sphincs_siggen 

ML-DSA: signature generation operation

lc_alg_operation_sphincs_sigver 

ML-DSA: signature generation operation

Definition at line 773 of file lc_sphincs.h.

◆ lc_sphincs_type

Enumerator
LC_SPHINCS_UNKNOWN 

Unknown key type

LC_SPHINCS_SHAKE_256s 

Sphincs 256s using SHAKE for signature operation

LC_SPHINCS_SHAKE_256f 

Sphincs 256f using SHAKE for signature operation

LC_SPHINCS_SHAKE_192s 

Sphincs 192s using SHAKE for signature operation

LC_SPHINCS_SHAKE_192f 

Sphincs 192f using SHAKE for signature operation

LC_SPHINCS_SHAKE_128s 

Sphincs 128s using SHAKE for signature operation

LC_SPHINCS_SHAKE_128f 

Sphincs 128f using SHAKE for signature operation

Definition at line 67 of file lc_sphincs.h.

Function Documentation

◆ lc_sphincs_pct()

int lc_sphincs_pct ( const struct lc_sphincs_pk *  pk,
const struct lc_sphincs_sk *  sk 
)

Pairwise consistency check as per FIPS 140 IG.

This call should be invoked after generating a key pair in FIPS mode

Parameters
[in]pkPublic key
[in]skSecret key
Returns
0 on success, < 0 on error