28#ifndef LC_DILITHIUM_87_H
29#define LC_DILITHIUM_87_H
33#include "ext_headers.h"
52#define LC_DILITHIUM_MODE 5
54#define LC_DILITHIUM_SEEDBYTES 32
55#define LC_DILITHIUM_CRHBYTES 64
56#define LC_DILITHIUM_TRBYTES 64
57#define LC_DILITHIUM_RNDBYTES 32
58#define LC_DILITHIUM_N 256
59#define LC_DILITHIUM_Q 8380417
60#define LC_DILITHIUM_D 13
61#define LC_DILITHIUM_ROOT_OF_UNITY 1753
63#if LC_DILITHIUM_MODE == 2
64#define LC_DILITHIUM_NIST_CATEGORY 1
65#define LC_DILITHIUM_LAMBDA 128
66#define LC_DILITHIUM_K 4
67#define LC_DILITHIUM_L 4
68#define LC_DILITHIUM_ETA 2
69#define LC_DILITHIUM_TAU 39
70#define LC_DILITHIUM_BETA 78
71#define LC_DILITHIUM_GAMMA1 (1 << 17)
72#define LC_DILITHIUM_GAMMA2 ((LC_DILITHIUM_Q - 1) / 88)
73#define LC_DILITHIUM_OMEGA 80
75#elif LC_DILITHIUM_MODE == 3
76#define LC_DILITHIUM_NIST_CATEGORY 3
77#define LC_DILITHIUM_LAMBDA 192
78#define LC_DILITHIUM_K 6
79#define LC_DILITHIUM_L 5
80#define LC_DILITHIUM_ETA 4
81#define LC_DILITHIUM_TAU 49
82#define LC_DILITHIUM_BETA 196
83#define LC_DILITHIUM_GAMMA1 (1 << 19)
84#define LC_DILITHIUM_GAMMA2 ((LC_DILITHIUM_Q - 1) / 32)
85#define LC_DILITHIUM_OMEGA 55
87#elif LC_DILITHIUM_MODE == 5
88#define LC_DILITHIUM_NIST_CATEGORY 5
89#define LC_DILITHIUM_LAMBDA 256
90#define LC_DILITHIUM_K 8
91#define LC_DILITHIUM_L 7
92#define LC_DILITHIUM_ETA 2
93#define LC_DILITHIUM_TAU 60
94#define LC_DILITHIUM_BETA 120
95#define LC_DILITHIUM_GAMMA1 (1 << 19)
96#define LC_DILITHIUM_GAMMA2 ((LC_DILITHIUM_Q - 1) / 32)
97#define LC_DILITHIUM_OMEGA 75
101#define LC_DILITHIUM_CTILDE_BYTES (LC_DILITHIUM_LAMBDA * 2 / 8)
102#define LC_DILITHIUM_POLYT1_PACKEDBYTES 320
103#define LC_DILITHIUM_POLYT0_PACKEDBYTES 416
104#define LC_DILITHIUM_POLYVECH_PACKEDBYTES (LC_DILITHIUM_OMEGA + LC_DILITHIUM_K)
106#if LC_DILITHIUM_GAMMA1 == (1 << 17)
107#define LC_DILITHIUM_POLYZ_PACKEDBYTES 576
108#elif LC_DILITHIUM_GAMMA1 == (1 << 19)
109#define LC_DILITHIUM_POLYZ_PACKEDBYTES 640
112#if LC_DILITHIUM_GAMMA2 == (LC_DILITHIUM_Q - 1) / 88
113#define LC_DILITHIUM_POLYW1_PACKEDBYTES 192
114#elif LC_DILITHIUM_GAMMA2 == (LC_DILITHIUM_Q - 1) / 32
115#define LC_DILITHIUM_POLYW1_PACKEDBYTES 128
118#if LC_DILITHIUM_ETA == 2
119#define LC_DILITHIUM_POLYETA_PACKEDBYTES 96
120#elif LC_DILITHIUM_ETA == 4
121#define LC_DILITHIUM_POLYETA_PACKEDBYTES 128
132#define LC_DILITHIUM_PUBLICKEYBYTES \
133 (LC_DILITHIUM_SEEDBYTES + \
134 LC_DILITHIUM_K * LC_DILITHIUM_POLYT1_PACKEDBYTES)
135#define LC_DILITHIUM_SECRETKEYBYTES \
136 (2 * LC_DILITHIUM_SEEDBYTES + LC_DILITHIUM_TRBYTES + \
137 LC_DILITHIUM_L * LC_DILITHIUM_POLYETA_PACKEDBYTES + \
138 LC_DILITHIUM_K * LC_DILITHIUM_POLYETA_PACKEDBYTES + \
139 LC_DILITHIUM_K * LC_DILITHIUM_POLYT0_PACKEDBYTES)
141#define LC_DILITHIUM_CRYPTO_BYTES \
142 (LC_DILITHIUM_CTILDE_BYTES + \
143 LC_DILITHIUM_L * LC_DILITHIUM_POLYZ_PACKEDBYTES + \
144 LC_DILITHIUM_POLYVECH_PACKEDBYTES)
152 uint8_t
sk[LC_DILITHIUM_SECRETKEYBYTES];
159 uint8_t
pk[LC_DILITHIUM_PUBLICKEYBYTES];
166 uint8_t
sig[LC_DILITHIUM_CRYPTO_BYTES];
169#ifndef LC_DILITHIUM_CTX_ON_STACK
181 uint8_t
shake_state[LC_HASH_STATE_SIZE_ALIGN(LC_SHA3_256_STATE_SIZE)];
275#define LC_DILITHIUM_AHAT_ALIGNMENT (32)
281#define LC_DILITHIUM_87_AHAT_PAD \
282 (LC_DILITHIUM_AHAT_ALIGNMENT - \
283 (sizeof(struct lc_dilithium_ctx) % LC_DILITHIUM_AHAT_ALIGNMENT))
286#define LC_DILITHIUM_87_AHAT_SIZE \
287 (256 * sizeof(int32_t) * LC_DILITHIUM_K * LC_DILITHIUM_L)
289#ifndef LC_DILITHIUM_CTX_ON_STACK
290#define LC_DILITHIUM_CTX_SIZE \
291 sizeof(struct lc_dilithium_ctx)
293#define LC_DILITHIUM_CTX_INIT_HASH(name) \
294 LC_SHAKE_256_CTX((&(name)->dilithium_hash_ctx))
296#define LC_DILITHIUM_SET_CTX_COMMON(name) \
297 (name)->dilithium_prehash_type = NULL; \
298 (name)->ml_dsa_internal = 0; \
299 (name)->userctxlen = 0; \
300 (name)->userctx = NULL; \
301 (name)->ahat = NULL; \
302 (name)->ahat_size = 0; \
303 (name)->external_mu = NULL; \
304 (name)->external_mu_len = 0; \
305 (name)->nist_category = 0; \
306 (name)->composite_algorithm = 0;
308#define LC_DILITHIUM_SET_CTX(name) \
309 LC_DILITHIUM_CTX_INIT_HASH(name); \
310 LC_DILITHIUM_SET_CTX_COMMON(name)
321#ifndef LC_DILITHIUM_CTX_ON_STACK
322#define LC_DILITHIUM_CTX_ON_STACK(name) \
323 _Pragma("GCC diagnostic push") _Pragma( \
324 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
326 name##_ctx_buf, LC_DILITHIUM_CTX_SIZE, \
327 LC_HASH_COMMON_ALIGNMENT); \
328 struct lc_dilithium_ctx *name = \
329 (struct lc_dilithium_ctx *)name##_ctx_buf; \
330 LC_DILITHIUM_SET_CTX(name); \
331 _Pragma("GCC diagnostic pop")
374#define LC_DILITHIUM_87_CTX_ON_STACK_AHAT(name) \
375 _Pragma("GCC diagnostic push") _Pragma( \
376 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
378 name##_ctx_buf, LC_DILITHIUM_CTX_SIZE + \
379 LC_DILITHIUM_87_AHAT_PAD + LC_DILITHIUM_87_AHAT_SIZE, \
380 LC_HASH_COMMON_ALIGNMENT); \
381 struct lc_dilithium_ctx *name = \
382 (struct lc_dilithium_ctx *)name##_ctx_buf; \
383 LC_DILITHIUM_SET_CTX(name); \
384 name->ahat = (uint8_t *)name + LC_DILITHIUM_CTX_SIZE + \
385 LC_DILITHIUM_87_AHAT_PAD; \
386 name->ahat_expanded = 0; \
387 name->ahat_size = LC_DILITHIUM_87_AHAT_SIZE; \
388 _Pragma("GCC diagnostic pop")
472 struct lc_rng_ctx *rng_ctx);
506 const uint8_t *seed,
size_t seedlen);
523 struct lc_rng_ctx *rng_ctx);
544 const uint8_t *m,
size_t mlen,
546 struct lc_rng_ctx *rng_ctx);
598 struct lc_rng_ctx *rng_ctx);
631 const uint8_t *m,
size_t mlen,
687#define LC_DILITHIUM_ED25519_SIG
688#ifdef LC_DILITHIUM_ED25519_SIG
690#include "lc_ed25519.h"
723#ifndef LC_DILITHIUM_ED25519_CTX_ON_STACK
730#ifndef LC_DILITHIUM_ED25519_CTX_ON_STACK
731#define LC_DILITHIUM_ED25519_CTX_SIZE \
732 sizeof(struct lc_dilithium_ed25519_ctx)
735#define LC_DILITHIUM_ED25519_CTX_INIT_HASH(name) \
736 LC_SHA512_CTX((&(name)->dilithium_ctx.dilithium_hash_ctx))
738#define LC_DILITHIUM_ED25519_CTX_INIT_HASH(name) \
739 LC_SHAKE_256_CTX(((&(name)->dilithium_ctx.dilithium_hash_ctx))
741#define LC_DILITHIUM_ED25519_SET_CTX(name) \
742 LC_DILITHIUM_SET_CTX_COMMON(&(name)->dilithium_ctx); \
743 LC_DILITHIUM_ED25519_CTX_INIT_HASH(name); \
744 (name)->dilithium_ctx.composite_algorithm = 1
753#ifndef LC_DILITHIUM_ED25519_CTX_ON_STACK
754#define LC_DILITHIUM_ED25519_CTX_ON_STACK(name) \
755 _Pragma("GCC diagnostic push") _Pragma( \
756 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
758 name##_ctx_buf, LC_DILITHIUM_ED25519_CTX_SIZE, \
759 LC_HASH_COMMON_ALIGNMENT); \
760 struct lc_dilithium_ed25519_ctx *name = \
761 (struct lc_dilithium_ed25519_ctx *)name##_ctx_buf; \
762 LC_DILITHIUM_ED25519_SET_CTX(name); \
763 _Pragma("GCC diagnostic pop")
809 struct lc_rng_ctx *rng_ctx);
837 const uint8_t *m,
size_t mlen,
839 struct lc_rng_ctx *rng_ctx);
860 const uint8_t *m,
size_t mlen,
862 struct lc_rng_ctx *rng_ctx);
923 struct lc_rng_ctx *rng_ctx);
937 const uint8_t *m,
size_t mlen,
957 const uint8_t *m,
size_t mlen,
1021#define LC_DILITHIUM_ED448_SIG
1022#ifdef LC_DILITHIUM_ED448_SIG
1024#include "lc_ed448.h"
1056#ifndef LC_DILITHIUM_ED448_CTX_ON_STACK
1063#ifndef LC_DILITHIUM_ED448_CTX_ON_STACK
1064#define LC_DILITHIUM_ED448_CTX_SIZE \
1065 sizeof(struct lc_dilithium_ed448_ctx)
1066#define LC_DILITHIUM_ED448_SET_CTX(name) \
1067 LC_DILITHIUM_SET_CTX(&(name)->dilithium_ctx); \
1068 (name)->dilithium_ctx.composite_algorithm = 1;
1077#ifndef LC_DILITHIUM_ED448_CTX_ON_STACK
1078#define LC_DILITHIUM_ED448_CTX_ON_STACK(name) \
1079 _Pragma("GCC diagnostic push") _Pragma( \
1080 "GCC diagnostic ignored \"-Wdeclaration-after-statement\"") \
1081 LC_ALIGNED_BUFFER( \
1082 name##_ctx_buf, LC_DILITHIUM_ED448_CTX_SIZE, \
1083 LC_HASH_COMMON_ALIGNMENT); \
1084 struct lc_dilithium_ed448_ctx *name = \
1085 (struct lc_dilithium_ed448_ctx *)name##_ctx_buf; \
1086 LC_DILITHIUM_ED448_SET_CTX(name); \
1087 _Pragma("GCC diagnostic pop")
1133 struct lc_rng_ctx *rng_ctx);
1161 const uint8_t *m,
size_t mlen,
1163 struct lc_rng_ctx *rng_ctx);
1184 const uint8_t *m,
size_t mlen,
1186 struct lc_rng_ctx *rng_ctx);
1247 struct lc_rng_ctx *rng_ctx);
1261 const uint8_t *m,
size_t mlen,
1281 const uint8_t *m,
size_t mlen,
1350#ifndef LC_DILITHIUM_INTERNAL
1351#undef LC_DILITHIUM_MODE
1352#undef LC_DILITHIUM_NIST_CATEGORY
1353#undef LC_DILITHIUM_SEEDBYTES
1354#undef LC_DILITHIUM_CRHBYTES
1355#undef LC_DILITHIUM_TRBYTES
1356#undef LC_DILITHIUM_RNDBYTES
1357#undef LC_DILITHIUM_N
1358#undef LC_DILITHIUM_Q
1359#undef LC_DILITHIUM_D
1360#undef LC_DILITHIUM_ROOT_OF_UNITY
1361#undef LC_DILITHIUM_LAMBDA
1362#undef LC_DILITHIUM_K
1363#undef LC_DILITHIUM_L
1364#undef LC_DILITHIUM_ETA
1365#undef LC_DILITHIUM_TAU
1366#undef LC_DILITHIUM_BETA
1367#undef LC_DILITHIUM_GAMMA1
1368#undef LC_DILITHIUM_GAMMA2
1369#undef LC_DILITHIUM_OMEGA
1370#undef LC_DILITHIUM_CTILDE_BYTES
1371#undef LC_DILITHIUM_POLYT1_PACKEDBYTES
1372#undef LC_DILITHIUM_POLYT0_PACKEDBYTES
1373#undef LC_DILITHIUM_POLYVECH_PACKEDBYTES
1374#undef LC_DILITHIUM_POLYZ_PACKEDBYTES
1375#undef LC_DILITHIUM_POLYW1_PACKEDBYTES
1376#undef LC_DILITHIUM_POLYETA_PACKEDBYTES
1377#undef LC_DILITHIUM_PUBLICKEYBYTES
1378#undef LC_DILITHIUM_SECRETKEYBYTES
1379#undef LC_DILITHIUM_CRYPTO_BYTES
void lc_hash_zero(struct lc_hash_ctx *hash_ctx)
Zeroize Hash context allocated with either LC_HASH_CTX_ON_STACK or lc_hmac_alloc.
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_dilithium_87_sign_ctx(struct lc_dilithium_87_sig *sig, struct lc_dilithium_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature with Dilithium context in one shot.
struct lc_dilithium_87_sk sk
struct lc_dilithium_87_sig sig
void lc_dilithium_87_ctx_zero_free(struct lc_dilithium_ctx *ctx)
Zeroize and free Dilithium stream context.
unsigned int composite_algorithm
Indicator whether it is a composite algorithm usage. This is used and set internally.
int lc_dilithium_87_verify(const struct lc_dilithium_87_sig *sig, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_pk *pk)
Verifies ML-DSA signature in one shot.
int lc_dilithium_87_ctx_alloc(struct lc_dilithium_ctx **ctx)
Allocate Dilithium stream context on heap.
int lc_dilithium_87_ed25519_sign(struct lc_dilithium_87_ed25519_sig *sig, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed25519_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature in one shot.
int lc_dilithium_87_ed448_sign(struct lc_dilithium_87_ed448_sig *sig, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed448_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature in one shot.
int lc_dilithium_87_ed448_verify_update(struct lc_dilithium_ed448_ctx *ctx, const uint8_t *m, size_t mlen)
Updates signature verification with Dilithium context in stream operation.
struct lc_ed448_sk sk_ed448
static LC_PURE unsigned int lc_dilithium_87_sig_size(void)
Return the size of the Dilithium signature.
uint8_t shake_state[LC_HASH_STATE_SIZE_ALIGN(LC_SHA3_256_STATE_SIZE)]
State memory of the hash context used internally to the library - it should not be touched by the use...
int lc_dilithium_87_keypair(struct lc_dilithium_87_pk *pk, struct lc_dilithium_87_sk *sk, struct lc_rng_ctx *rng_ctx)
Generates Dilithium public and private key.
void lc_dilithium_87_ed25519_ctx_zero_free(struct lc_dilithium_ed25519_ctx *ctx)
Zeroize and free Dilithium-ED25519 stream context.
struct lc_dilithium_87_pk pk
int lc_dilithium_87_ed25519_sign_update(struct lc_dilithium_ed25519_ctx *ctx, const uint8_t *m, size_t mlen)
Updates signature generation with Dilithium context in stream operation.
struct lc_ed25519_sig sig_ed25519
unsigned int ahat_expanded
Was aHat already filled? This is used and set internally.
const uint8_t * external_mu
Pointer to the external mu.
int lc_dilithium_87_ed448_verify_init(struct lc_dilithium_ed448_ctx *ctx, const struct lc_dilithium_87_ed448_pk *pk)
Initiates signature verification with Dilithium context in stream operation.
int lc_dilithium_87_sign_final(struct lc_dilithium_87_sig *sig, struct lc_dilithium_ctx *ctx, const struct lc_dilithium_87_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature.
static LC_PURE unsigned int lc_dilithium_87_pk_size(void)
Return the size of the Dilithium public key.
int lc_dilithium_87_ed448_verify_ctx(const struct lc_dilithium_87_ed448_sig *sig, struct lc_dilithium_ed448_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed448_pk *pk)
Verifies signature in one shot with Dilithium context.
static void lc_dilithium_87_ctx_zero(struct lc_dilithium_ctx *ctx)
Zeroize Dilithium context allocated with LC_DILITHIUM_CTX_ON_STACK lc_dilithium_ed25519_alloc.
struct lc_ed448_pk pk_ed448
static void lc_dilithium_87_ed25519_ctx_zero(struct lc_dilithium_ed25519_ctx *ctx)
Zeroize Dilithium-ED25519 context allocated with LC_DILITHIUM_ED25519_CTX_ON_STACK lc_dilithium_ed255...
int lc_dilithium_87_pk_from_sk(struct lc_dilithium_87_pk *pk, const struct lc_dilithium_87_sk *sk)
Generates Dilithium public from private key.
int lc_dilithium_87_sign_init(struct lc_dilithium_ctx *ctx, const struct lc_dilithium_87_sk *sk)
Initializes a signature operation.
int lc_dilithium_87_ed448_keypair(struct lc_dilithium_87_ed448_pk *pk, struct lc_dilithium_87_ed448_sk *sk, struct lc_rng_ctx *rng_ctx)
Generates Dilithium public and private key.
struct lc_hash_ctx dilithium_hash_ctx
Hash context used internally to the library - it should not be touched by the user.
int lc_dilithium_87_verify_ctx(const struct lc_dilithium_87_sig *sig, struct lc_dilithium_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_pk *pk)
Verifies signature with Dilithium context in one shot.
int lc_dilithium_87_ed25519_sign_init(struct lc_dilithium_ed25519_ctx *ctx, const struct lc_dilithium_87_ed25519_sk *sk)
Initiates signature generation with Dilithium context in stream operation.
unsigned int ml_dsa_internal
When set to true, only the ML-DSA.Sign_internal or ML-DSA.Verify_internal are performed (see FIPS 204...
struct lc_ed448_sig sig_ed448
int lc_dilithium_87_ed448_sign_init(struct lc_dilithium_ed448_ctx *ctx, const struct lc_dilithium_87_ed448_sk *sk)
Initiates signature generation with Dilithium context in stream operation.
int lc_dilithium_87_ed448_sign_update(struct lc_dilithium_ed448_ctx *ctx, const uint8_t *m, size_t mlen)
Updates signature generation with Dilithium context in stream operation.
struct lc_dilithium_ctx dilithium_ctx
int lc_dilithium_87_ed25519_verify(const struct lc_dilithium_87_ed25519_sig *sig, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed25519_pk *pk)
Verifies signature in one shot.
void lc_dilithium_87_ed448_ctx_zero_free(struct lc_dilithium_ed448_ctx *ctx)
Zeroize and free Dilithium-ED448 stream context.
static void lc_dilithium_87_ed448_ctx_zero(struct lc_dilithium_ed448_ctx *ctx)
Zeroize Dilithium-ED448 context allocated with LC_DILITHIUM_ED448_CTX_ON_STACK lc_dilithium_ed448_all...
struct lc_ed25519_pk pk_ed25519
int lc_dilithium_87_ed448_sign_final(struct lc_dilithium_87_ed448_sig *sig, struct lc_dilithium_ed448_ctx *ctx, const struct lc_dilithium_87_ed448_sk *sk, struct lc_rng_ctx *rng_ctx)
Perform signature generation with Dilithium context in stream operation.
int lc_dilithium_87_ed448_sign_ctx(struct lc_dilithium_87_ed448_sig *sig, struct lc_dilithium_ed448_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed448_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature with Dilithium context in one shot.
int lc_dilithium_87_verify_update(struct lc_dilithium_ctx *ctx, const uint8_t *m, size_t mlen)
Add more data to an already initialized signature state.
size_t userctxlen
length of the user context (allowed range between 0 and 255 bytes)
int lc_dilithium_87_ed25519_verify_ctx(const struct lc_dilithium_87_ed25519_sig *sig, struct lc_dilithium_ed25519_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed25519_pk *pk)
Verifies signature in one shot with Dilithium context.
struct lc_dilithium_87_sk sk
int lc_dilithium_87_ed448_verify(const struct lc_dilithium_87_ed448_sig *sig, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed448_pk *pk)
Verifies signature in one shot.
int lc_dilithium_87_sign_update(struct lc_dilithium_ctx *ctx, const uint8_t *m, size_t mlen)
Add more data to an already initialized signature state.
int lc_dilithium_87_ed25519_verify_init(struct lc_dilithium_ed25519_ctx *ctx, const struct lc_dilithium_87_ed25519_pk *pk)
Initiates signature verification with Dilithium context in stream operation.
int lc_dilithium_87_keypair_from_seed(struct lc_dilithium_87_pk *pk, struct lc_dilithium_87_sk *sk, const uint8_t *seed, size_t seedlen)
Generates Dilithium public and private key from a given seed.
int lc_dilithium_87_ed448_ctx_alloc(struct lc_dilithium_ed448_ctx **ctx)
Allocate Dilithium-ED448 stream context on heap.
void * ahat
Pointer to the AHat buffer. This can be provided by the caller or it must be NULL otherwise.
int lc_dilithium_87_ed448_pk_from_sk(struct lc_dilithium_87_ed448_pk *pk, const struct lc_dilithium_87_ed448_sk *sk)
Generates Dilithium public from private key.
uint8_t sig[LC_DILITHIUM_CRYPTO_BYTES]
int lc_dilithium_87_ctx_alloc_ahat(struct lc_dilithium_ctx **ctx)
Allocate Dilithium stream context on heap including additional parameter relevant for the signature o...
struct lc_ed25519_sk sk_ed25519
struct lc_dilithium_ctx dilithium_ctx
int lc_dilithium_87_ed25519_verify_final(const struct lc_dilithium_87_ed25519_sig *sig, struct lc_dilithium_ed25519_ctx *ctx, const struct lc_dilithium_87_ed25519_pk *pk)
Perform signature verification with Dilithium context in stream operation.
int lc_dilithium_87_ed25519_keypair(struct lc_dilithium_87_ed25519_pk *pk, struct lc_dilithium_87_ed25519_sk *sk, struct lc_rng_ctx *rng_ctx)
Generates Dilithium public and private key.
int lc_dilithium_87_sign(struct lc_dilithium_87_sig *sig, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes ML-DSA signature in one shot.
int lc_dilithium_87_ed25519_pk_from_sk(struct lc_dilithium_87_ed25519_pk *pk, const struct lc_dilithium_87_ed25519_sk *sk)
Generates Dilithium public from private key.
const uint8_t * userctx
buffer with a caller-specified context string
int lc_dilithium_87_ed25519_sign_final(struct lc_dilithium_87_ed25519_sig *sig, struct lc_dilithium_ed25519_ctx *ctx, const struct lc_dilithium_87_ed25519_sk *sk, struct lc_rng_ctx *rng_ctx)
Perform signature generation with Dilithium context in stream operation.
int lc_dilithium_87_ed448_verify_final(const struct lc_dilithium_87_ed448_sig *sig, struct lc_dilithium_ed448_ctx *ctx, const struct lc_dilithium_87_ed448_pk *pk)
Perform signature verification with Dilithium context in stream operation.
uint8_t nist_category
NIST category required for composite signatures.
struct lc_dilithium_87_sig sig
int lc_dilithium_87_ed25519_ctx_alloc(struct lc_dilithium_ed25519_ctx **ctx)
Allocate Dilithium-ED25519 stream context on heap.
struct lc_dilithium_87_pk pk
int lc_dilithium_87_verify_init(struct lc_dilithium_ctx *ctx, const struct lc_dilithium_87_pk *pk)
Initializes a signature verification operation.
uint8_t pk[LC_DILITHIUM_PUBLICKEYBYTES]
static LC_PURE unsigned int lc_dilithium_87_sk_size(void)
Return the size of the Dilithium secret key.
int lc_dilithium_87_verify_final(const struct lc_dilithium_87_sig *sig, struct lc_dilithium_ctx *ctx, const struct lc_dilithium_87_pk *pk)
Verifies signature.
uint8_t sk[LC_DILITHIUM_SECRETKEYBYTES]
int lc_dilithium_87_ed25519_verify_update(struct lc_dilithium_ed25519_ctx *ctx, const uint8_t *m, size_t mlen)
Updates signature verification with Dilithium context in stream operation.
int lc_dilithium_87_ed25519_sign_ctx(struct lc_dilithium_87_ed25519_sig *sig, struct lc_dilithium_ed25519_ctx *ctx, const uint8_t *m, size_t mlen, const struct lc_dilithium_87_ed25519_sk *sk, struct lc_rng_ctx *rng_ctx)
Computes signature with Dilithium context in one shot.
const struct lc_hash * dilithium_prehash_type
When using HashML-DSA, set the hash reference used for the hash operation. Allowed values are lc_sha2...
Dilithium stream context.
Dilithium stream context.
static void lc_memset_secure(void *s, int c, size_t n)