]> jfr.im git - solanum.git/blob - librb/src/mbedtls_ratbox.h
MbedTLS: Adjust ciphersuite order and update documentation
[solanum.git] / librb / src / mbedtls_ratbox.h
1 /*
2 * librb: a library used by ircd-ratbox and other things
3 * mbedtls_ratbox.h: embedded data for ARM MbedTLS backend
4 *
5 * Copyright (C) 2016 Aaron Jones <aaronmdjones@gmail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
20 * USA
21 *
22 * $Id$
23 */
24
25 #ifndef RB_MBEDTLS_EMBEDDED_DATA_H
26 #define RB_MBEDTLS_EMBEDDED_DATA_H
27
28 #include "mbedtls/entropy.h"
29 #include "mbedtls/ctr_drbg.h"
30 #include "mbedtls/certs.h"
31 #include "mbedtls/x509.h"
32 #include "mbedtls/ssl.h"
33 #include "mbedtls/ssl_ciphersuites.h"
34 #include "mbedtls/net.h"
35 #include "mbedtls/error.h"
36 #include "mbedtls/debug.h"
37 #include "mbedtls/dhm.h"
38 #include "mbedtls/version.h"
39
40 /*
41 * Personalization string for CTR-DRBG initialization
42 */
43 static const char rb_mbedtls_personal_str[] = "charybdis/librb personalization string";
44
45 /*
46 * Default list of supported ciphersuites
47 * The user can override this with the ssl_cipher_list option in ircd.conf
48 *
49 * The format for this option is the same as the macro names below, but
50 * with underscores replaced with hyphens, and without the initial MBEDTLS_
51 *
52 * For example;
53 * ssl_cipher_list = "TLS-ECDHE-RSA-WITH-AES-256-GCM-SHA384"
54 *
55 * Multiple ciphersuites can be separated by colons (:)
56 *
57 * ************************************************************************
58 *
59 * The ordering of the following list should be intuitive. Within the list;
60 *
61 * * All AEAD forward-secret ciphersuites are located first [1]
62 * * All SHA2 forward-secret ciphersuites are located second
63 * * All remaining forward-secret ciphersuites are located third
64 * * All non-forward-secret ciphersuites are located last, in the same order
65 *
66 * [1] Because in practice, they are the only secure ciphersuites available;
67 * the ETM extension for CBC ciphersuites has not seen wide adoption.
68 *
69 * In practice, all clients SHOULD support an AEAD forward-secret cipher,
70 * which the server will then negotiate as they are preferred.
71 *
72 * This choice can be revisited in future; please consult me first. -- amdj
73 */
74 static const int rb_mbedtls_ciphersuites[] = {
75
76 // AEAD forward-secret ciphersuites
77
78 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
79 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384,
80 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
81 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384,
82 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
83 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384,
84 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CCM,
85 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CCM,
86
87 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
88 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256,
89 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
90 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256,
91 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
92 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256,
93 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
94 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CCM,
95
96 // SHA2 forward-secret ciphersuites
97
98 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
99 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384,
100 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
101 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384,
102 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
103 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256,
104
105 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
106 MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256,
107 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
108 MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
109 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
110 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256,
111
112 // Remaining forward-secret ciphersuites
113
114 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
115 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
116 MBEDTLS_TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
117 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,
118
119 MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
120 MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
121 MBEDTLS_TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
122 MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,
123
124 // Non-forward-secret ciphersuites
125
126 MBEDTLS_TLS_RSA_WITH_AES_256_GCM_SHA384,
127 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384,
128 MBEDTLS_TLS_RSA_WITH_AES_256_CCM,
129
130 MBEDTLS_TLS_RSA_WITH_AES_128_GCM_SHA256,
131 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256,
132 MBEDTLS_TLS_RSA_WITH_AES_128_CCM,
133
134 MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA256,
135 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256,
136
137 MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA256,
138 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256,
139
140 MBEDTLS_TLS_RSA_WITH_AES_256_CBC_SHA,
141 MBEDTLS_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA,
142
143 MBEDTLS_TLS_RSA_WITH_AES_128_CBC_SHA,
144 MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA,
145
146 // The end of list sentinel
147 0
148 };
149
150 /*
151 * YES, this is a hardcoded CA certificate.
152 *
153 * BEFORE YOU THROW YOUR ARMS UP IN A PANIC ABOUT A BACKDOOR, READ THIS TEXT!
154 *
155 * ARM mbedTLS requires a CA certificate to be set in its configuration before it will
156 * request a client certificate from peers. Since we want to do that, and not all
157 * installations will have a CA certificate to hand, we have this.
158 *
159 * Its key was securely destroyed after being generated, but even if it wasn't, that
160 * doesn't matter; the IRCd will accept ALL certificates, whether signed by this CA
161 * certificate or not!
162 *
163 * After all, it only cares about certificates in as far as to generate a fingerprint
164 * for them.
165 *
166 * Yes, this is a massive hack, but there is no alternative.
167 */
168
169 static const unsigned char rb_mbedtls_dummy_ca_certificate[825] = {
170 0x30, 0x82, 0x03, 0x35, 0x30, 0x82, 0x02, 0x1D, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00,
171 0x86, 0xC5, 0x1F, 0x62, 0xBE, 0xFC, 0x0B, 0xA8, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
172 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x30, 0x31, 0x31, 0x2F, 0x30, 0x2D, 0x06, 0x03, 0x55,
173 0x04, 0x03, 0x0C, 0x26, 0x43, 0x68, 0x61, 0x72, 0x79, 0x62, 0x64, 0x69, 0x73, 0x20, 0x6D, 0x62,
174 0x65, 0x64, 0x54, 0x4C, 0x53, 0x20, 0x44, 0x75, 0x6D, 0x6D, 0x79, 0x20, 0x43, 0x41, 0x20, 0x43,
175 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x36,
176 0x30, 0x35, 0x30, 0x34, 0x30, 0x38, 0x35, 0x32, 0x35, 0x33, 0x5A, 0x17, 0x0D, 0x34, 0x33, 0x30,
177 0x39, 0x32, 0x30, 0x30, 0x38, 0x35, 0x32, 0x35, 0x33, 0x5A, 0x30, 0x31, 0x31, 0x2F, 0x30, 0x2D,
178 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x26, 0x43, 0x68, 0x61, 0x72, 0x79, 0x62, 0x64, 0x69, 0x73,
179 0x20, 0x6D, 0x62, 0x65, 0x64, 0x54, 0x4C, 0x53, 0x20, 0x44, 0x75, 0x6D, 0x6D, 0x79, 0x20, 0x43,
180 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x30, 0x82, 0x01,
181 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00,
182 0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xCA, 0x4B,
183 0xA6, 0xA1, 0x82, 0x5B, 0x06, 0xC6, 0x82, 0x76, 0x8E, 0xB2, 0x22, 0x37, 0x83, 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x45, 0x4A,
195 0x2F, 0x4D, 0xF5, 0x0E, 0x4F, 0xFF, 0xAC, 0xE0, 0x55, 0xF4, 0x86, 0x04, 0x1B, 0x60, 0xDF, 0x4C,
196 0x25, 0xB9, 0xEC, 0x10, 0x0C, 0x54, 0x16, 0xDF, 0x42, 0xF0, 0x07, 0x00, 0x28, 0x81, 0x7C, 0x95,
197 0xAA, 0xC1, 0x01, 0xA3, 0xB8, 0xDF, 0x68, 0xCB, 0x55, 0xA7, 0x80, 0xCC, 0xE5, 0x3D, 0xE1, 0x68,
198 0x10, 0x27, 0x56, 0x94, 0x67, 0xEC, 0x82, 0x66, 0x3D, 0x96, 0x76, 0xC3, 0xEE, 0x23, 0x02, 0x03,
199 0x01, 0x00, 0x01, 0xA3, 0x50, 0x30, 0x4E, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16,
200 0x04, 0x14, 0xFF, 0xC8, 0xBA, 0x56, 0x74, 0xB1, 0x03, 0xA9, 0x79, 0x55, 0xFA, 0x58, 0x86, 0x13,
201 0xDE, 0xC0, 0xFA, 0xF2, 0x94, 0x62, 0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30,
202 0x16, 0x80, 0x14, 0xFF, 0xC8, 0xBA, 0x56, 0x74, 0xB1, 0x03, 0xA9, 0x79, 0x55, 0xFA, 0x58, 0x86,
203 0x13, 0xDE, 0xC0, 0xFA, 0xF2, 0x94, 0x62, 0x30, 0x0C, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05,
204 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01,
205 0x01, 0x0B, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01, 0x00, 0x3D, 0x35, 0x69, 0x87, 0xEB, 0x41, 0xA9,
206 0x2A, 0x51, 0xF3, 0x28, 0x71, 0xB4, 0x06, 0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0xB8, 0xB3, 0xBF, 0x65, 0xD4, 0x52,
218 0x98, 0x06, 0xE6, 0x8A, 0xB1, 0x36, 0xEA, 0x39, 0xB3, 0x04, 0x2B, 0x6E, 0x64, 0x6E, 0xF3, 0x20,
219 0x74, 0xB6, 0x6E, 0x21, 0x3B, 0x99, 0xFE, 0x6E, 0x70, 0x48, 0x78, 0xEA, 0x31, 0x95, 0xB3, 0xB0,
220 0x0E, 0x48, 0x83, 0x35, 0xA9, 0x74, 0xBF, 0x45, 0x07, 0xC8, 0x5A, 0x12, 0xA2, 0x4D, 0x16, 0xDB,
221 0xB3, 0x1F, 0x72, 0xDE, 0x2A, 0x28, 0xFE, 0x7C, 0x2D
222 };
223
224 #endif /* RB_MBEDTLS_EMBEDDED_DATA_H */