/src/openssl41/crypto/ml_dsa/ml_dsa_sample.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2024-2026 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the Apache License 2.0 (the "License"). You may not use |
5 | | * this file except in compliance with the License. You can obtain a copy |
6 | | * in the file LICENSE in the source distribution or at |
7 | | * https://www.openssl.org/source/license.html |
8 | | */ |
9 | | |
10 | | #include <openssl/byteorder.h> |
11 | | #include <openssl/crypto.h> |
12 | | #include "ml_dsa_local.h" |
13 | | #include "ml_dsa_vector.h" |
14 | | #include "ml_dsa_matrix.h" |
15 | | #include "ml_dsa_hash.h" |
16 | | #include "internal/constant_time.h" |
17 | | #include "internal/sha3.h" |
18 | | #include "internal/packet.h" |
19 | | |
20 | 0 | #define SHAKE128_BLOCKSIZE SHA3_BLOCKSIZE(128) |
21 | 0 | #define SHAKE256_BLOCKSIZE SHA3_BLOCKSIZE(256) |
22 | | |
23 | | /* |
24 | | * This is a constant time version of n % 5 |
25 | | * Note that 0xFFFF / 5 = 0x3333, 2 is added to make an over-estimate of 1/5 |
26 | | * and then we divide by (0xFFFF + 1) |
27 | | */ |
28 | 4.29M | #define MOD5(n) ((n) - 5 * (0x3335 * (n) >> 16)) |
29 | | |
30 | | #if SHAKE128_BLOCKSIZE % 3 != 0 |
31 | | #error "rej_ntt_poly() requires SHAKE128_BLOCKSIZE to be a multiple of 3" |
32 | | #endif |
33 | | |
34 | | typedef int(COEFF_FROM_NIBBLE_FUNC)(uint32_t nibble, uint32_t *out); |
35 | | |
36 | | static COEFF_FROM_NIBBLE_FUNC coeff_from_nibble_4; |
37 | | static COEFF_FROM_NIBBLE_FUNC coeff_from_nibble_2; |
38 | | |
39 | | static ML_DSA_MATRIX_EXPAND_A_FN matrix_expand_A_scalar; |
40 | | static ML_DSA_VECTOR_EXPAND_S_FN vector_expand_S_scalar; |
41 | | static ML_DSA_VECTOR_EXPAND_MASK_FN vector_expand_mask_scalar; |
42 | | |
43 | | /** |
44 | | * @brief Combine 3 bytes to form an coefficient. |
45 | | * See FIPS 204, Algorithm 14, CoeffFromThreeBytes() |
46 | | * |
47 | | * This is not constant time as it is used to generate the matrix A which is public. |
48 | | * |
49 | | * @param s A byte array of 3 uniformly distributed bytes. |
50 | | * @param out The returned coefficient in the range 0..q-1. |
51 | | * @returns 1 if the value is less than q or 0 otherwise. |
52 | | * This is used for rejection sampling. |
53 | | */ |
54 | | static ossl_inline int coeff_from_three_bytes(const uint8_t *s, uint32_t *out) |
55 | 32.9M | { |
56 | | /* Zero out the top bit of the 3rd byte to get a value in the range 0..2^23-1) */ |
57 | 32.9M | *out = (uint32_t)s[0] | ((uint32_t)s[1] << 8) | (((uint32_t)s[2] & 0x7f) << 16); |
58 | 32.9M | return *out < ML_DSA_Q; |
59 | 32.9M | } |
60 | | |
61 | | /** |
62 | | * @brief Generate a value in the range (q-4..0..4) |
63 | | * See FIPS 204, Algorithm 15, CoeffFromHalfByte() where eta = 4 |
64 | | * Note the FIPS 204 code uses the range -4..4 (whereas this code adds q to the |
65 | | * negative numbers). |
66 | | * |
67 | | * @param nibble A value in the range 0..15 |
68 | | * @param out The returned value if the range (q-4)..0..4 if nibble is < 9 |
69 | | * @returns 1 nibble was in range, or 0 if the nibble was rejected. |
70 | | */ |
71 | | static ossl_inline int coeff_from_nibble_4(uint32_t nibble, uint32_t *out) |
72 | 3.42M | { |
73 | | /* |
74 | | * This is not constant time but will not leak any important info since |
75 | | * the value is either chosen or thrown away. |
76 | | */ |
77 | 3.42M | if (value_barrier_32(nibble < 9)) { |
78 | 1.92M | *out = mod_sub(4, nibble); |
79 | 1.92M | return 1; |
80 | 1.92M | } |
81 | 1.49M | return 0; |
82 | 3.42M | } |
83 | | |
84 | | /** |
85 | | * @brief Generate a value in the range (q-2..0..2) |
86 | | * See FIPS 204, Algorithm 15, CoeffFromHalfByte() where eta = 2 |
87 | | * Note the FIPS 204 code uses the range -2..2 (whereas this code adds q to the |
88 | | * negative numbers). |
89 | | * |
90 | | * @param nibble A value in the range 0..15 |
91 | | * @param out The returned value if the range (q-2)..0..2 if nibble is < 15 |
92 | | * @returns 1 nibble was in range, or 0 if the nibble was rejected. |
93 | | */ |
94 | | static ossl_inline int coeff_from_nibble_2(uint32_t nibble, uint32_t *out) |
95 | 4.58M | { |
96 | 4.58M | if (value_barrier_32(nibble < 15)) { |
97 | 4.29M | *out = mod_sub(2, MOD5(nibble)); |
98 | 4.29M | return 1; |
99 | 4.29M | } |
100 | 287k | return 0; |
101 | 4.58M | } |
102 | | |
103 | | /** |
104 | | * @brief Use a seed value to generate a polynomial with coefficients in the |
105 | | * range of 0..q-1 using rejection sampling. |
106 | | * SHAKE128 is used to absorb the seed, and then sequences of 3 sample bytes are |
107 | | * squeezed to try to produce coefficients. |
108 | | * The SHAKE128 stream is used to get uniformly distributed elements. |
109 | | * This algorithm is used for matrix expansion and only operates on public inputs. |
110 | | * |
111 | | * See FIPS 204, Algorithm 30, RejNTTPoly() |
112 | | * |
113 | | * @param g_ctx A EVP_MD_CTX object used for sampling the seed. |
114 | | * @param md A pre-fetched SHAKE128 object. |
115 | | * @param seed The seed to use for sampling. |
116 | | * @param seed_len The size of |seed| |
117 | | * @param out The returned polynomial with coefficients in the range of |
118 | | * 0..q-1. This range is required for NTT. |
119 | | * @returns 1 if the polynomial was successfully generated, or 0 if any of the |
120 | | * digest operations failed. |
121 | | */ |
122 | | static int rej_ntt_poly(EVP_MD_CTX *g_ctx, const EVP_MD *md, |
123 | | const uint8_t *seed, size_t seed_len, POLY *out) |
124 | 128k | { |
125 | 128k | int j = 0; |
126 | 128k | uint8_t blocks[SHAKE128_BLOCKSIZE], *b, *end = blocks + sizeof(blocks); |
127 | | |
128 | | /* |
129 | | * Instead of just squeezing 3 bytes at a time, we grab a whole block |
130 | | * Note that the shake128 blocksize of 168 is divisible by 3. |
131 | | */ |
132 | 128k | if (!shake_xof(g_ctx, md, seed, seed_len, blocks, sizeof(blocks))) |
133 | 0 | return 0; |
134 | | |
135 | 643k | while (1) { |
136 | 33.5M | for (b = blocks; b < end; b += 3) { |
137 | 32.9M | if (coeff_from_three_bytes(b, &(out->coeff[j]))) { |
138 | 32.9M | if (++j >= ML_DSA_NUM_POLY_COEFFICIENTS) |
139 | 128k | return 1; /* finished */ |
140 | 32.9M | } |
141 | 32.9M | } |
142 | 514k | if (!EVP_DigestSqueeze(g_ctx, blocks, sizeof(blocks))) |
143 | 0 | return 0; |
144 | 514k | } |
145 | 128k | } |
146 | | |
147 | | /** |
148 | | * @brief Use a seed value to generate a polynomial with coefficients in the |
149 | | * range of ((q-eta)..0..eta) using rejection sampling. eta is either 2 or 4. |
150 | | * SHAKE256 is used to absorb the seed, and then samples are squeezed. |
151 | | * See FIPS 204, Algorithm 31, RejBoundedPoly() |
152 | | * |
153 | | * @param h_ctx A EVP_MD_CTX object context used to sample the seed. |
154 | | * @param md A pre-fetched SHAKE256 object. |
155 | | * @param coef_from_nibble A function that is dependent on eta, which takes a |
156 | | * nibble and tries to see if it is in the correct range. |
157 | | * @param seed The seed to use for sampling. |
158 | | * @param seed_len The size of |seed| |
159 | | * @param out The returned polynomial with coefficients in the range of |
160 | | * ((q-eta)..0..eta) |
161 | | * @returns 1 if the polynomial was successfully generated, or 0 if any of the |
162 | | * digest operations failed. |
163 | | */ |
164 | | static int rej_bounded_poly(EVP_MD_CTX *h_ctx, const EVP_MD *md, |
165 | | COEFF_FROM_NIBBLE_FUNC *coef_from_nibble, |
166 | | const uint8_t *seed, size_t seed_len, POLY *out) |
167 | 24.3k | { |
168 | 24.3k | int ret = 0; |
169 | 24.3k | int j = 0; |
170 | 24.3k | uint32_t z0, z1; |
171 | 24.3k | uint8_t blocks[SHAKE256_BLOCKSIZE], *b, *end = blocks + sizeof(blocks); |
172 | | |
173 | | /* Instead of just squeezing 1 byte at a time, we grab a whole block */ |
174 | 24.3k | if (!shake_xof(h_ctx, md, seed, seed_len, blocks, sizeof(blocks))) |
175 | 0 | goto err; |
176 | | |
177 | 40.9k | while (1) { |
178 | 4.02M | for (b = blocks; b < end; b++) { |
179 | 4.01M | z0 = *b & 0x0F; /* lower nibble of byte */ |
180 | 4.01M | z1 = *b >> 4; /* high nibble of byte */ |
181 | | |
182 | 4.01M | if (coef_from_nibble(z0, &out->coeff[j]) |
183 | 3.11M | && ++j >= ML_DSA_NUM_POLY_COEFFICIENTS) { |
184 | 12.2k | ret = 1; |
185 | 12.2k | goto err; |
186 | 12.2k | } |
187 | 3.99M | if (coef_from_nibble(z1, &out->coeff[j]) |
188 | 3.10M | && ++j >= ML_DSA_NUM_POLY_COEFFICIENTS) { |
189 | 12.0k | ret = 1; |
190 | 12.0k | goto err; |
191 | 12.0k | } |
192 | 3.99M | } |
193 | 16.6k | if (!EVP_DigestSqueeze(h_ctx, blocks, sizeof(blocks))) |
194 | 0 | goto err; |
195 | 16.6k | } |
196 | 24.3k | err: |
197 | 24.3k | OPENSSL_cleanse(blocks, sizeof(blocks)); |
198 | 24.3k | return ret; |
199 | 24.3k | } |
200 | | |
201 | | /** |
202 | | * @brief Generate a k * l matrix that has uniformly distributed polynomial |
203 | | * elements using rejection sampling. |
204 | | * See FIPS 204, Algorithm 32, ExpandA() |
205 | | * |
206 | | * @param g_ctx A EVP_MD_CTX context used for rejection sampling |
207 | | * seed values generated from the seed rho. |
208 | | * @param md A pre-fetched SHAKE128 object |
209 | | * @param rho A 32 byte seed to generated the matrix from. |
210 | | * @param out The generated k * l matrix of polynomials with coefficients |
211 | | * in the range of 0..q-1. |
212 | | * @returns 1 if the matrix was generated, or 0 on error. |
213 | | */ |
214 | | static int matrix_expand_A_scalar(EVP_MD_CTX *g_ctx, const EVP_MD *md, |
215 | | const uint8_t *rho, MATRIX *out) |
216 | 1.19k | { |
217 | 1.19k | int ret = 0; |
218 | 1.19k | size_t i, j; |
219 | 1.19k | uint8_t derived_seed[ML_DSA_RHO_BYTES + 2]; |
220 | 1.19k | POLY *poly = out->m_poly; |
221 | | |
222 | | /* |
223 | | * The seeds derived below and the sampling buffers in rej_ntt_poly() are |
224 | | * not cleansed: per FIPS 204 section 3.6.3 the matrix A is easily |
225 | | * computed from the public key and does not require any special |
226 | | * protections. |
227 | | */ |
228 | | |
229 | | /* The seed used for each matrix element is rho + column_index + row_index */ |
230 | 1.19k | memcpy(derived_seed, rho, ML_DSA_RHO_BYTES); |
231 | 8.27k | for (i = 0; i < out->k; i++) { |
232 | 46.9k | for (j = 0; j < out->l; j++) { |
233 | 39.8k | derived_seed[ML_DSA_RHO_BYTES + 1] = (uint8_t)i; |
234 | 39.8k | derived_seed[ML_DSA_RHO_BYTES] = (uint8_t)j; |
235 | | /* Generate the polynomial for each matrix element using a unique seed */ |
236 | 39.8k | if (!rej_ntt_poly(g_ctx, md, derived_seed, sizeof(derived_seed), poly++)) |
237 | 0 | goto err; |
238 | 39.8k | } |
239 | 7.07k | } |
240 | 1.19k | ret = 1; |
241 | 1.19k | err: |
242 | 1.19k | return ret; |
243 | 1.19k | } |
244 | | |
245 | | /** |
246 | | * @brief Generates 2 vectors using rejection sampling whose polynomial |
247 | | * coefficients are in the interval [q-eta..0..eta] |
248 | | * |
249 | | * See FIPS 204, Algorithm 33, ExpandS(). |
250 | | * Note that in FIPS 204 the range -eta..eta is used. |
251 | | * |
252 | | * @param h_ctx A EVP_MD_CTX context to use to sample the seed. |
253 | | * @param md A pre-fetched SHAKE256 object. |
254 | | * @param eta Is either 2 or 4, and determines the range of the coefficients for |
255 | | * s1 and s2. |
256 | | * @param seed A 64 byte seed to use for sampling. |
257 | | * @param s1 A 1 * l column vector containing polynomials with coefficients in |
258 | | * the range (q-eta)..0..eta |
259 | | * @param s2 A 1 * k column vector containing polynomials with coefficients in |
260 | | * the range (q-eta)..0..eta |
261 | | * @returns 1 if s1 and s2 were successfully generated, or 0 otherwise. |
262 | | */ |
263 | | static int vector_expand_S_scalar(EVP_MD_CTX *h_ctx, const EVP_MD *md, int eta, |
264 | | const uint8_t *seed, VECTOR *s1, VECTOR *s2) |
265 | 672 | { |
266 | 672 | int ret = 0; |
267 | 672 | size_t i; |
268 | 672 | size_t l = s1->num_poly; |
269 | 672 | size_t k = s2->num_poly; |
270 | 672 | uint8_t derived_seed[ML_DSA_PRIV_SEED_BYTES + 2]; |
271 | 672 | COEFF_FROM_NIBBLE_FUNC *coef_from_nibble_fn; |
272 | | |
273 | 672 | coef_from_nibble_fn = (eta == ML_DSA_ETA_4) ? coeff_from_nibble_4 : coeff_from_nibble_2; |
274 | | |
275 | | /* |
276 | | * Each polynomial generated uses a unique seed that consists of |
277 | | * seed + counter (where the counter is 2 bytes starting at 0) |
278 | | */ |
279 | 672 | memcpy(derived_seed, seed, ML_DSA_PRIV_SEED_BYTES); |
280 | 672 | derived_seed[ML_DSA_PRIV_SEED_BYTES] = 0; |
281 | 672 | derived_seed[ML_DSA_PRIV_SEED_BYTES + 1] = 0; |
282 | | |
283 | 4.24k | for (i = 0; i < l; i++) { |
284 | 3.56k | if (!rej_bounded_poly(h_ctx, md, coef_from_nibble_fn, |
285 | 3.56k | derived_seed, sizeof(derived_seed), &s1->poly[i])) |
286 | 0 | goto err; |
287 | 3.56k | ++derived_seed[ML_DSA_PRIV_SEED_BYTES]; |
288 | 3.56k | } |
289 | 4.68k | for (i = 0; i < k; i++) { |
290 | 4.01k | if (!rej_bounded_poly(h_ctx, md, coef_from_nibble_fn, |
291 | 4.01k | derived_seed, sizeof(derived_seed), &s2->poly[i])) |
292 | 0 | goto err; |
293 | 4.01k | ++derived_seed[ML_DSA_PRIV_SEED_BYTES]; |
294 | 4.01k | } |
295 | 672 | ret = 1; |
296 | 672 | err: |
297 | 672 | OPENSSL_cleanse(derived_seed, sizeof(derived_seed)); |
298 | 672 | return ret; |
299 | 672 | } |
300 | | |
301 | | /* See FIPS 204, Algorithm 34, ExpandMask(), Step 4 & 5 */ |
302 | | int ossl_ml_dsa_poly_expand_mask(POLY *out, const uint8_t *seed, size_t seed_len, |
303 | | uint32_t gamma1, |
304 | | EVP_MD_CTX *h_ctx, const EVP_MD *md) |
305 | 20.5k | { |
306 | 20.5k | uint8_t buf[32 * 20]; |
307 | 20.5k | size_t buf_len = 32 * (gamma1 == ML_DSA_GAMMA1_TWO_POWER_19 ? 20 : 18); |
308 | 20.5k | int ret = shake_xof(h_ctx, md, seed, seed_len, buf, buf_len) |
309 | 20.5k | && ossl_ml_dsa_poly_decode_expand_mask(out, buf, buf_len, gamma1); |
310 | | |
311 | 20.5k | OPENSSL_cleanse(buf, sizeof(buf)); |
312 | 20.5k | return ret; |
313 | 20.5k | } |
314 | | |
315 | | /* |
316 | | * @brief Sample a polynomial with coefficients in the range {-1..1}. |
317 | | * The number of non zero values (hamming weight) is given by tau |
318 | | * |
319 | | * See FIPS 204, Algorithm 29, SampleInBall() |
320 | | * This function is assumed to not be constant time. |
321 | | * The algorithm is based on Durstenfeld's version of the Fisher-Yates shuffle. |
322 | | * |
323 | | * Note that the coefficients returned by this implementation are positive |
324 | | * i.e one of q-1, 0, or 1. |
325 | | * |
326 | | * @param tau is the number of +1 or -1's in the polynomial 'out_c' (39, 49 or 60) |
327 | | * that is less than or equal to 64 |
328 | | */ |
329 | | int ossl_ml_dsa_poly_sample_in_ball(POLY *out_c, const uint8_t *seed, int seed_len, |
330 | | EVP_MD_CTX *h_ctx, const EVP_MD *md, |
331 | | uint32_t tau) |
332 | 4.92k | { |
333 | 4.92k | uint8_t block[SHAKE256_BLOCKSIZE]; |
334 | 4.92k | uint64_t signs; |
335 | 4.92k | int offset = 8; |
336 | 4.92k | size_t end; |
337 | 4.92k | int ret = 0; |
338 | | |
339 | | /* |
340 | | * Rather than squeeze 8 bytes followed by lots of 1 byte squeezes |
341 | | * the SHAKE blocksize is squeezed each time and buffered into 'block'. |
342 | | */ |
343 | 4.92k | if (!shake_xof(h_ctx, md, seed, seed_len, block, sizeof(block))) |
344 | 0 | goto err; |
345 | | |
346 | | /* |
347 | | * grab the first 64 bits - since tau < 64 |
348 | | * Each bit gives a +1 or -1 value. |
349 | | */ |
350 | 4.92k | OPENSSL_load_u64_le(&signs, block); |
351 | | |
352 | | /* |
353 | | * SampleInBall implements a Fisher-Yates shuffle whose rejection-sampling |
354 | | * inner loop and data-dependent array index unavoidably leak the structure |
355 | | * of the challenge polynomial via memory-access pattern and branch timing. |
356 | | * This is safe: c_tilde = H(mu ‖ w1) is the Fiat-Shamir commitment and is |
357 | | * published in the accepted signature, so the SHAKE bytes that build c are |
358 | | * effectively public. See the BoringSSL design discussion at |
359 | | * https://boringssl-review.googlesource.com/c/boringssl/+/67747/comment/8d8f01ac_70af3f21/ |
360 | | * |
361 | | * The first 8 bytes (the sign bits loaded into |signs| above) are left |
362 | | * tainted: they determine only the ±1 values written into c, which flow |
363 | | * into the CT arithmetic of cs1/cs2/ct0 alongside the already-tainted |
364 | | * secret polynomials and cause no spurious violations there. |
365 | | * Only the rejection-sampling bytes need to be declassified. |
366 | | */ |
367 | 4.92k | CONSTTIME_DECLASSIFY(block + offset, sizeof(block) - offset); |
368 | | |
369 | 4.92k | poly_zero(out_c); |
370 | | |
371 | | /* Loop tau times */ |
372 | 240k | for (end = 256 - tau; end < 256; end++) { |
373 | 235k | size_t index; /* index is a random offset to write +1 or -1 */ |
374 | | |
375 | | /* rejection sample in {0..end} to choose an index to place -1 or 1 into */ |
376 | 261k | for (;;) { |
377 | 261k | if (offset == sizeof(block)) { |
378 | | /* squeeze another block if the bytes from block have been used */ |
379 | 0 | if (!EVP_DigestSqueeze(h_ctx, block, sizeof(block))) |
380 | 0 | goto err; |
381 | | /* See comment above for why the block is declassified. */ |
382 | 0 | CONSTTIME_DECLASSIFY(block, sizeof(block)); |
383 | 0 | offset = 0; |
384 | 0 | } |
385 | | |
386 | 261k | index = block[offset++]; |
387 | 261k | if (index <= end) |
388 | 235k | break; |
389 | 261k | } |
390 | | |
391 | | /* |
392 | | * In-place swap the coefficient we are about to replace to the end so |
393 | | * we don't lose any values that have been already written. |
394 | | */ |
395 | 235k | out_c->coeff[end] = out_c->coeff[index]; |
396 | | /* set the random coefficient value to either 1 or q-1 */ |
397 | 235k | out_c->coeff[index] = mod_sub(1, 2 * (signs & 1)); |
398 | 235k | signs >>= 1; /* grab the next random bit */ |
399 | 235k | } |
400 | 4.92k | ret = 1; |
401 | 4.92k | err: |
402 | 4.92k | OPENSSL_cleanse(block, sizeof(block)); |
403 | 4.92k | return ret; |
404 | 4.92k | } |
405 | | |
406 | | static void vector_expand_mask_scalar(VECTOR *out, |
407 | | const uint8_t rho_prime[ML_DSA_RHO_PRIME_BYTES], uint32_t kappa, uint32_t gamma1, |
408 | | EVP_MD_CTX *h_ctx, const EVP_MD *md) |
409 | 1.13k | { |
410 | 1.13k | size_t i; |
411 | 1.13k | uint8_t derived_seed[ML_DSA_RHO_PRIME_BYTES + 2]; |
412 | | |
413 | 1.13k | memcpy(derived_seed, rho_prime, ML_DSA_RHO_PRIME_BYTES); |
414 | | |
415 | 6.99k | for (i = 0; i < out->num_poly; i++) { |
416 | 5.85k | size_t index = kappa + i; |
417 | | |
418 | 5.85k | derived_seed[ML_DSA_RHO_PRIME_BYTES] = index & 0xFF; |
419 | 5.85k | derived_seed[ML_DSA_RHO_PRIME_BYTES + 1] = (index >> 8) & 0xFF; |
420 | 5.85k | poly_expand_mask(out->poly + i, derived_seed, sizeof(derived_seed), |
421 | 5.85k | gamma1, h_ctx, md); |
422 | 5.85k | } |
423 | 1.13k | OPENSSL_cleanse(derived_seed, sizeof(derived_seed)); |
424 | 1.13k | } |
425 | | |
426 | | static const OSSL_ML_DSA_SAMPLE_OPS ml_dsa_sample_generic_meth = { |
427 | | matrix_expand_A_scalar, |
428 | | vector_expand_S_scalar, |
429 | | vector_expand_mask_scalar |
430 | | }; |
431 | | |
432 | | #if defined(KECCAK1600_ASM) \ |
433 | | && (defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || defined(_M_X64)) \ |
434 | | && !defined(OPENSSL_NO_ASM) |
435 | | #include "ml_dsa_sample_hw_x86_64.inc" |
436 | | const OSSL_ML_DSA_SAMPLE_OPS *ossl_ml_dsa_sample_ops(void) |
437 | 1.19k | { |
438 | 1.19k | if (SHA3_avx512vl_capable()) |
439 | 0 | return &ml_dsa_sample_x86_64; |
440 | 1.19k | return &ml_dsa_sample_generic_meth; |
441 | 1.19k | } |
442 | | #else |
443 | | const OSSL_ML_DSA_SAMPLE_OPS *ossl_ml_dsa_sample_ops(void) |
444 | | { |
445 | | return &ml_dsa_sample_generic_meth; |
446 | | } |
447 | | #endif |