qubip_aurora 0.11.0

A framework to build OpenSSL Providers tailored for the transition to post-quantum cryptography
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
#![expect(dead_code)]
#![expect(unused_imports)]

use super::*;
use bindings::{dispatch_table_entry, OSSL_DISPATCH};
use bindings::{OSSL_FUNC_keymgmt_export_fn, OSSL_FUNC_KEYMGMT_EXPORT};
use bindings::{OSSL_FUNC_keymgmt_export_types_ex_fn, OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX};
use bindings::{OSSL_FUNC_keymgmt_free_fn, OSSL_FUNC_KEYMGMT_FREE};
use bindings::{OSSL_FUNC_keymgmt_gen_cleanup_fn, OSSL_FUNC_KEYMGMT_GEN_CLEANUP};
use bindings::{OSSL_FUNC_keymgmt_gen_fn, OSSL_FUNC_KEYMGMT_GEN};
use bindings::{OSSL_FUNC_keymgmt_gen_init_fn, OSSL_FUNC_KEYMGMT_GEN_INIT};
use bindings::{OSSL_FUNC_keymgmt_gen_set_params_fn, OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS};
use bindings::{OSSL_FUNC_keymgmt_gen_settable_params_fn, OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS};
use bindings::{OSSL_FUNC_keymgmt_get_params_fn, OSSL_FUNC_KEYMGMT_GET_PARAMS};
use bindings::{OSSL_FUNC_keymgmt_gettable_params_fn, OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS};
use bindings::{OSSL_FUNC_keymgmt_has_fn, OSSL_FUNC_KEYMGMT_HAS};
use bindings::{OSSL_FUNC_keymgmt_import_fn, OSSL_FUNC_KEYMGMT_IMPORT};
use bindings::{OSSL_FUNC_keymgmt_import_types_ex_fn, OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX};
use bindings::{OSSL_FUNC_keymgmt_load_fn, OSSL_FUNC_KEYMGMT_LOAD};
use bindings::{OSSL_FUNC_keymgmt_match_fn, OSSL_FUNC_KEYMGMT_MATCH};
use bindings::{OSSL_FUNC_keymgmt_new_fn, OSSL_FUNC_KEYMGMT_NEW};
use bindings::{OSSL_FUNC_keymgmt_set_params_fn, OSSL_FUNC_KEYMGMT_SET_PARAMS};
use bindings::{OSSL_FUNC_keymgmt_settable_params_fn, OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS};
use bindings::{OSSL_FUNC_signature_digest_sign_fn, OSSL_FUNC_SIGNATURE_DIGEST_SIGN};
use bindings::{OSSL_FUNC_signature_digest_sign_init_fn, OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT};
use bindings::{OSSL_FUNC_signature_digest_verify_fn, OSSL_FUNC_SIGNATURE_DIGEST_VERIFY};
use bindings::{OSSL_FUNC_signature_digest_verify_init_fn, OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT};
use bindings::{OSSL_FUNC_signature_freectx_fn, OSSL_FUNC_SIGNATURE_FREECTX};
use bindings::{OSSL_FUNC_signature_get_ctx_params_fn, OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS};
use bindings::{
    OSSL_FUNC_signature_gettable_ctx_params_fn, OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
};
use bindings::{OSSL_FUNC_signature_newctx_fn, OSSL_FUNC_SIGNATURE_NEWCTX};
use bindings::{OSSL_FUNC_signature_set_ctx_params_fn, OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS};
use bindings::{
    OSSL_FUNC_signature_settable_ctx_params_fn, OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
};
use bindings::{OSSL_FUNC_signature_sign_fn, OSSL_FUNC_SIGNATURE_SIGN};
use bindings::{OSSL_FUNC_signature_sign_init_fn, OSSL_FUNC_SIGNATURE_SIGN_INIT};
use bindings::{OSSL_FUNC_signature_verify_fn, OSSL_FUNC_SIGNATURE_VERIFY};
use bindings::{OSSL_FUNC_signature_verify_init_fn, OSSL_FUNC_SIGNATURE_VERIFY_INIT};

mod decoder_functions;
mod encoder_functions;
mod keymgmt_functions;

#[path = "../common/signature.rs"]
mod signature;

#[path = "../common/signature_functions.rs"]
mod signature_functions;

pub(crate) type OurError = anyhow::Error;
pub(crate) use anyhow::anyhow;

// Ensure proper null-terminated C string
// https://docs.openssl.org/master/man7/provider/#algorithm-naming
pub(super) const NAMES: &CStr = c"ML-DSA-87:2.16.840.1.101.3.4.3.19:id-ml-dsa-87:mldsa87";

/// NAME should be a substring of NAMES
pub(crate) const NAME: &CStr = c"ML-DSA-87";

/// LONG_NAME should be a substring of NAMES
pub(crate) const LONG_NAME: &CStr = c"id-ml-dsa-87";

/// OID should be a substring of NAMES
///
/// This OID is defined in
/// <https://csrc.nist.gov/projects/computer-security-objects-register/algorithm-registration>.
pub(crate) const OID: asn1::ObjectIdentifier = asn1::oid!(2, 16, 840, 1, 101, 3, 4, 3, 19);
pub(crate) const OID_PKCS8: pkcs8::ObjectIdentifier =
    pkcs8::ObjectIdentifier::new_unwrap("2.16.840.1.101.3.4.3.19");
pub(crate) const SIGALG_OID: Option<&CStr> = Some(c"2.16.840.1.101.3.4.3.19");

crate::adapters::common::keymgmt_functions::oid_consistency_tests!();

/// [RFC 5280 AlgorithmIdentifier](https://www.rfc-editor.org/rfc/rfc5280.html#section-4.1.1.2)
/// in DER-encoded format.
use std::sync::LazyLock;
pub(crate) static ALGORITHM_ID_DER: LazyLock<Vec<u8>> = LazyLock::new(|| {
    asn1::write(|w| {
        w.write_element(&asn1::SequenceWriter::new(&|w| {
            w.write_element(&OID)?;
            Ok(())
        }))
    })
    .expect("OID should be encodable as AlgorithmIdentifier")
});

// Ensure proper null-terminated C string
pub(super) const DESCRIPTION: &CStr = c"ML-DSA-87 from pqclean";

/// number of bits of security
pub(crate) const SECURITY_BITS: u32 = 256;

/// used to register an Signature Id Object within OpenSSL
/// for this algorithm
pub(crate) const OBJ_SIGID: ObjSigId = ObjSigId {
    oid: SIGALG_OID.unwrap(),
    short_name: NAME,
    long_name: LONG_NAME,
    digest_name: None,
};

#[allow(unused_imports)]
pub(crate) use keymgmt_functions::{PUBKEY_LEN, SECRETKEY_LEN, SIGNATURE_LEN};

pub(crate) mod capabilities {
    pub(crate) mod tls_sigalg {
        use super::super::forge;
        use forge::capabilities::tls_sigalg;
        use forge::osslparams::CONST_OSSL_PARAM;
        use tls_sigalg::*;

        /// A [_unit-like struct_][rustbook:unit-like-structs] implementing [`TLSSigAlg`] for `id-ml-dsa-87`.
        ///
        /// [rustbook:unit-like-structs]: https://doc.rust-lang.org/book/ch05-01-defining-structs.html#unit-like-structs-without-any-fields
        pub(crate) struct TLSSigAlgCap;

        /// Implement [`TLSSigAlg`] for [`TLSSigAlgCap`]
        ///
        /// # NOTE
        ///
        /// > For ML-DSA we refer to ids reserved by <https://datatracker.ietf.org/doc/html/draft-ietf-tls-mldsa-01#name-ml-dsa-signaturescheme-valu>.
        ///
        /// We use default values for MAX_TLS (none), MIN_DTLS (disabled), MAX_DTLS (disabled)
        impl TLSSigAlg for TLSSigAlgCap {
            /// The name of the signature algorithm as given in the [IANA TLS SignatureScheme registry][IANA:tls-signaturescheme] as "Description".
            ///
            /// [IANA:tls-signaturescheme]: https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-signaturescheme
            ///
            /// # NOTE
            ///
            /// > For ML-DSA we refer to ids reserved by <https://datatracker.ietf.org/doc/html/draft-ietf-tls-mldsa-01#name-ml-dsa-signaturescheme-valu>.
            const SIGALG_IANA_NAME: &CStr = c"mldsa87";

            /// The TLS algorithm ID value as given in the [IANA TLS SignatureScheme registry][IANA:tls-signaturescheme].
            ///
            /// [IANA:tls-signaturescheme]: https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-signaturescheme
            ///
            /// # NOTE
            ///
            /// > For ML-DSA we refer to ids reserved by <https://datatracker.ietf.org/doc/html/draft-ietf-tls-mldsa-01#name-ml-dsa-signaturescheme-valu>.
            const SIGALG_CODEPOINT: u32 = 0x0906; // 2310 in decimal notation

            /// A name for the signature algorithm as known by the provider.
            ///
            /// Note this is also the name that
            /// [`SSL_CONF_cmd(-sigalgs)`][SSL_CONF_cmd(3ossl):cli]/[`SSL_CONF_cmd(SignatureAlgorithms)`][SSL_CONF_cmd(3ossl):conf]
            /// will support.
            ///
            /// [SSL_CONF_cmd(3ossl):cli]: https://docs.openssl.org/master/man3/SSL_CONF_cmd/#supported-command-line-commands
            /// [SSL_CONF_cmd(3ossl):conf]: https://docs.openssl.org/master/man3/SSL_CONF_cmd/#supported-configuration-file-commands
            const SIGALG_NAME: &CStr = c"ML-DSA-87";

            /// The OID of the [`Self::SIGALG_SIG_NAME`] algorithm in canonical numeric text form. \[optional\]
            ///
            /// # NOTE
            ///
            /// > The OIDs for ML-DSA come from the [NIST Computer Security Objects Register](https://csrc.nist.gov/projects/computer-security-objects-register/algorithm-registration).
            ///
            /// > These values match the [values used in OpenSSL 3.5 in `providers/common/capabilities.c`](https://github.com/openssl/openssl/blob/97fbbc2f1f023d712d38263c824b6c5c8ffe6e61/providers/common/capabilities.c#L316-L320)
            const SIGALG_OID: Option<&CStr> = super::super::SIGALG_OID;

            const SECURITY_BITS: u32 = super::super::SECURITY_BITS;

            /// min TLS: v1.3
            const MIN_TLS: TLSVersion = TLSVersion::TLSv1_3;
            // use default values for MAX_TLS (none), MIN_DTLS (disabled), MAX_DTLS (disabled) (see doc-comment)
        }

        pub(crate) static OSSL_PARAM_ARRAY: &[CONST_OSSL_PARAM] =
            tls_sigalg::as_params!(TLSSigAlgCap);

        pub(crate) struct OQScompatCap;

        /// Implement [`TLSSigAlg`] for [`OQScompatCap`].
        ///
        /// This is identical to [`TLSSigAlgCap`], but uses `"mldsa87"` for [`TLSSigAlg::SIGALG_NAME`] for compatiblity with the OQS provider.
        impl TLSSigAlg for OQScompatCap {
            /// A name for the signature algorithm as known by the provider.
            ///
            /// Note this is also the name that
            /// [`SSL_CONF_cmd(-sigalgs)`][SSL_CONF_cmd(3ossl):cli]/[`SSL_CONF_cmd(SignatureAlgorithms)`][SSL_CONF_cmd(3ossl):conf]
            /// will support.
            ///
            /// Here we use `"mldsa87"` for compatiblity with the OQS provider.
            ///
            /// [SSL_CONF_cmd(3ossl):cli]: https://docs.openssl.org/master/man3/SSL_CONF_cmd/#supported-command-line-commands
            /// [SSL_CONF_cmd(3ossl):conf]: https://docs.openssl.org/master/man3/SSL_CONF_cmd/#supported-configuration-file-commands
            const SIGALG_NAME: &CStr = c"mldsa87";

            const SIGALG_IANA_NAME: &CStr = TLSSigAlgCap::SIGALG_IANA_NAME;
            const SIGALG_CODEPOINT: u32 = TLSSigAlgCap::SIGALG_CODEPOINT;
            const SECURITY_BITS: u32 = TLSSigAlgCap::SECURITY_BITS;

            /// If needed, this OID has already been defined
            const SIGALG_OID: Option<&CStr> = None;
            /// If needed, this OID has already been defined
            const SIGALG_SIG_OID: Option<&CStr> = None;
            /// If needed, this OID has already been defined
            const SIGALG_HASH_OID: Option<&CStr> = None;
            /// If needed, this OID has already been defined
            const SIGALG_KEYTYPE_OID: Option<&CStr> = None;

            const SIGALG_SIG_NAME: Option<&CStr> = TLSSigAlgCap::SIGALG_SIG_NAME;
            const SIGALG_HASH_NAME: Option<&CStr> = TLSSigAlgCap::SIGALG_HASH_NAME;
            const SIGALG_KEYTYPE: Option<&CStr> = TLSSigAlgCap::SIGALG_KEYTYPE;
            const MIN_TLS: TLSVersion = TLSSigAlgCap::MIN_TLS;
            const MAX_TLS: TLSVersion = TLSSigAlgCap::MAX_TLS;
            const MIN_DTLS: DTLSVersion = TLSSigAlgCap::MIN_DTLS;
            const MAX_DTLS: DTLSVersion = TLSSigAlgCap::MAX_DTLS;
        }

        pub(crate) static OSSL_PARAM_ARRAY_OQSCOMP: &[CONST_OSSL_PARAM] =
            tls_sigalg::as_params!(OQScompatCap);
    }
}

// TODO reenable typechecking in dispatch_table_entry macro and make sure these still compile!
// https://docs.openssl.org/3.2/man7/provider-signature/
pub(super) const SIG_FUNCTIONS: &[OSSL_DISPATCH] = &[
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_NEWCTX,
        OSSL_FUNC_signature_newctx_fn,
        signature_functions::newctx
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_FREECTX,
        OSSL_FUNC_signature_freectx_fn,
        signature_functions::freectx
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_SIGN_INIT,
        OSSL_FUNC_signature_sign_init_fn,
        signature_functions::sign_init
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_SIGN,
        OSSL_FUNC_signature_sign_fn,
        signature_functions::sign
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_VERIFY_INIT,
        OSSL_FUNC_signature_verify_init_fn,
        signature_functions::verify_init
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_VERIFY,
        OSSL_FUNC_signature_verify_fn,
        signature_functions::verify
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
        OSSL_FUNC_signature_digest_verify_init_fn,
        signature_functions::digest_verify_init
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_DIGEST_VERIFY,
        OSSL_FUNC_signature_digest_verify_fn,
        signature_functions::digest_verify
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
        OSSL_FUNC_signature_digest_sign_init_fn,
        signature_functions::digest_sign_init
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_DIGEST_SIGN,
        OSSL_FUNC_signature_digest_sign_fn,
        signature_functions::digest_sign
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
        OSSL_FUNC_signature_gettable_ctx_params_fn,
        signature_functions::gettable_ctx_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS,
        OSSL_FUNC_signature_get_ctx_params_fn,
        signature_functions::get_ctx_params
    ),
    #[cfg(any())]
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
        OSSL_FUNC_signature_settable_ctx_params_fn,
        signature_functions::settable_ctx_params
    ),
    #[cfg(any())]
    dispatch_table_entry!(
        OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS,
        OSSL_FUNC_signature_set_ctx_params_fn,
        signature_functions::set_ctx_params
    ),
    OSSL_DISPATCH::END,
];

// TODO reenable typechecking in dispatch_table_entry macro and make sure these still compile!
// https://docs.openssl.org/3.2/man7/provider-keymgmt/
pub(super) const KMGMT_FUNCTIONS: &[OSSL_DISPATCH] = &[
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_NEW,
        OSSL_FUNC_keymgmt_new_fn,
        keymgmt_functions::new
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_FREE,
        OSSL_FUNC_keymgmt_free_fn,
        keymgmt_functions::free
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_HAS,
        OSSL_FUNC_keymgmt_has_fn,
        keymgmt_functions::has
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GEN,
        OSSL_FUNC_keymgmt_gen_fn,
        keymgmt_functions::gen
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GEN_CLEANUP,
        OSSL_FUNC_keymgmt_gen_cleanup_fn,
        keymgmt_functions::gen_cleanup
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GEN_INIT,
        OSSL_FUNC_keymgmt_gen_init_fn,
        keymgmt_functions::gen_init
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS,
        OSSL_FUNC_keymgmt_gen_set_params_fn,
        keymgmt_functions::gen_set_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
        OSSL_FUNC_keymgmt_gen_settable_params_fn,
        keymgmt_functions::gen_settable_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GET_PARAMS,
        OSSL_FUNC_keymgmt_get_params_fn,
        keymgmt_functions::get_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS,
        OSSL_FUNC_keymgmt_gettable_params_fn,
        keymgmt_functions::gettable_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_SET_PARAMS,
        OSSL_FUNC_keymgmt_set_params_fn,
        keymgmt_functions::set_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS,
        OSSL_FUNC_keymgmt_settable_params_fn,
        keymgmt_functions::settable_params
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_IMPORT,
        OSSL_FUNC_keymgmt_import_fn,
        keymgmt_functions::import
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_EXPORT,
        OSSL_FUNC_keymgmt_export_fn,
        keymgmt_functions::export
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX,
        OSSL_FUNC_keymgmt_import_types_ex_fn,
        keymgmt_functions::import_types_ex
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX,
        OSSL_FUNC_keymgmt_export_types_ex_fn,
        keymgmt_functions::export_types_ex
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_LOAD,
        OSSL_FUNC_keymgmt_load_fn,
        keymgmt_functions::load
    ),
    dispatch_table_entry!(
        OSSL_FUNC_KEYMGMT_MATCH,
        OSSL_FUNC_keymgmt_match_fn,
        keymgmt_functions::match_
    ),
    OSSL_DISPATCH::END,
];

pub(super) use decoder_functions::DER2PrivateKeyInfo as DECODER_DER2PrivateKeyInfo;
pub(super) use decoder_functions::DER2SubjectPublicKeyInfo as DECODER_DER2SubjectPublicKeyInfo;
pub(super) use encoder_functions::PrivateKeyInfo2DER as ENCODER_PrivateKeyInfo2DER;
pub(super) use encoder_functions::PrivateKeyInfo2PEM as ENCODER_PrivateKeyInfo2PEM;
pub(super) use encoder_functions::PrivateKeyInfo2Text as ENCODER_PrivateKeyInfo2Text;
pub(super) use encoder_functions::PubKeyStructureless2Text as ENCODER_PubKeyStructureless2Text;
pub(super) use encoder_functions::SubjectPublicKeyInfo2DER as ENCODER_SubjectPublicKeyInfo2DER;
pub(super) use encoder_functions::SubjectPublicKeyInfo2PEM as ENCODER_SubjectPublicKeyInfo2PEM;

#[cfg(test)]
mod tests {
    use super::*;
    use crate::adapters::common::wycheproof::*;
    use signature::{Verifier, VerifierWithCtx};
    use wycheproof::mldsa_verify;

    struct Mldsa87;

    impl_sigalg_verify_variant!(Mldsa87, keymgmt_functions::PublicKey, signature::Signature);

    #[test]
    fn test_mldsa_87_verify_from_wycheproof() {
        crate::tests::common::setup().expect("Failed to initialize test setup");
        run_mldsa_wycheproof_verify_tests::<Mldsa87>(mldsa_verify::TestName::MlDsa87Verify);
    }

    use signature::{SignatureBytes, SignatureEncoding, Signer, SignerWithCtx};
    use wycheproof::mldsa_sign;

    impl_sigalg_sign_variant!(Mldsa87, keymgmt_functions::PrivateKey, signature::Signature);

    #[test]
    fn test_mldsa_87_sign_seed_from_wycheproof() {
        crate::tests::common::setup().expect("Failed to initialize test setup");
        run_mldsa_wycheproof_sign_tests::<Mldsa87>(
            mldsa_sign::TestName::MlDsa87SignSeed,
            // pqclean doesn't support deterministic ML-DSA
            false,
        );
    }

    #[test]
    fn test_mldsa_87_sign_noseed_from_wycheproof() {
        crate::tests::common::setup().expect("Failed to initialize test setup");
        run_mldsa_wycheproof_sign_tests::<Mldsa87>(
            mldsa_sign::TestName::MlDsa87SignNoSeed,
            // pqclean doesn't support deterministic ML-DSA
            false,
        );
    }
}