Debian Codegraph @

crt/s2n/tls/s2n_certificate_keys.c

raw symbols SCIP
1 /*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16 #include "tls/s2n_certificate_keys.h"
17
18 #include <openssl/objects.h>
19
20 #include "utils/s2n_safety.h"
21
22 const struct s2n_certificate_key s2n_rsa_rsae_1024 = {
23 .public_key_libcrypto_nid = NID_rsaEncryption,
24 .name = "rsa_1024",
25 .bits = 1024,
26 };
27
28 const struct s2n_certificate_key s2n_rsa_rsae_2048 = {
29 .public_key_libcrypto_nid = NID_rsaEncryption,
30 .name = "rsa_2048",
31 .bits = 2048,
32 };
33
34 const struct s2n_certificate_key s2n_rsa_rsae_3072 = {
35 .public_key_libcrypto_nid = NID_rsaEncryption,
36 .name = "rsa_3072",
37 .bits = 3072,
38 };
39
40 const struct s2n_certificate_key s2n_rsa_rsae_4096 = {
41 .public_key_libcrypto_nid = NID_rsaEncryption,
42 .name = "rsa_4096",
43 .bits = 4096,
44 };
45
46 const struct s2n_certificate_key s2n_rsa_pss_1024 = {
47 .public_key_libcrypto_nid = NID_rsassaPss,
48 .name = "rsa_pss_1024",
49 .bits = 1024,
50 };
51
52 const struct s2n_certificate_key s2n_rsa_pss_2048 = {
53 .public_key_libcrypto_nid = NID_rsassaPss,
54 .name = "rsa_pss_2048",
55 .bits = 2048,
56 };
57
58 const struct s2n_certificate_key s2n_rsa_pss_3072 = {
59 .public_key_libcrypto_nid = NID_rsassaPss,
60 .name = "rsa_pss_3072",
61 .bits = 3072,
62 };
63
64 const struct s2n_certificate_key s2n_rsa_pss_4096 = {
65 .public_key_libcrypto_nid = NID_rsassaPss,
66 .name = "rsa_pss_4096",
67 .bits = 4096,
68 };
69
70 const struct s2n_certificate_key s2n_ec_p256 = {
71 .public_key_libcrypto_nid = NID_X9_62_prime256v1,
72 .name = "ecdsa_p256",
73 .bits = 256,
74 };
75
76 const struct s2n_certificate_key s2n_ec_p384 = {
77 .public_key_libcrypto_nid = NID_secp384r1,
78 .name = "ecdsa_p384",
79 .bits = 384,
80 };
81
82 const struct s2n_certificate_key s2n_ec_p521 = {
83 .public_key_libcrypto_nid = NID_secp521r1,
84 .name = "ecdsa_p521",
85 .bits = 521,
86 };
87
88 const struct s2n_certificate_key s2n_mldsa_87 = {
89 #if S2N_LIBCRYPTO_SUPPORTS_MLDSA
90 .public_key_libcrypto_nid = NID_PQDSA,
91 #else
92 .public_key_libcrypto_nid = NID_undef,
93 #endif
94 .name = "mldsa_87",
95 .bits = 20736, /* The ML-DSA-87 public key size is 2592 bytes. */
96 };
97
98 const struct s2n_certificate_key *s2n_certificate_keys_20250429[] = {
99 /**
100 *= https://www.rfc-editor.org/rfc/rfc9151#section-5.1
101 *# CNSA (D)TLS connections MUST use secp384r1
102 **/
103 &s2n_ec_p384,
104
105 /**
106 *= https://www.rfc-editor.org/rfc/rfc9151#section-5.2
107 *# CNSA specifies a minimum modulus size of 3072 bits; however, only two
108 *# modulus sizes (3072 bits and 4096 bits) are supported by this profile.
109 **/
110 &s2n_rsa_rsae_3072,
111 &s2n_rsa_rsae_4096,
112 &s2n_rsa_pss_3072,
113 &s2n_rsa_pss_4096,
114 };
115
116 struct s2n_certificate_key_preferences s2n_certificate_key_preferences_20250429 = {
117 .count = s2n_array_len(s2n_certificate_keys_20250429),
118 .certificate_keys = s2n_certificate_keys_20250429,
119 };
120
121 const struct s2n_certificate_key *s2n_certificate_keys_20260219[] = {
122 /* CNSA 2.0 */
123 &s2n_mldsa_87,
124 };
125
126 struct s2n_certificate_key_preferences s2n_certificate_key_preferences_20260219 = {
127 .count = s2n_array_len(s2n_certificate_keys_20260219),
128 .certificate_keys = s2n_certificate_keys_20260219,
129 };
130
131 const struct s2n_certificate_key *s2n_certificate_keys_20260220[] = {
132 /* CNSA 2.0 */
133 &s2n_mldsa_87,
134
135 /* CNSA 1.0 */
136 &s2n_ec_p384,
137 &s2n_rsa_rsae_3072,
138 &s2n_rsa_rsae_4096,
139 &s2n_rsa_pss_3072,
140 &s2n_rsa_pss_4096,
141 };
142
143 struct s2n_certificate_key_preferences s2n_certificate_key_preferences_20260220 = {
144 .count = s2n_array_len(s2n_certificate_keys_20260220),
145 .certificate_keys = s2n_certificate_keys_20260220,
146 };