Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/openssl/providers/common/der/der_ml_dsa_key.c
48383 views
1
/*
2
* Copyright 2025 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
/*
11
* DSA low level APIs are deprecated for public use, but still ok for
12
* internal use.
13
*/
14
#include "internal/deprecated.h"
15
16
#include "internal/packet.h"
17
#include "prov/der_ml_dsa.h"
18
19
int ossl_DER_w_algorithmIdentifier_ML_DSA(WPACKET *pkt, int tag, ML_DSA_KEY *key)
20
{
21
const uint8_t *alg;
22
size_t len;
23
const char *name = ossl_ml_dsa_key_get_name(key);
24
25
if (OPENSSL_strcasecmp(name, "ML-DSA-44") == 0) {
26
alg = ossl_der_oid_id_ml_dsa_44;
27
len = sizeof(ossl_der_oid_id_ml_dsa_44);
28
} else if (OPENSSL_strcasecmp(name, "ML-DSA-65") == 0) {
29
alg = ossl_der_oid_id_ml_dsa_65;
30
len = sizeof(ossl_der_oid_id_ml_dsa_65);
31
} else if (OPENSSL_strcasecmp(name, "ML-DSA-87") == 0) {
32
alg = ossl_der_oid_id_ml_dsa_87;
33
len = sizeof(ossl_der_oid_id_ml_dsa_87);
34
} else {
35
return 0;
36
}
37
return ossl_DER_w_begin_sequence(pkt, tag)
38
/* No parameters */
39
&& ossl_DER_w_precompiled(pkt, -1, alg, len)
40
&& ossl_DER_w_end_sequence(pkt, tag);
41
}
42
43