27#ifndef OCRYPTO_ML_DSA87_H
28#define OCRYPTO_ML_DSA87_H
41#if defined(OCRYPTO_ML_DSA_SMALL) && defined(OCRYPTO_ML_DSA_FAST)
42#error "OCRYPTO_ML_DSA_SMALL & OCRYPTO_ML_DSA_FAST must not be defined simultaneously"
49#define ocrypto_ml_dsa87_PK_SIZE (2592)
54#define ocrypto_ml_dsa87_SK_SIZE (4896)
59#define ocrypto_ml_dsa87_SIG_SIZE (4627)
64 ocrypto_sha3_ctx sha3;
68} ocrypto_ml_dsa87_ctx_s;
71 ocrypto_sha3_ctx sha3;
74} ocrypto_ml_dsa87_ctx_m;
77 ocrypto_sha3_ctx sha3;
85} ocrypto_ml_dsa87_ctx_f;
87#if defined(OCRYPTO_ML_DSA_SMALL)
88typedef ocrypto_ml_dsa87_ctx_s ocrypto_ml_dsa87_ctx;
89#elif defined(OCRYPTO_ML_DSA_FAST)
90typedef ocrypto_ml_dsa87_ctx_f ocrypto_ml_dsa87_ctx;
92typedef ocrypto_ml_dsa87_ctx_m ocrypto_ml_dsa87_ctx;
96int ocrypto_ml_dsa87_key_pair_s(
97 ocrypto_ml_dsa87_ctx_s *ctx,
100 const uint8_t zeta[32]);
101int ocrypto_ml_dsa87_key_pair_m(
102 ocrypto_ml_dsa87_ctx_m *ctx,
105 const uint8_t zeta[32]);
107int ocrypto_ml_dsa87_sign_s(
108 ocrypto_ml_dsa87_ctx_s *ctx,
110 const uint8_t *m,
size_t mlen,
111 const uint8_t *ctx_str,
size_t ctx_len,
113 const uint8_t rnd[32]);
114int ocrypto_ml_dsa87_sign_m(
115 ocrypto_ml_dsa87_ctx_m *ctx,
117 const uint8_t *m,
size_t mlen,
118 const uint8_t *ctx_str,
size_t ctx_len,
120 const uint8_t rnd[32]);
121int ocrypto_ml_dsa87_sign_f(
122 ocrypto_ml_dsa87_ctx_f *ctx,
124 const uint8_t *m,
size_t mlen,
125 const uint8_t *ctx_str,
size_t ctx_len,
127 const uint8_t rnd[32]);
129int ocrypto_ml_dsa87_sign_hash_s(
130 ocrypto_ml_dsa87_ctx_s *ctx,
132 const uint8_t *hash,
size_t hash_len,
133 const uint8_t oid[11],
134 const uint8_t *ctx_str,
size_t ctx_len,
136 const uint8_t rnd[32]);
137int ocrypto_ml_dsa87_sign_hash_m(
138 ocrypto_ml_dsa87_ctx_m *ctx,
140 const uint8_t *hash,
size_t hash_len,
141 const uint8_t oid[11],
142 const uint8_t *ctx_str,
size_t ctx_len,
144 const uint8_t rnd[32]);
145int ocrypto_ml_dsa87_sign_hash_f(
146 ocrypto_ml_dsa87_ctx_f *ctx,
148 const uint8_t *hash,
size_t hash_len,
149 const uint8_t oid[11],
150 const uint8_t *ctx_str,
size_t ctx_len,
152 const uint8_t rnd[32]);
154int ocrypto_ml_dsa87_verify_s(
155 ocrypto_ml_dsa87_ctx_s *ctx,
157 const uint8_t *m,
size_t mlen,
158 const uint8_t *ctx_str,
size_t ctx_len,
160int ocrypto_ml_dsa87_verify_m(
161 ocrypto_ml_dsa87_ctx_m *ctx,
163 const uint8_t *m,
size_t mlen,
164 const uint8_t *ctx_str,
size_t ctx_len,
167int ocrypto_ml_dsa87_verify_hash_s(
168 ocrypto_ml_dsa87_ctx_s *ctx,
170 const uint8_t *hash,
size_t hash_len,
171 const uint8_t oid[11],
172 const uint8_t *ctx_str,
size_t ctx_len,
174int ocrypto_ml_dsa87_verify_hash_m(
175 ocrypto_ml_dsa87_ctx_m *ctx,
177 const uint8_t *hash,
size_t hash_len,
178 const uint8_t oid[11],
179 const uint8_t *ctx_str,
size_t ctx_len,
194 ocrypto_ml_dsa87_ctx *ctx,
197 const uint8_t zeta[32])
199#if defined(OCRYPTO_ML_DSA_SMALL)
200 return ocrypto_ml_dsa87_key_pair_s(ctx, sk, pk, zeta);
202 return ocrypto_ml_dsa87_key_pair_m((ocrypto_ml_dsa87_ctx_m*)ctx, sk, pk, zeta);
220 ocrypto_ml_dsa87_ctx *ctx,
222 const uint8_t *m,
size_t mlen,
223 const uint8_t *ctx_str,
size_t ctx_len,
225 const uint8_t rnd[32])
227#if defined(OCRYPTO_ML_DSA_SMALL)
228 return ocrypto_ml_dsa87_sign_s(ctx, sig, m, mlen, ctx_str, ctx_len, sk, rnd);
229#elif defined(OCRYPTO_ML_DSA_FAST)
230 return ocrypto_ml_dsa87_sign_f(ctx, sig, m, mlen, ctx_str, ctx_len, sk, rnd);
232 return ocrypto_ml_dsa87_sign_m(ctx, sig, m, mlen, ctx_str, ctx_len, sk, rnd);
251 ocrypto_ml_dsa87_ctx *ctx,
253 const uint8_t *hash,
size_t hash_len,
254 const uint8_t oid[11],
255 const uint8_t *ctx_str,
size_t ctx_len,
257 const uint8_t rnd[32])
259#if defined(OCRYPTO_ML_DSA_SMALL)
260 return ocrypto_ml_dsa87_sign_hash_s(ctx, sig, hash, hash_len, oid, ctx_str, ctx_len, sk, rnd);
261#elif defined(OCRYPTO_ML_DSA_FAST)
262 return ocrypto_ml_dsa87_sign_hash_f(ctx, sig, hash, hash_len, oid, ctx_str, ctx_len, sk, rnd);
264 return ocrypto_ml_dsa87_sign_hash_m(ctx, sig, hash, hash_len, oid, ctx_str, ctx_len, sk, rnd);
281 ocrypto_ml_dsa87_ctx *ctx,
283 const uint8_t *m,
size_t mlen,
284 const uint8_t *ctx_str,
size_t ctx_len,
287#if defined(OCRYPTO_ML_DSA_SMALL)
288 return ocrypto_ml_dsa87_verify_s(ctx, sig, m, mlen, ctx_str, ctx_len, pk);
290 return ocrypto_ml_dsa87_verify_m((ocrypto_ml_dsa87_ctx_m*)ctx, sig, m, mlen, ctx_str, ctx_len, pk);
308 ocrypto_ml_dsa87_ctx *ctx,
310 const uint8_t *hash,
size_t hash_len,
311 const uint8_t oid[11],
312 const uint8_t *ctx_str,
size_t ctx_len,
315#if defined(OCRYPTO_ML_DSA_SMALL)
316 return ocrypto_ml_dsa87_verify_hash_s(ctx, sig, hash, hash_len, oid, ctx_str, ctx_len, pk);
318 return ocrypto_ml_dsa87_verify_hash_m((ocrypto_ml_dsa87_ctx_m*)ctx, sig, hash, hash_len, oid, ctx_str, ctx_len, pk);
static int ocrypto_ml_dsa87_sign_hash(ocrypto_ml_dsa87_ctx *ctx, uint8_t sig[(4627)], const uint8_t *hash, size_t hash_len, const uint8_t oid[11], const uint8_t *ctx_str, size_t ctx_len, const uint8_t sk[(4896)], const uint8_t rnd[32])
Definition ocrypto_ml_dsa87.h:250
static int ocrypto_ml_dsa87_sign(ocrypto_ml_dsa87_ctx *ctx, uint8_t sig[(4627)], const uint8_t *m, size_t mlen, const uint8_t *ctx_str, size_t ctx_len, const uint8_t sk[(4896)], const uint8_t rnd[32])
Definition ocrypto_ml_dsa87.h:219
static int ocrypto_ml_dsa87_verify_hash(ocrypto_ml_dsa87_ctx *ctx, const uint8_t sig[(4627)], const uint8_t *hash, size_t hash_len, const uint8_t oid[11], const uint8_t *ctx_str, size_t ctx_len, const uint8_t pk[(2592)])
Definition ocrypto_ml_dsa87.h:307
#define ocrypto_ml_dsa87_PK_SIZE
Definition ocrypto_ml_dsa87.h:49
static int ocrypto_ml_dsa87_key_pair(ocrypto_ml_dsa87_ctx *ctx, uint8_t sk[(4896)], uint8_t pk[(2592)], const uint8_t zeta[32])
Definition ocrypto_ml_dsa87.h:193
static int ocrypto_ml_dsa87_verify(ocrypto_ml_dsa87_ctx *ctx, const uint8_t sig[(4627)], const uint8_t *m, size_t mlen, const uint8_t *ctx_str, size_t ctx_len, const uint8_t pk[(2592)])
Definition ocrypto_ml_dsa87.h:280
#define ocrypto_ml_dsa87_SIG_SIZE
Definition ocrypto_ml_dsa87.h:59
#define ocrypto_ml_dsa87_SK_SIZE
Definition ocrypto_ml_dsa87.h:54
SHA3 algorithms, with 224, 256, 384 and 512 bit outputs.