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