• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * \file ssl_ciphersuites.h
3  *
4  * \brief SSL Ciphersuites for mbed TLS
5  */
6 /*
7  *  Copyright The Mbed TLS Contributors
8  *  SPDX-License-Identifier: Apache-2.0
9  *
10  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
11  *  not use this file except in compliance with the License.
12  *  You may obtain a copy of the License at
13  *
14  *  http://www.apache.org/licenses/LICENSE-2.0
15  *
16  *  Unless required by applicable law or agreed to in writing, software
17  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  *  See the License for the specific language governing permissions and
20  *  limitations under the License.
21  */
22 #ifndef MBEDTLS_SSL_CIPHERSUITES_H
23 #define MBEDTLS_SSL_CIPHERSUITES_H
24 #include "mbedtls/private_access.h"
25 
26 #include "mbedtls/build_info.h"
27 
28 #include "mbedtls/pk.h"
29 #include "mbedtls/cipher.h"
30 #include "mbedtls/md.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Supported ciphersuites (Official IANA names)
38  */
39 #define MBEDTLS_TLS_RSA_WITH_NULL_MD5                    0x01   /**< Weak! */
40 #define MBEDTLS_TLS_RSA_WITH_NULL_SHA                    0x02   /**< Weak! */
41 
42 #define MBEDTLS_TLS_PSK_WITH_NULL_SHA                    0x2C   /**< Weak! */
43 #define MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA                0x2D   /**< Weak! */
44 #define MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA                0x2E   /**< Weak! */
45 #define MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA             0x2F
46 
47 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA         0x33
48 #define MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA             0x35
49 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA         0x39
50 
51 #define MBEDTLS_TLS_RSA_WITH_NULL_SHA256                 0x3B   /**< Weak! */
52 #define MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256          0x3C   /**< TLS 1.2 */
53 #define MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256          0x3D   /**< TLS 1.2 */
54 
55 #define MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA        0x41
56 #define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA    0x45
57 
58 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256      0x67   /**< TLS 1.2 */
59 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256      0x6B   /**< TLS 1.2 */
60 
61 #define MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA        0x84
62 #define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA    0x88
63 
64 #define MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA             0x8C
65 #define MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA             0x8D
66 
67 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA         0x90
68 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA         0x91
69 
70 #define MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA         0x94
71 #define MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA         0x95
72 
73 #define MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256          0x9C   /**< TLS 1.2 */
74 #define MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384          0x9D   /**< TLS 1.2 */
75 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256      0x9E   /**< TLS 1.2 */
76 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384      0x9F   /**< TLS 1.2 */
77 
78 #define MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256          0xA8   /**< TLS 1.2 */
79 #define MBEDTLS_TLS_PSK_WITH_AES_256_GCM_SHA384          0xA9   /**< TLS 1.2 */
80 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256      0xAA   /**< TLS 1.2 */
81 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384      0xAB   /**< TLS 1.2 */
82 #define MBEDTLS_TLS_RSA_PSK_WITH_AES_128_GCM_SHA256      0xAC   /**< TLS 1.2 */
83 #define MBEDTLS_TLS_RSA_PSK_WITH_AES_256_GCM_SHA384      0xAD   /**< TLS 1.2 */
84 
85 #define MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA256          0xAE
86 #define MBEDTLS_TLS_PSK_WITH_AES_256_CBC_SHA384          0xAF
87 #define MBEDTLS_TLS_PSK_WITH_NULL_SHA256                 0xB0   /**< Weak! */
88 #define MBEDTLS_TLS_PSK_WITH_NULL_SHA384                 0xB1   /**< Weak! */
89 
90 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256      0xB2
91 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384      0xB3
92 #define MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA256             0xB4   /**< Weak! */
93 #define MBEDTLS_TLS_DHE_PSK_WITH_NULL_SHA384             0xB5   /**< Weak! */
94 
95 #define MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA256      0xB6
96 #define MBEDTLS_TLS_RSA_PSK_WITH_AES_256_CBC_SHA384      0xB7
97 #define MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA256             0xB8   /**< Weak! */
98 #define MBEDTLS_TLS_RSA_PSK_WITH_NULL_SHA384             0xB9   /**< Weak! */
99 
100 #define MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256     0xBA   /**< TLS 1.2 */
101 #define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0xBE   /**< TLS 1.2 */
102 
103 #define MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256     0xC0   /**< TLS 1.2 */
104 #define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0xC4   /**< TLS 1.2 */
105 
106 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA             0xC001 /**< Weak! */
107 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA      0xC004
108 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA      0xC005
109 
110 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA            0xC006 /**< Weak! */
111 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA     0xC009
112 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA     0xC00A
113 
114 #define MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA               0xC00B /**< Weak! */
115 #define MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA        0xC00E
116 #define MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA        0xC00F
117 
118 #define MBEDTLS_TLS_ECDHE_RSA_WITH_NULL_SHA              0xC010 /**< Weak! */
119 #define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA       0xC013
120 #define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA       0xC014
121 
122 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256  0xC023 /**< TLS 1.2 */
123 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384  0xC024 /**< TLS 1.2 */
124 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256   0xC025 /**< TLS 1.2 */
125 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384   0xC026 /**< TLS 1.2 */
126 #define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256    0xC027 /**< TLS 1.2 */
127 #define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384    0xC028 /**< TLS 1.2 */
128 #define MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256     0xC029 /**< TLS 1.2 */
129 #define MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384     0xC02A /**< TLS 1.2 */
130 
131 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256  0xC02B /**< TLS 1.2 */
132 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384  0xC02C /**< TLS 1.2 */
133 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256   0xC02D /**< TLS 1.2 */
134 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384   0xC02E /**< TLS 1.2 */
135 #define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256    0xC02F /**< TLS 1.2 */
136 #define MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384    0xC030 /**< TLS 1.2 */
137 #define MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256     0xC031 /**< TLS 1.2 */
138 #define MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384     0xC032 /**< TLS 1.2 */
139 
140 #define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA       0xC035
141 #define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA       0xC036
142 #define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256    0xC037
143 #define MBEDTLS_TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384    0xC038
144 #define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA              0xC039
145 #define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA256           0xC03A
146 #define MBEDTLS_TLS_ECDHE_PSK_WITH_NULL_SHA384           0xC03B
147 
148 #define MBEDTLS_TLS_RSA_WITH_ARIA_128_CBC_SHA256         0xC03C /**< TLS 1.2 */
149 #define MBEDTLS_TLS_RSA_WITH_ARIA_256_CBC_SHA384         0xC03D /**< TLS 1.2 */
150 #define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256     0xC044 /**< TLS 1.2 */
151 #define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384     0xC045 /**< TLS 1.2 */
152 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 0xC048 /**< TLS 1.2 */
153 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 0xC049 /**< TLS 1.2 */
154 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256  0xC04A /**< TLS 1.2 */
155 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384  0xC04B /**< TLS 1.2 */
156 #define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256   0xC04C /**< TLS 1.2 */
157 #define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384   0xC04D /**< TLS 1.2 */
158 #define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256    0xC04E /**< TLS 1.2 */
159 #define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384    0xC04F /**< TLS 1.2 */
160 #define MBEDTLS_TLS_RSA_WITH_ARIA_128_GCM_SHA256         0xC050 /**< TLS 1.2 */
161 #define MBEDTLS_TLS_RSA_WITH_ARIA_256_GCM_SHA384         0xC051 /**< TLS 1.2 */
162 #define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256     0xC052 /**< TLS 1.2 */
163 #define MBEDTLS_TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384     0xC053 /**< TLS 1.2 */
164 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 0xC05C /**< TLS 1.2 */
165 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 0xC05D /**< TLS 1.2 */
166 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256  0xC05E /**< TLS 1.2 */
167 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384  0xC05F /**< TLS 1.2 */
168 #define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256   0xC060 /**< TLS 1.2 */
169 #define MBEDTLS_TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384   0xC061 /**< TLS 1.2 */
170 #define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256    0xC062 /**< TLS 1.2 */
171 #define MBEDTLS_TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384    0xC063 /**< TLS 1.2 */
172 #define MBEDTLS_TLS_PSK_WITH_ARIA_128_CBC_SHA256         0xC064 /**< TLS 1.2 */
173 #define MBEDTLS_TLS_PSK_WITH_ARIA_256_CBC_SHA384         0xC065 /**< TLS 1.2 */
174 #define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256     0xC066 /**< TLS 1.2 */
175 #define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384     0xC067 /**< TLS 1.2 */
176 #define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256     0xC068 /**< TLS 1.2 */
177 #define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384     0xC069 /**< TLS 1.2 */
178 #define MBEDTLS_TLS_PSK_WITH_ARIA_128_GCM_SHA256         0xC06A /**< TLS 1.2 */
179 #define MBEDTLS_TLS_PSK_WITH_ARIA_256_GCM_SHA384         0xC06B /**< TLS 1.2 */
180 #define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256     0xC06C /**< TLS 1.2 */
181 #define MBEDTLS_TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384     0xC06D /**< TLS 1.2 */
182 #define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256     0xC06E /**< TLS 1.2 */
183 #define MBEDTLS_TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384     0xC06F /**< TLS 1.2 */
184 #define MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256   0xC070 /**< TLS 1.2 */
185 #define MBEDTLS_TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384   0xC071 /**< TLS 1.2 */
186 
187 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0xC072
188 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0xC073
189 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256  0xC074
190 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384  0xC075
191 #define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256   0xC076
192 #define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384   0xC077
193 #define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256    0xC078
194 #define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384    0xC079
195 
196 #define MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256         0xC07A /**< TLS 1.2 */
197 #define MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384         0xC07B /**< TLS 1.2 */
198 #define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256     0xC07C /**< TLS 1.2 */
199 #define MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384     0xC07D /**< TLS 1.2 */
200 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 0xC086 /**< TLS 1.2 */
201 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 0xC087 /**< TLS 1.2 */
202 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256  0xC088 /**< TLS 1.2 */
203 #define MBEDTLS_TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384  0xC089 /**< TLS 1.2 */
204 #define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256   0xC08A /**< TLS 1.2 */
205 #define MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384   0xC08B /**< TLS 1.2 */
206 #define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256    0xC08C /**< TLS 1.2 */
207 #define MBEDTLS_TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384    0xC08D /**< TLS 1.2 */
208 
209 #define MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256       0xC08E /**< TLS 1.2 */
210 #define MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384       0xC08F /**< TLS 1.2 */
211 #define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256   0xC090 /**< TLS 1.2 */
212 #define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384   0xC091 /**< TLS 1.2 */
213 #define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256   0xC092 /**< TLS 1.2 */
214 #define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384   0xC093 /**< TLS 1.2 */
215 
216 #define MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256       0xC094
217 #define MBEDTLS_TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384       0xC095
218 #define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256   0xC096
219 #define MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384   0xC097
220 #define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256   0xC098
221 #define MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384   0xC099
222 #define MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0xC09A
223 #define MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0xC09B
224 
225 #define MBEDTLS_TLS_RSA_WITH_AES_128_CCM                0xC09C  /**< TLS 1.2 */
226 #define MBEDTLS_TLS_RSA_WITH_AES_256_CCM                0xC09D  /**< TLS 1.2 */
227 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM            0xC09E  /**< TLS 1.2 */
228 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM            0xC09F  /**< TLS 1.2 */
229 #define MBEDTLS_TLS_RSA_WITH_AES_128_CCM_8              0xC0A0  /**< TLS 1.2 */
230 #define MBEDTLS_TLS_RSA_WITH_AES_256_CCM_8              0xC0A1  /**< TLS 1.2 */
231 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM_8          0xC0A2  /**< TLS 1.2 */
232 #define MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM_8          0xC0A3  /**< TLS 1.2 */
233 #define MBEDTLS_TLS_PSK_WITH_AES_128_CCM                0xC0A4  /**< TLS 1.2 */
234 #define MBEDTLS_TLS_PSK_WITH_AES_256_CCM                0xC0A5  /**< TLS 1.2 */
235 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM            0xC0A6  /**< TLS 1.2 */
236 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM            0xC0A7  /**< TLS 1.2 */
237 #define MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8              0xC0A8  /**< TLS 1.2 */
238 #define MBEDTLS_TLS_PSK_WITH_AES_256_CCM_8              0xC0A9  /**< TLS 1.2 */
239 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CCM_8          0xC0AA  /**< TLS 1.2 */
240 #define MBEDTLS_TLS_DHE_PSK_WITH_AES_256_CCM_8          0xC0AB  /**< TLS 1.2 */
241 /* The last two are named with PSK_DHE in the RFC, which looks like a typo */
242 
243 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM        0xC0AC  /**< TLS 1.2 */
244 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM        0xC0AD  /**< TLS 1.2 */
245 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8      0xC0AE  /**< TLS 1.2 */
246 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8      0xC0AF  /**< TLS 1.2 */
247 
248 #define MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8          0xC0FF  /**< experimental */
249 
250 /* RFC 7905 */
251 #define MBEDTLS_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256   0xCCA8 /**< TLS 1.2 */
252 #define MBEDTLS_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 0xCCA9 /**< TLS 1.2 */
253 #define MBEDTLS_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256     0xCCAA /**< TLS 1.2 */
254 #define MBEDTLS_TLS_PSK_WITH_CHACHA20_POLY1305_SHA256         0xCCAB /**< TLS 1.2 */
255 #define MBEDTLS_TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256   0xCCAC /**< TLS 1.2 */
256 #define MBEDTLS_TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256     0xCCAD /**< TLS 1.2 */
257 #define MBEDTLS_TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256     0xCCAE /**< TLS 1.2 */
258 
259 /* RFC 8446, Appendix B.4 */
260 #define MBEDTLS_TLS1_3_AES_128_GCM_SHA256                     0x1301 /**< TLS 1.3 */
261 #define MBEDTLS_TLS1_3_AES_256_GCM_SHA384                     0x1302 /**< TLS 1.3 */
262 #define MBEDTLS_TLS1_3_CHACHA20_POLY1305_SHA256               0x1303 /**< TLS 1.3 */
263 #define MBEDTLS_TLS1_3_AES_128_CCM_SHA256                     0x1304 /**< TLS 1.3 */
264 #define MBEDTLS_TLS1_3_AES_128_CCM_8_SHA256                   0x1305 /**< TLS 1.3 */
265 
266 /* Reminder: update mbedtls_ssl_premaster_secret when adding a new key exchange.
267  * Reminder: update MBEDTLS_KEY_EXCHANGE__xxx below
268  */
269 typedef enum {
270     MBEDTLS_KEY_EXCHANGE_NONE = 0,
271     MBEDTLS_KEY_EXCHANGE_RSA,
272     MBEDTLS_KEY_EXCHANGE_DHE_RSA,
273     MBEDTLS_KEY_EXCHANGE_ECDHE_RSA,
274     MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA,
275     MBEDTLS_KEY_EXCHANGE_PSK,
276     MBEDTLS_KEY_EXCHANGE_DHE_PSK,
277     MBEDTLS_KEY_EXCHANGE_RSA_PSK,
278     MBEDTLS_KEY_EXCHANGE_ECDHE_PSK,
279     MBEDTLS_KEY_EXCHANGE_ECDH_RSA,
280     MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA,
281     MBEDTLS_KEY_EXCHANGE_ECJPAKE,
282 } mbedtls_key_exchange_type_t;
283 
284 /* Key exchanges using a certificate */
285 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)           || \
286     defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)       || \
287     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)     || \
288     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)   || \
289     defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)       || \
290     defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)      || \
291     defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
292 #define MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED
293 #endif
294 
295 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED) || \
296     defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED)
297 #define MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED
298 #endif
299 
300 /* Key exchanges allowing client certificate requests */
301 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)           ||       \
302     defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)       ||       \
303     defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)      ||       \
304     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)     ||       \
305     defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)    ||       \
306     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
307 #define MBEDTLS_KEY_EXCHANGE_CERT_REQ_ALLOWED_ENABLED
308 #endif
309 
310 /* Key exchanges involving server signature in ServerKeyExchange */
311 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)       || \
312     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)     || \
313     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
314 #define MBEDTLS_KEY_EXCHANGE_WITH_SERVER_SIGNATURE_ENABLED
315 #endif
316 
317 /* Key exchanges using ECDH */
318 #if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED)      || \
319     defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)
320 #define MBEDTLS_KEY_EXCHANGE_SOME_ECDH_ENABLED
321 #endif
322 
323 /* Key exchanges that don't involve ephemeral keys */
324 #if defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED)           || \
325     defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)           || \
326     defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)       || \
327     defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDH_ENABLED)
328 #define MBEDTLS_KEY_EXCHANGE_SOME_NON_PFS_ENABLED
329 #endif
330 
331 /* Key exchanges that involve ephemeral keys */
332 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)       || \
333     defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)       || \
334     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)     || \
335     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)     || \
336     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)   || \
337     defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED)
338 #define MBEDTLS_KEY_EXCHANGE_SOME_PFS_ENABLED
339 #endif
340 
341 /* Key exchanges using a PSK */
342 #if defined(MBEDTLS_KEY_EXCHANGE_PSK_ENABLED)           || \
343     defined(MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED)       || \
344     defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)       || \
345     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
346 #define MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED
347 #endif
348 
349 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PSK_ENABLED) || \
350     defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_PSK_ENABLED)
351 #define MBEDTLS_SSL_HANDSHAKE_WITH_PSK_ENABLED
352 #endif
353 
354 /* Key exchanges using DHE */
355 #if defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED)       || \
356     defined(MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED)
357 #define MBEDTLS_KEY_EXCHANGE_SOME_DHE_ENABLED
358 #endif
359 
360 /* Key exchanges using ECDHE */
361 #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED)     || \
362     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)   || \
363     defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED)
364 #define MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED
365 #endif
366 
367 typedef struct mbedtls_ssl_ciphersuite_t mbedtls_ssl_ciphersuite_t;
368 
369 #define MBEDTLS_CIPHERSUITE_WEAK       0x01    /**< Weak ciphersuite flag  */
370 #define MBEDTLS_CIPHERSUITE_SHORT_TAG  0x02    /**< Short authentication tag,
371                                                      eg for CCM_8 */
372 #define MBEDTLS_CIPHERSUITE_NODTLS     0x04    /**< Can't be used with DTLS */
373 
374 /**
375  * \brief   This structure is used for storing ciphersuite information
376  *
377  * \note    members are defined using integral types instead of enums
378  *          in order to pack structure and reduce memory usage by internal
379  *          \c ciphersuite_definitions[]
380  */
381 struct mbedtls_ssl_ciphersuite_t {
382     int MBEDTLS_PRIVATE(id);
383     const char *MBEDTLS_PRIVATE(name);
384 
385     uint8_t MBEDTLS_PRIVATE(cipher);           /* mbedtls_cipher_type_t */
386     uint8_t MBEDTLS_PRIVATE(mac);              /* mbedtls_md_type_t */
387     uint8_t MBEDTLS_PRIVATE(key_exchange);     /* mbedtls_key_exchange_type_t */
388     uint8_t MBEDTLS_PRIVATE(flags);
389 
390     uint16_t MBEDTLS_PRIVATE(min_tls_version); /* mbedtls_ssl_protocol_version */
391     uint16_t MBEDTLS_PRIVATE(max_tls_version); /* mbedtls_ssl_protocol_version */
392 };
393 
394 const int *mbedtls_ssl_list_ciphersuites(void);
395 
396 const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string(const char *ciphersuite_name);
397 const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id(int ciphersuite_id);
398 
399 #if defined(MBEDTLS_PK_C)
400 mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_pk_alg(const mbedtls_ssl_ciphersuite_t *info);
401 #if defined(MBEDTLS_USE_PSA_CRYPTO)
402 psa_algorithm_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_alg(const mbedtls_ssl_ciphersuite_t *info);
403 psa_key_usage_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_usage(const mbedtls_ssl_ciphersuite_t *info);
404 #endif
405 mbedtls_pk_type_t mbedtls_ssl_get_ciphersuite_sig_alg(const mbedtls_ssl_ciphersuite_t *info);
406 #endif
407 
408 int mbedtls_ssl_ciphersuite_uses_ec(const mbedtls_ssl_ciphersuite_t *info);
409 int mbedtls_ssl_ciphersuite_uses_psk(const mbedtls_ssl_ciphersuite_t *info);
410 
mbedtls_ssl_ciphersuite_get_name(const mbedtls_ssl_ciphersuite_t * info)411 static inline const char *mbedtls_ssl_ciphersuite_get_name(const mbedtls_ssl_ciphersuite_t *info)
412 {
413     return info->MBEDTLS_PRIVATE(name);
414 }
415 
416 size_t mbedtls_ssl_ciphersuite_get_cipher_key_bitlen(const mbedtls_ssl_ciphersuite_t *info);
417 
418 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_PFS_ENABLED)
mbedtls_ssl_ciphersuite_has_pfs(const mbedtls_ssl_ciphersuite_t * info)419 static inline int mbedtls_ssl_ciphersuite_has_pfs(const mbedtls_ssl_ciphersuite_t *info)
420 {
421     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
422         case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
423         case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
424         case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
425         case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
426         case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
427         case MBEDTLS_KEY_EXCHANGE_ECJPAKE:
428             return 1;
429 
430         default:
431             return 0;
432     }
433 }
434 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_PFS_ENABLED */
435 
436 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_NON_PFS_ENABLED)
mbedtls_ssl_ciphersuite_no_pfs(const mbedtls_ssl_ciphersuite_t * info)437 static inline int mbedtls_ssl_ciphersuite_no_pfs(const mbedtls_ssl_ciphersuite_t *info)
438 {
439     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
440         case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
441         case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
442         case MBEDTLS_KEY_EXCHANGE_RSA:
443         case MBEDTLS_KEY_EXCHANGE_PSK:
444         case MBEDTLS_KEY_EXCHANGE_RSA_PSK:
445             return 1;
446 
447         default:
448             return 0;
449     }
450 }
451 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_NON_PFS_ENABLED */
452 
453 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDH_ENABLED)
mbedtls_ssl_ciphersuite_uses_ecdh(const mbedtls_ssl_ciphersuite_t * info)454 static inline int mbedtls_ssl_ciphersuite_uses_ecdh(const mbedtls_ssl_ciphersuite_t *info)
455 {
456     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
457         case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
458         case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
459             return 1;
460 
461         default:
462             return 0;
463     }
464 }
465 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDH_ENABLED */
466 
mbedtls_ssl_ciphersuite_cert_req_allowed(const mbedtls_ssl_ciphersuite_t * info)467 static inline int mbedtls_ssl_ciphersuite_cert_req_allowed(const mbedtls_ssl_ciphersuite_t *info)
468 {
469     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
470         case MBEDTLS_KEY_EXCHANGE_RSA:
471         case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
472         case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
473         case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
474         case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
475         case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
476             return 1;
477 
478         default:
479             return 0;
480     }
481 }
482 
mbedtls_ssl_ciphersuite_uses_srv_cert(const mbedtls_ssl_ciphersuite_t * info)483 static inline int mbedtls_ssl_ciphersuite_uses_srv_cert(const mbedtls_ssl_ciphersuite_t *info)
484 {
485     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
486         case MBEDTLS_KEY_EXCHANGE_RSA:
487         case MBEDTLS_KEY_EXCHANGE_RSA_PSK:
488         case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
489         case MBEDTLS_KEY_EXCHANGE_ECDH_RSA:
490         case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
491         case MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA:
492         case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
493             return 1;
494 
495         default:
496             return 0;
497     }
498 }
499 
500 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_DHE_ENABLED)
mbedtls_ssl_ciphersuite_uses_dhe(const mbedtls_ssl_ciphersuite_t * info)501 static inline int mbedtls_ssl_ciphersuite_uses_dhe(const mbedtls_ssl_ciphersuite_t *info)
502 {
503     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
504         case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
505         case MBEDTLS_KEY_EXCHANGE_DHE_PSK:
506             return 1;
507 
508         default:
509             return 0;
510     }
511 }
512 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_DHE_ENABLED) */
513 
514 #if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED)
mbedtls_ssl_ciphersuite_uses_ecdhe(const mbedtls_ssl_ciphersuite_t * info)515 static inline int mbedtls_ssl_ciphersuite_uses_ecdhe(const mbedtls_ssl_ciphersuite_t *info)
516 {
517     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
518         case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
519         case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
520         case MBEDTLS_KEY_EXCHANGE_ECDHE_PSK:
521             return 1;
522 
523         default:
524             return 0;
525     }
526 }
527 #endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDHE_ENABLED) */
528 
529 #if defined(MBEDTLS_KEY_EXCHANGE_WITH_SERVER_SIGNATURE_ENABLED)
mbedtls_ssl_ciphersuite_uses_server_signature(const mbedtls_ssl_ciphersuite_t * info)530 static inline int mbedtls_ssl_ciphersuite_uses_server_signature(
531     const mbedtls_ssl_ciphersuite_t *info)
532 {
533     switch (info->MBEDTLS_PRIVATE(key_exchange)) {
534         case MBEDTLS_KEY_EXCHANGE_DHE_RSA:
535         case MBEDTLS_KEY_EXCHANGE_ECDHE_RSA:
536         case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
537             return 1;
538 
539         default:
540             return 0;
541     }
542 }
543 #endif /* MBEDTLS_KEY_EXCHANGE_WITH_SERVER_SIGNATURE_ENABLED */
544 
545 #ifdef __cplusplus
546 }
547 #endif
548 
549 #endif /* ssl_ciphersuites.h */
550