1*0957b409SSimon J. Gerraty /*
2*0957b409SSimon J. Gerraty * Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
3*0957b409SSimon J. Gerraty *
4*0957b409SSimon J. Gerraty * Permission is hereby granted, free of charge, to any person obtaining
5*0957b409SSimon J. Gerraty * a copy of this software and associated documentation files (the
6*0957b409SSimon J. Gerraty * "Software"), to deal in the Software without restriction, including
7*0957b409SSimon J. Gerraty * without limitation the rights to use, copy, modify, merge, publish,
8*0957b409SSimon J. Gerraty * distribute, sublicense, and/or sell copies of the Software, and to
9*0957b409SSimon J. Gerraty * permit persons to whom the Software is furnished to do so, subject to
10*0957b409SSimon J. Gerraty * the following conditions:
11*0957b409SSimon J. Gerraty *
12*0957b409SSimon J. Gerraty * The above copyright notice and this permission notice shall be
13*0957b409SSimon J. Gerraty * included in all copies or substantial portions of the Software.
14*0957b409SSimon J. Gerraty *
15*0957b409SSimon J. Gerraty * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16*0957b409SSimon J. Gerraty * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*0957b409SSimon J. Gerraty * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18*0957b409SSimon J. Gerraty * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19*0957b409SSimon J. Gerraty * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20*0957b409SSimon J. Gerraty * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21*0957b409SSimon J. Gerraty * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22*0957b409SSimon J. Gerraty * SOFTWARE.
23*0957b409SSimon J. Gerraty */
24*0957b409SSimon J. Gerraty
25*0957b409SSimon J. Gerraty #include "brssl.h"
26*0957b409SSimon J. Gerraty #include "bearssl.h"
27*0957b409SSimon J. Gerraty
28*0957b409SSimon J. Gerraty /* see brssl.h */
29*0957b409SSimon J. Gerraty const protocol_version protocol_versions[] = {
30*0957b409SSimon J. Gerraty { "tls10", BR_TLS10, "TLS 1.0" },
31*0957b409SSimon J. Gerraty { "tls11", BR_TLS11, "TLS 1.1" },
32*0957b409SSimon J. Gerraty { "tls12", BR_TLS12, "TLS 1.2" },
33*0957b409SSimon J. Gerraty { NULL, 0, NULL }
34*0957b409SSimon J. Gerraty };
35*0957b409SSimon J. Gerraty
36*0957b409SSimon J. Gerraty /* see brssl.h */
37*0957b409SSimon J. Gerraty const hash_function hash_functions[] = {
38*0957b409SSimon J. Gerraty { "md5", &br_md5_vtable, "MD5" },
39*0957b409SSimon J. Gerraty { "sha1", &br_sha1_vtable, "SHA-1" },
40*0957b409SSimon J. Gerraty { "sha224", &br_sha224_vtable, "SHA-224" },
41*0957b409SSimon J. Gerraty { "sha256", &br_sha256_vtable, "SHA-256" },
42*0957b409SSimon J. Gerraty { "sha384", &br_sha384_vtable, "SHA-384" },
43*0957b409SSimon J. Gerraty { "sha512", &br_sha512_vtable, "SHA-512" },
44*0957b409SSimon J. Gerraty { NULL, 0, NULL }
45*0957b409SSimon J. Gerraty };
46*0957b409SSimon J. Gerraty
47*0957b409SSimon J. Gerraty /* see brssl.h */
48*0957b409SSimon J. Gerraty const cipher_suite cipher_suites[] = {
49*0957b409SSimon J. Gerraty {
50*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
51*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
52*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_CHAPOL | REQ_SHA256 | REQ_TLS12,
53*0957b409SSimon J. Gerraty "ECDHE with ECDSA, ChaCha20+Poly1305 encryption (TLS 1.2+)"
54*0957b409SSimon J. Gerraty },
55*0957b409SSimon J. Gerraty {
56*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
57*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
58*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_CHAPOL | REQ_SHA256 | REQ_TLS12,
59*0957b409SSimon J. Gerraty "ECDHE with RSA, ChaCha20+Poly1305 encryption (TLS 1.2+)"
60*0957b409SSimon J. Gerraty },
61*0957b409SSimon J. Gerraty {
62*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
63*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
64*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESGCM | REQ_SHA256 | REQ_TLS12,
65*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-128/GCM encryption (TLS 1.2+)"
66*0957b409SSimon J. Gerraty },
67*0957b409SSimon J. Gerraty {
68*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_AES_128_GCM_SHA256",
69*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
70*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_AESGCM | REQ_SHA256 | REQ_TLS12,
71*0957b409SSimon J. Gerraty "ECDHE with RSA, AES-128/GCM encryption (TLS 1.2+)"
72*0957b409SSimon J. Gerraty },
73*0957b409SSimon J. Gerraty {
74*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
75*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
76*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESGCM | REQ_SHA384 | REQ_TLS12,
77*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-256/GCM encryption (TLS 1.2+)"
78*0957b409SSimon J. Gerraty },
79*0957b409SSimon J. Gerraty {
80*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_AES_256_GCM_SHA384",
81*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
82*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_AESGCM | REQ_SHA384 | REQ_TLS12,
83*0957b409SSimon J. Gerraty "ECDHE with RSA, AES-256/GCM encryption (TLS 1.2+)"
84*0957b409SSimon J. Gerraty },
85*0957b409SSimon J. Gerraty {
86*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_128_CCM",
87*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_128_CCM,
88*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
89*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-128/CCM encryption (TLS 1.2+)"
90*0957b409SSimon J. Gerraty },
91*0957b409SSimon J. Gerraty {
92*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_256_CCM",
93*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_256_CCM,
94*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
95*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-256/CCM encryption (TLS 1.2+)"
96*0957b409SSimon J. Gerraty },
97*0957b409SSimon J. Gerraty {
98*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_128_CCM_8",
99*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8,
100*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
101*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-128/CCM_8 encryption (TLS 1.2+)"
102*0957b409SSimon J. Gerraty },
103*0957b409SSimon J. Gerraty {
104*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_256_CCM_8",
105*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8,
106*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
107*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-256/CCM_8 encryption (TLS 1.2+)"
108*0957b409SSimon J. Gerraty },
109*0957b409SSimon J. Gerraty {
110*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
111*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
112*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCBC | REQ_SHA256 | REQ_TLS12,
113*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-128/CBC + SHA-256 (TLS 1.2+)"
114*0957b409SSimon J. Gerraty },
115*0957b409SSimon J. Gerraty {
116*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_AES_128_CBC_SHA256",
117*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
118*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_AESCBC | REQ_SHA256 | REQ_TLS12,
119*0957b409SSimon J. Gerraty "ECDHE with RSA, AES-128/CBC + SHA-256 (TLS 1.2+)"
120*0957b409SSimon J. Gerraty },
121*0957b409SSimon J. Gerraty {
122*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
123*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
124*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCBC | REQ_SHA384 | REQ_TLS12,
125*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-256/CBC + SHA-384 (TLS 1.2+)"
126*0957b409SSimon J. Gerraty },
127*0957b409SSimon J. Gerraty {
128*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_AES_256_CBC_SHA384",
129*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
130*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_AESCBC | REQ_SHA384 | REQ_TLS12,
131*0957b409SSimon J. Gerraty "ECDHE with RSA, AES-256/CBC + SHA-384 (TLS 1.2+)"
132*0957b409SSimon J. Gerraty },
133*0957b409SSimon J. Gerraty {
134*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
135*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
136*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCBC | REQ_SHA1,
137*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-128/CBC + SHA-1"
138*0957b409SSimon J. Gerraty },
139*0957b409SSimon J. Gerraty {
140*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_AES_128_CBC_SHA",
141*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
142*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_AESCBC | REQ_SHA1,
143*0957b409SSimon J. Gerraty "ECDHE with RSA, AES-128/CBC + SHA-1"
144*0957b409SSimon J. Gerraty },
145*0957b409SSimon J. Gerraty {
146*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
147*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
148*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_AESCBC | REQ_SHA1,
149*0957b409SSimon J. Gerraty "ECDHE with ECDSA, AES-256/CBC + SHA-1"
150*0957b409SSimon J. Gerraty },
151*0957b409SSimon J. Gerraty {
152*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_AES_256_CBC_SHA",
153*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
154*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_AESCBC | REQ_SHA1,
155*0957b409SSimon J. Gerraty "ECDHE with RSA, AES-256/CBC + SHA-1"
156*0957b409SSimon J. Gerraty },
157*0957b409SSimon J. Gerraty {
158*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_AES_128_GCM_SHA256",
159*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
160*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESGCM | REQ_SHA256 | REQ_TLS12,
161*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), AES-128/GCM (TLS 1.2+)"
162*0957b409SSimon J. Gerraty },
163*0957b409SSimon J. Gerraty {
164*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_AES_128_GCM_SHA256",
165*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256,
166*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESGCM | REQ_SHA256 | REQ_TLS12,
167*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), AES-128/GCM (TLS 1.2+)"
168*0957b409SSimon J. Gerraty },
169*0957b409SSimon J. Gerraty {
170*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_AES_256_GCM_SHA384",
171*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
172*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESGCM | REQ_SHA384 | REQ_TLS12,
173*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), AES-256/GCM (TLS 1.2+)"
174*0957b409SSimon J. Gerraty },
175*0957b409SSimon J. Gerraty {
176*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_AES_256_GCM_SHA384",
177*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384,
178*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESGCM | REQ_SHA384 | REQ_TLS12,
179*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), AES-256/GCM (TLS 1.2+)"
180*0957b409SSimon J. Gerraty },
181*0957b409SSimon J. Gerraty {
182*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
183*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256,
184*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA256 | REQ_TLS12,
185*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), AES-128/CBC + HMAC/SHA-256 (TLS 1.2+)"
186*0957b409SSimon J. Gerraty },
187*0957b409SSimon J. Gerraty {
188*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_AES_128_CBC_SHA256",
189*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,
190*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA256 | REQ_TLS12,
191*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), AES-128/CBC + HMAC/SHA-256 (TLS 1.2+)"
192*0957b409SSimon J. Gerraty },
193*0957b409SSimon J. Gerraty {
194*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
195*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,
196*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA384 | REQ_TLS12,
197*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), AES-256/CBC + HMAC/SHA-384 (TLS 1.2+)"
198*0957b409SSimon J. Gerraty },
199*0957b409SSimon J. Gerraty {
200*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_AES_256_CBC_SHA384",
201*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384,
202*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA384 | REQ_TLS12,
203*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), AES-256/CBC + HMAC/SHA-384 (TLS 1.2+)"
204*0957b409SSimon J. Gerraty },
205*0957b409SSimon J. Gerraty {
206*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_AES_128_CBC_SHA",
207*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
208*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA1,
209*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), AES-128/CBC + HMAC/SHA-1"
210*0957b409SSimon J. Gerraty },
211*0957b409SSimon J. Gerraty {
212*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_AES_128_CBC_SHA",
213*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA,
214*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA1,
215*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), AES-128/CBC + HMAC/SHA-1"
216*0957b409SSimon J. Gerraty },
217*0957b409SSimon J. Gerraty {
218*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_AES_256_CBC_SHA",
219*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
220*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA1,
221*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), AES-256/CBC + HMAC/SHA-1"
222*0957b409SSimon J. Gerraty },
223*0957b409SSimon J. Gerraty {
224*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_AES_256_CBC_SHA",
225*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA,
226*0957b409SSimon J. Gerraty REQ_ECDH | REQ_AESCBC | REQ_SHA1,
227*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), AES-256/CBC + HMAC/SHA-1"
228*0957b409SSimon J. Gerraty },
229*0957b409SSimon J. Gerraty {
230*0957b409SSimon J. Gerraty "RSA_WITH_AES_128_GCM_SHA256",
231*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_128_GCM_SHA256,
232*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESGCM | REQ_SHA256 | REQ_TLS12,
233*0957b409SSimon J. Gerraty "RSA key exchange, AES-128/GCM encryption (TLS 1.2+)"
234*0957b409SSimon J. Gerraty },
235*0957b409SSimon J. Gerraty {
236*0957b409SSimon J. Gerraty "RSA_WITH_AES_256_GCM_SHA384",
237*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_256_GCM_SHA384,
238*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESGCM | REQ_SHA384 | REQ_TLS12,
239*0957b409SSimon J. Gerraty "RSA key exchange, AES-256/GCM encryption (TLS 1.2+)"
240*0957b409SSimon J. Gerraty },
241*0957b409SSimon J. Gerraty {
242*0957b409SSimon J. Gerraty "RSA_WITH_AES_128_CCM",
243*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_128_CCM,
244*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
245*0957b409SSimon J. Gerraty "RSA key exchange, AES-128/CCM encryption (TLS 1.2+)"
246*0957b409SSimon J. Gerraty },
247*0957b409SSimon J. Gerraty {
248*0957b409SSimon J. Gerraty "RSA_WITH_AES_256_CCM",
249*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_256_CCM,
250*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
251*0957b409SSimon J. Gerraty "RSA key exchange, AES-256/CCM encryption (TLS 1.2+)"
252*0957b409SSimon J. Gerraty },
253*0957b409SSimon J. Gerraty {
254*0957b409SSimon J. Gerraty "RSA_WITH_AES_128_CCM_8",
255*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_128_CCM_8,
256*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
257*0957b409SSimon J. Gerraty "RSA key exchange, AES-128/CCM_8 encryption (TLS 1.2+)"
258*0957b409SSimon J. Gerraty },
259*0957b409SSimon J. Gerraty {
260*0957b409SSimon J. Gerraty "RSA_WITH_AES_256_CCM_8",
261*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_256_CCM_8,
262*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCCM | REQ_SHA256 | REQ_TLS12,
263*0957b409SSimon J. Gerraty "RSA key exchange, AES-256/CCM_8 encryption (TLS 1.2+)"
264*0957b409SSimon J. Gerraty },
265*0957b409SSimon J. Gerraty {
266*0957b409SSimon J. Gerraty "RSA_WITH_AES_128_CBC_SHA256",
267*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_128_CBC_SHA256,
268*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCBC | REQ_SHA256 | REQ_TLS12,
269*0957b409SSimon J. Gerraty "RSA key exchange, AES-128/CBC + HMAC/SHA-256 (TLS 1.2+)"
270*0957b409SSimon J. Gerraty },
271*0957b409SSimon J. Gerraty {
272*0957b409SSimon J. Gerraty "RSA_WITH_AES_256_CBC_SHA256",
273*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_256_CBC_SHA256,
274*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCBC | REQ_SHA256 | REQ_TLS12,
275*0957b409SSimon J. Gerraty "RSA key exchange, AES-256/CBC + HMAC/SHA-256 (TLS 1.2+)"
276*0957b409SSimon J. Gerraty },
277*0957b409SSimon J. Gerraty {
278*0957b409SSimon J. Gerraty "RSA_WITH_AES_128_CBC_SHA",
279*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_128_CBC_SHA,
280*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCBC | REQ_SHA1,
281*0957b409SSimon J. Gerraty "RSA key exchange, AES-128/CBC + HMAC/SHA-1"
282*0957b409SSimon J. Gerraty },
283*0957b409SSimon J. Gerraty {
284*0957b409SSimon J. Gerraty "RSA_WITH_AES_256_CBC_SHA",
285*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_AES_256_CBC_SHA,
286*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_AESCBC | REQ_SHA1,
287*0957b409SSimon J. Gerraty "RSA key exchange, AES-256/CBC + HMAC/SHA-1"
288*0957b409SSimon J. Gerraty },
289*0957b409SSimon J. Gerraty {
290*0957b409SSimon J. Gerraty "ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
291*0957b409SSimon J. Gerraty BR_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA,
292*0957b409SSimon J. Gerraty REQ_ECDHE_ECDSA | REQ_3DESCBC | REQ_SHA1,
293*0957b409SSimon J. Gerraty "ECDHE with ECDSA, 3DES/CBC + SHA-1"
294*0957b409SSimon J. Gerraty },
295*0957b409SSimon J. Gerraty {
296*0957b409SSimon J. Gerraty "ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
297*0957b409SSimon J. Gerraty BR_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
298*0957b409SSimon J. Gerraty REQ_ECDHE_RSA | REQ_3DESCBC | REQ_SHA1,
299*0957b409SSimon J. Gerraty "ECDHE with RSA, 3DES/CBC + SHA-1"
300*0957b409SSimon J. Gerraty },
301*0957b409SSimon J. Gerraty {
302*0957b409SSimon J. Gerraty "ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",
303*0957b409SSimon J. Gerraty BR_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA,
304*0957b409SSimon J. Gerraty REQ_ECDH | REQ_3DESCBC | REQ_SHA1,
305*0957b409SSimon J. Gerraty "ECDH key exchange (EC cert), 3DES/CBC + HMAC/SHA-1"
306*0957b409SSimon J. Gerraty },
307*0957b409SSimon J. Gerraty {
308*0957b409SSimon J. Gerraty "ECDH_RSA_WITH_3DES_EDE_CBC_SHA",
309*0957b409SSimon J. Gerraty BR_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA,
310*0957b409SSimon J. Gerraty REQ_ECDH | REQ_3DESCBC | REQ_SHA1,
311*0957b409SSimon J. Gerraty "ECDH key exchange (RSA cert), 3DES/CBC + HMAC/SHA-1"
312*0957b409SSimon J. Gerraty },
313*0957b409SSimon J. Gerraty {
314*0957b409SSimon J. Gerraty "RSA_WITH_3DES_EDE_CBC_SHA",
315*0957b409SSimon J. Gerraty BR_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
316*0957b409SSimon J. Gerraty REQ_RSAKEYX | REQ_3DESCBC | REQ_SHA1,
317*0957b409SSimon J. Gerraty "RSA key exchange, 3DES/CBC + HMAC/SHA-1"
318*0957b409SSimon J. Gerraty },
319*0957b409SSimon J. Gerraty { NULL, 0, 0, NULL }
320*0957b409SSimon J. Gerraty };
321*0957b409SSimon J. Gerraty
322*0957b409SSimon J. Gerraty static const struct {
323*0957b409SSimon J. Gerraty int id;
324*0957b409SSimon J. Gerraty const char *name;
325*0957b409SSimon J. Gerraty const char *sid[4];
326*0957b409SSimon J. Gerraty } curves[] = {
327*0957b409SSimon J. Gerraty { BR_EC_sect163k1,
328*0957b409SSimon J. Gerraty "sect163k1",
329*0957b409SSimon J. Gerraty { "sect163k1", "K-163", NULL, NULL } },
330*0957b409SSimon J. Gerraty { BR_EC_sect163r1,
331*0957b409SSimon J. Gerraty "sect163r1",
332*0957b409SSimon J. Gerraty { "sect163r1", NULL, NULL, NULL } },
333*0957b409SSimon J. Gerraty { BR_EC_sect163r2,
334*0957b409SSimon J. Gerraty "sect163r2",
335*0957b409SSimon J. Gerraty { "sect163r2", "B-163", NULL, NULL } },
336*0957b409SSimon J. Gerraty { BR_EC_sect193r1,
337*0957b409SSimon J. Gerraty "sect193r1",
338*0957b409SSimon J. Gerraty { "sect193r1", NULL, NULL, NULL } },
339*0957b409SSimon J. Gerraty { BR_EC_sect193r2,
340*0957b409SSimon J. Gerraty "sect193r2",
341*0957b409SSimon J. Gerraty { "sect193r2", NULL, NULL, NULL } },
342*0957b409SSimon J. Gerraty { BR_EC_sect233k1,
343*0957b409SSimon J. Gerraty "sect233k1",
344*0957b409SSimon J. Gerraty { "sect233k1", "K-233", NULL, NULL } },
345*0957b409SSimon J. Gerraty { BR_EC_sect233r1,
346*0957b409SSimon J. Gerraty "sect233r1",
347*0957b409SSimon J. Gerraty { "sect233r1", "B-233", NULL, NULL } },
348*0957b409SSimon J. Gerraty { BR_EC_sect239k1,
349*0957b409SSimon J. Gerraty "sect239k1",
350*0957b409SSimon J. Gerraty { "sect239k1", NULL, NULL, NULL } },
351*0957b409SSimon J. Gerraty { BR_EC_sect283k1,
352*0957b409SSimon J. Gerraty "sect283k1",
353*0957b409SSimon J. Gerraty { "sect283k1", "K-283", NULL, NULL } },
354*0957b409SSimon J. Gerraty { BR_EC_sect283r1,
355*0957b409SSimon J. Gerraty "sect283r1",
356*0957b409SSimon J. Gerraty { "sect283r1", "B-283", NULL, NULL } },
357*0957b409SSimon J. Gerraty { BR_EC_sect409k1,
358*0957b409SSimon J. Gerraty "sect409k1",
359*0957b409SSimon J. Gerraty { "sect409k1", "K-409", NULL, NULL } },
360*0957b409SSimon J. Gerraty { BR_EC_sect409r1,
361*0957b409SSimon J. Gerraty "sect409r1",
362*0957b409SSimon J. Gerraty { "sect409r1", "B-409", NULL, NULL } },
363*0957b409SSimon J. Gerraty { BR_EC_sect571k1,
364*0957b409SSimon J. Gerraty "sect571k1",
365*0957b409SSimon J. Gerraty { "sect571k1", "K-571", NULL, NULL } },
366*0957b409SSimon J. Gerraty { BR_EC_sect571r1,
367*0957b409SSimon J. Gerraty "sect571r1",
368*0957b409SSimon J. Gerraty { "sect571r1", "B-571", NULL, NULL } },
369*0957b409SSimon J. Gerraty { BR_EC_secp160k1,
370*0957b409SSimon J. Gerraty "secp160k1",
371*0957b409SSimon J. Gerraty { "secp160k1", NULL, NULL, NULL } },
372*0957b409SSimon J. Gerraty { BR_EC_secp160r1,
373*0957b409SSimon J. Gerraty "secp160r1",
374*0957b409SSimon J. Gerraty { "secp160r1", NULL, NULL, NULL } },
375*0957b409SSimon J. Gerraty { BR_EC_secp160r2,
376*0957b409SSimon J. Gerraty "secp160r2",
377*0957b409SSimon J. Gerraty { "secp160r2", NULL, NULL, NULL } },
378*0957b409SSimon J. Gerraty { BR_EC_secp192k1,
379*0957b409SSimon J. Gerraty "secp192k1",
380*0957b409SSimon J. Gerraty { "secp192k1", NULL, NULL, NULL } },
381*0957b409SSimon J. Gerraty { BR_EC_secp192r1,
382*0957b409SSimon J. Gerraty "secp192r1",
383*0957b409SSimon J. Gerraty { "secp192r1", "P-192", NULL, NULL } },
384*0957b409SSimon J. Gerraty { BR_EC_secp224k1,
385*0957b409SSimon J. Gerraty "secp224k1",
386*0957b409SSimon J. Gerraty { "secp224k1", NULL, NULL, NULL } },
387*0957b409SSimon J. Gerraty { BR_EC_secp224r1,
388*0957b409SSimon J. Gerraty "secp224r1",
389*0957b409SSimon J. Gerraty { "secp224r1", "P-224", NULL, NULL } },
390*0957b409SSimon J. Gerraty { BR_EC_secp256k1,
391*0957b409SSimon J. Gerraty "secp256k1",
392*0957b409SSimon J. Gerraty { "secp256k1", NULL, NULL, NULL } },
393*0957b409SSimon J. Gerraty { BR_EC_secp256r1,
394*0957b409SSimon J. Gerraty "secp256r1 (P-256)",
395*0957b409SSimon J. Gerraty { "secp256r1", "P-256", "prime256v1", NULL } },
396*0957b409SSimon J. Gerraty { BR_EC_secp384r1,
397*0957b409SSimon J. Gerraty "secp384r1 (P-384)",
398*0957b409SSimon J. Gerraty { "secp384r1", "P-384", NULL, NULL } },
399*0957b409SSimon J. Gerraty { BR_EC_secp521r1,
400*0957b409SSimon J. Gerraty "secp521r1 (P-521)",
401*0957b409SSimon J. Gerraty { "secp521r1", "P-521", NULL, NULL } },
402*0957b409SSimon J. Gerraty { BR_EC_brainpoolP256r1,
403*0957b409SSimon J. Gerraty "brainpoolP256r1",
404*0957b409SSimon J. Gerraty { "brainpoolP256r1", NULL, NULL, NULL } },
405*0957b409SSimon J. Gerraty { BR_EC_brainpoolP384r1,
406*0957b409SSimon J. Gerraty "brainpoolP384r1",
407*0957b409SSimon J. Gerraty { "brainpoolP384r1", NULL, NULL, NULL } },
408*0957b409SSimon J. Gerraty { BR_EC_brainpoolP512r1,
409*0957b409SSimon J. Gerraty "brainpoolP512r1",
410*0957b409SSimon J. Gerraty { "brainpoolP512r1", NULL, NULL, NULL } },
411*0957b409SSimon J. Gerraty { BR_EC_curve25519,
412*0957b409SSimon J. Gerraty "Curve25519",
413*0957b409SSimon J. Gerraty { "curve25519", "c25519", NULL, NULL } },
414*0957b409SSimon J. Gerraty { BR_EC_curve448,
415*0957b409SSimon J. Gerraty "Curve448",
416*0957b409SSimon J. Gerraty { "curve448", "c448", NULL, NULL } },
417*0957b409SSimon J. Gerraty { 0, 0, { 0, 0, 0, 0 } }
418*0957b409SSimon J. Gerraty };
419*0957b409SSimon J. Gerraty
420*0957b409SSimon J. Gerraty static const struct {
421*0957b409SSimon J. Gerraty const char *long_name;
422*0957b409SSimon J. Gerraty const char *short_name;
423*0957b409SSimon J. Gerraty const void *impl;
424*0957b409SSimon J. Gerraty } algo_names[] = {
425*0957b409SSimon J. Gerraty /* Block ciphers */
426*0957b409SSimon J. Gerraty { "aes_big_cbcenc", "big", &br_aes_big_cbcenc_vtable },
427*0957b409SSimon J. Gerraty { "aes_big_cbcdec", "big", &br_aes_big_cbcdec_vtable },
428*0957b409SSimon J. Gerraty { "aes_big_ctr", "big", &br_aes_big_ctr_vtable },
429*0957b409SSimon J. Gerraty { "aes_big_ctrcbc", "big", &br_aes_big_ctrcbc_vtable },
430*0957b409SSimon J. Gerraty { "aes_small_cbcenc", "small", &br_aes_small_cbcenc_vtable },
431*0957b409SSimon J. Gerraty { "aes_small_cbcdec", "small", &br_aes_small_cbcdec_vtable },
432*0957b409SSimon J. Gerraty { "aes_small_ctr", "small", &br_aes_small_ctr_vtable },
433*0957b409SSimon J. Gerraty { "aes_small_ctrcbc", "small", &br_aes_small_ctrcbc_vtable },
434*0957b409SSimon J. Gerraty { "aes_ct_cbcenc", "ct", &br_aes_ct_cbcenc_vtable },
435*0957b409SSimon J. Gerraty { "aes_ct_cbcdec", "ct", &br_aes_ct_cbcdec_vtable },
436*0957b409SSimon J. Gerraty { "aes_ct_ctr", "ct", &br_aes_ct_ctr_vtable },
437*0957b409SSimon J. Gerraty { "aes_ct_ctrcbc", "ct", &br_aes_ct_ctrcbc_vtable },
438*0957b409SSimon J. Gerraty { "aes_ct64_cbcenc", "ct64", &br_aes_ct64_cbcenc_vtable },
439*0957b409SSimon J. Gerraty { "aes_ct64_cbcdec", "ct64", &br_aes_ct64_cbcdec_vtable },
440*0957b409SSimon J. Gerraty { "aes_ct64_ctr", "ct64", &br_aes_ct64_ctr_vtable },
441*0957b409SSimon J. Gerraty { "aes_ct64_ctrcbc", "ct64", &br_aes_ct64_ctrcbc_vtable },
442*0957b409SSimon J. Gerraty
443*0957b409SSimon J. Gerraty { "des_tab_cbcenc", "tab", &br_des_tab_cbcenc_vtable },
444*0957b409SSimon J. Gerraty { "des_tab_cbcdec", "tab", &br_des_tab_cbcdec_vtable },
445*0957b409SSimon J. Gerraty { "des_ct_cbcenc", "ct", &br_des_ct_cbcenc_vtable },
446*0957b409SSimon J. Gerraty { "des_ct_cbcdec", "ct", &br_des_ct_cbcdec_vtable },
447*0957b409SSimon J. Gerraty
448*0957b409SSimon J. Gerraty { "chacha20_ct", "ct", &br_chacha20_ct_run },
449*0957b409SSimon J. Gerraty
450*0957b409SSimon J. Gerraty { "ghash_ctmul", "ctmul", &br_ghash_ctmul },
451*0957b409SSimon J. Gerraty { "ghash_ctmul32", "ctmul32", &br_ghash_ctmul32 },
452*0957b409SSimon J. Gerraty { "ghash_ctmul64", "ctmul64", &br_ghash_ctmul64 },
453*0957b409SSimon J. Gerraty
454*0957b409SSimon J. Gerraty { "poly1305_ctmul", "ctmul", &br_poly1305_ctmul_run },
455*0957b409SSimon J. Gerraty { "poly1305_ctmul32", "ctmul32", &br_poly1305_ctmul32_run },
456*0957b409SSimon J. Gerraty
457*0957b409SSimon J. Gerraty { "ec_all_m15", "all_m15", &br_ec_all_m15 },
458*0957b409SSimon J. Gerraty { "ec_all_m31", "all_m31", &br_ec_all_m31 },
459*0957b409SSimon J. Gerraty { "ec_c25519_i15", "c25519_i15", &br_ec_c25519_i15 },
460*0957b409SSimon J. Gerraty { "ec_c25519_i31", "c25519_i31", &br_ec_c25519_i31 },
461*0957b409SSimon J. Gerraty { "ec_c25519_m15", "c25519_m15", &br_ec_c25519_m15 },
462*0957b409SSimon J. Gerraty { "ec_c25519_m31", "c25519_m31", &br_ec_c25519_m31 },
463*0957b409SSimon J. Gerraty { "ec_p256_m15", "p256_m15", &br_ec_p256_m15 },
464*0957b409SSimon J. Gerraty { "ec_p256_m31", "p256_m31", &br_ec_p256_m31 },
465*0957b409SSimon J. Gerraty { "ec_prime_i15", "prime_i15", &br_ec_prime_i15 },
466*0957b409SSimon J. Gerraty { "ec_prime_i31", "prime_i31", &br_ec_prime_i31 },
467*0957b409SSimon J. Gerraty
468*0957b409SSimon J. Gerraty { "ecdsa_i15_sign_asn1", "i15_asn1", &br_ecdsa_i15_sign_asn1 },
469*0957b409SSimon J. Gerraty { "ecdsa_i15_sign_raw", "i15_raw", &br_ecdsa_i15_sign_raw },
470*0957b409SSimon J. Gerraty { "ecdsa_i31_sign_asn1", "i31_asn1", &br_ecdsa_i31_sign_asn1 },
471*0957b409SSimon J. Gerraty { "ecdsa_i31_sign_raw", "i31_raw", &br_ecdsa_i31_sign_raw },
472*0957b409SSimon J. Gerraty { "ecdsa_i15_vrfy_asn1", "i15_asn1", &br_ecdsa_i15_vrfy_asn1 },
473*0957b409SSimon J. Gerraty { "ecdsa_i15_vrfy_raw", "i15_raw", &br_ecdsa_i15_vrfy_raw },
474*0957b409SSimon J. Gerraty { "ecdsa_i31_vrfy_asn1", "i31_asn1", &br_ecdsa_i31_vrfy_asn1 },
475*0957b409SSimon J. Gerraty { "ecdsa_i31_vrfy_raw", "i31_raw", &br_ecdsa_i31_vrfy_raw },
476*0957b409SSimon J. Gerraty
477*0957b409SSimon J. Gerraty { "rsa_i15_pkcs1_sign", "i15", &br_rsa_i15_pkcs1_sign },
478*0957b409SSimon J. Gerraty { "rsa_i31_pkcs1_sign", "i31", &br_rsa_i31_pkcs1_sign },
479*0957b409SSimon J. Gerraty { "rsa_i32_pkcs1_sign", "i32", &br_rsa_i32_pkcs1_sign },
480*0957b409SSimon J. Gerraty { "rsa_i15_pkcs1_vrfy", "i15", &br_rsa_i15_pkcs1_vrfy },
481*0957b409SSimon J. Gerraty { "rsa_i31_pkcs1_vrfy", "i31", &br_rsa_i31_pkcs1_vrfy },
482*0957b409SSimon J. Gerraty { "rsa_i32_pkcs1_vrfy", "i32", &br_rsa_i32_pkcs1_vrfy },
483*0957b409SSimon J. Gerraty
484*0957b409SSimon J. Gerraty { 0, 0, 0 }
485*0957b409SSimon J. Gerraty };
486*0957b409SSimon J. Gerraty
487*0957b409SSimon J. Gerraty static const struct {
488*0957b409SSimon J. Gerraty const char *long_name;
489*0957b409SSimon J. Gerraty const char *short_name;
490*0957b409SSimon J. Gerraty const void *(*get)(void);
491*0957b409SSimon J. Gerraty } algo_names_dyn[] = {
492*0957b409SSimon J. Gerraty { "aes_pwr8_cbcenc", "pwr8",
493*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_pwr8_cbcenc_get_vtable },
494*0957b409SSimon J. Gerraty { "aes_pwr8_cbcdec", "pwr8",
495*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_pwr8_cbcdec_get_vtable },
496*0957b409SSimon J. Gerraty { "aes_pwr8_ctr", "pwr8",
497*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_pwr8_ctr_get_vtable },
498*0957b409SSimon J. Gerraty { "aes_pwr8_ctrcbc", "pwr8",
499*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_pwr8_ctrcbc_get_vtable },
500*0957b409SSimon J. Gerraty { "aes_x86ni_cbcenc", "x86ni",
501*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_x86ni_cbcenc_get_vtable },
502*0957b409SSimon J. Gerraty { "aes_x86ni_cbcdec", "x86ni",
503*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_x86ni_cbcdec_get_vtable },
504*0957b409SSimon J. Gerraty { "aes_x86ni_ctr", "x86ni",
505*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_x86ni_ctr_get_vtable },
506*0957b409SSimon J. Gerraty { "aes_x86ni_ctrcbc", "x86ni",
507*0957b409SSimon J. Gerraty (const void *(*)(void))&br_aes_x86ni_ctrcbc_get_vtable },
508*0957b409SSimon J. Gerraty { "chacha20_sse2", "sse2",
509*0957b409SSimon J. Gerraty (const void *(*)(void))&br_chacha20_sse2_get },
510*0957b409SSimon J. Gerraty { "ghash_pclmul", "pclmul",
511*0957b409SSimon J. Gerraty (const void *(*)(void))&br_ghash_pclmul_get },
512*0957b409SSimon J. Gerraty { "ghash_pwr8", "pwr8",
513*0957b409SSimon J. Gerraty (const void *(*)(void))&br_ghash_pwr8_get },
514*0957b409SSimon J. Gerraty { "poly1305_ctmulq", "ctmulq",
515*0957b409SSimon J. Gerraty (const void *(*)(void))&br_poly1305_ctmulq_get },
516*0957b409SSimon J. Gerraty { "rsa_i62_pkcs1_sign", "i62",
517*0957b409SSimon J. Gerraty (const void *(*)(void))&br_rsa_i62_pkcs1_sign_get },
518*0957b409SSimon J. Gerraty { "rsa_i62_pkcs1_vrfy", "i62",
519*0957b409SSimon J. Gerraty (const void *(*)(void))&br_rsa_i62_pkcs1_vrfy_get },
520*0957b409SSimon J. Gerraty { "ec_c25519_m62", "m62",
521*0957b409SSimon J. Gerraty (const void *(*)(void))&br_ec_c25519_m62_get },
522*0957b409SSimon J. Gerraty { "ec_c25519_m64", "m64",
523*0957b409SSimon J. Gerraty (const void *(*)(void))&br_ec_c25519_m64_get },
524*0957b409SSimon J. Gerraty { "ec_p256_m62", "m62",
525*0957b409SSimon J. Gerraty (const void *(*)(void))&br_ec_p256_m62_get },
526*0957b409SSimon J. Gerraty { "ec_p256_m64", "m64",
527*0957b409SSimon J. Gerraty (const void *(*)(void))&br_ec_p256_m64_get },
528*0957b409SSimon J. Gerraty { 0, 0, 0, }
529*0957b409SSimon J. Gerraty };
530*0957b409SSimon J. Gerraty
531*0957b409SSimon J. Gerraty /* see brssl.h */
532*0957b409SSimon J. Gerraty const char *
get_algo_name(const void * impl,int long_name)533*0957b409SSimon J. Gerraty get_algo_name(const void *impl, int long_name)
534*0957b409SSimon J. Gerraty {
535*0957b409SSimon J. Gerraty size_t u;
536*0957b409SSimon J. Gerraty
537*0957b409SSimon J. Gerraty for (u = 0; algo_names[u].long_name; u ++) {
538*0957b409SSimon J. Gerraty if (impl == algo_names[u].impl) {
539*0957b409SSimon J. Gerraty return long_name
540*0957b409SSimon J. Gerraty ? algo_names[u].long_name
541*0957b409SSimon J. Gerraty : algo_names[u].short_name;
542*0957b409SSimon J. Gerraty }
543*0957b409SSimon J. Gerraty }
544*0957b409SSimon J. Gerraty for (u = 0; algo_names_dyn[u].long_name; u ++) {
545*0957b409SSimon J. Gerraty if (impl == algo_names_dyn[u].get()) {
546*0957b409SSimon J. Gerraty return long_name
547*0957b409SSimon J. Gerraty ? algo_names_dyn[u].long_name
548*0957b409SSimon J. Gerraty : algo_names_dyn[u].short_name;
549*0957b409SSimon J. Gerraty }
550*0957b409SSimon J. Gerraty }
551*0957b409SSimon J. Gerraty return "UNKNOWN";
552*0957b409SSimon J. Gerraty }
553*0957b409SSimon J. Gerraty
554*0957b409SSimon J. Gerraty /* see brssl.h */
555*0957b409SSimon J. Gerraty const char *
get_curve_name(int id)556*0957b409SSimon J. Gerraty get_curve_name(int id)
557*0957b409SSimon J. Gerraty {
558*0957b409SSimon J. Gerraty size_t u;
559*0957b409SSimon J. Gerraty
560*0957b409SSimon J. Gerraty for (u = 0; curves[u].name; u ++) {
561*0957b409SSimon J. Gerraty if (curves[u].id == id) {
562*0957b409SSimon J. Gerraty return curves[u].name;
563*0957b409SSimon J. Gerraty }
564*0957b409SSimon J. Gerraty }
565*0957b409SSimon J. Gerraty return NULL;
566*0957b409SSimon J. Gerraty }
567*0957b409SSimon J. Gerraty
568*0957b409SSimon J. Gerraty /* see brssl.h */
569*0957b409SSimon J. Gerraty int
get_curve_name_ext(int id,char * dst,size_t len)570*0957b409SSimon J. Gerraty get_curve_name_ext(int id, char *dst, size_t len)
571*0957b409SSimon J. Gerraty {
572*0957b409SSimon J. Gerraty const char *name;
573*0957b409SSimon J. Gerraty char tmp[30];
574*0957b409SSimon J. Gerraty size_t n;
575*0957b409SSimon J. Gerraty
576*0957b409SSimon J. Gerraty name = get_curve_name(id);
577*0957b409SSimon J. Gerraty if (name == NULL) {
578*0957b409SSimon J. Gerraty sprintf(tmp, "unknown (%d)", id);
579*0957b409SSimon J. Gerraty name = tmp;
580*0957b409SSimon J. Gerraty }
581*0957b409SSimon J. Gerraty n = 1 + strlen(name);
582*0957b409SSimon J. Gerraty if (n > len) {
583*0957b409SSimon J. Gerraty if (len > 0) {
584*0957b409SSimon J. Gerraty dst[0] = 0;
585*0957b409SSimon J. Gerraty }
586*0957b409SSimon J. Gerraty return -1;
587*0957b409SSimon J. Gerraty }
588*0957b409SSimon J. Gerraty memcpy(dst, name, n);
589*0957b409SSimon J. Gerraty return 0;
590*0957b409SSimon J. Gerraty }
591*0957b409SSimon J. Gerraty
592*0957b409SSimon J. Gerraty /* see brssl.h */
593*0957b409SSimon J. Gerraty const char *
get_suite_name(unsigned suite)594*0957b409SSimon J. Gerraty get_suite_name(unsigned suite)
595*0957b409SSimon J. Gerraty {
596*0957b409SSimon J. Gerraty size_t u;
597*0957b409SSimon J. Gerraty
598*0957b409SSimon J. Gerraty for (u = 0; cipher_suites[u].name; u ++) {
599*0957b409SSimon J. Gerraty if (cipher_suites[u].suite == suite) {
600*0957b409SSimon J. Gerraty return cipher_suites[u].name;
601*0957b409SSimon J. Gerraty }
602*0957b409SSimon J. Gerraty }
603*0957b409SSimon J. Gerraty return NULL;
604*0957b409SSimon J. Gerraty }
605*0957b409SSimon J. Gerraty
606*0957b409SSimon J. Gerraty /* see brssl.h */
607*0957b409SSimon J. Gerraty int
get_suite_name_ext(unsigned suite,char * dst,size_t len)608*0957b409SSimon J. Gerraty get_suite_name_ext(unsigned suite, char *dst, size_t len)
609*0957b409SSimon J. Gerraty {
610*0957b409SSimon J. Gerraty const char *name;
611*0957b409SSimon J. Gerraty char tmp[30];
612*0957b409SSimon J. Gerraty size_t n;
613*0957b409SSimon J. Gerraty
614*0957b409SSimon J. Gerraty name = get_suite_name(suite);
615*0957b409SSimon J. Gerraty if (name == NULL) {
616*0957b409SSimon J. Gerraty sprintf(tmp, "unknown (0x%04X)", suite);
617*0957b409SSimon J. Gerraty name = tmp;
618*0957b409SSimon J. Gerraty }
619*0957b409SSimon J. Gerraty n = 1 + strlen(name);
620*0957b409SSimon J. Gerraty if (n > len) {
621*0957b409SSimon J. Gerraty if (len > 0) {
622*0957b409SSimon J. Gerraty dst[0] = 0;
623*0957b409SSimon J. Gerraty }
624*0957b409SSimon J. Gerraty return -1;
625*0957b409SSimon J. Gerraty }
626*0957b409SSimon J. Gerraty memcpy(dst, name, n);
627*0957b409SSimon J. Gerraty return 0;
628*0957b409SSimon J. Gerraty }
629*0957b409SSimon J. Gerraty
630*0957b409SSimon J. Gerraty /* see brssl.h */
631*0957b409SSimon J. Gerraty int
uses_ecdhe(unsigned suite)632*0957b409SSimon J. Gerraty uses_ecdhe(unsigned suite)
633*0957b409SSimon J. Gerraty {
634*0957b409SSimon J. Gerraty size_t u;
635*0957b409SSimon J. Gerraty
636*0957b409SSimon J. Gerraty for (u = 0; cipher_suites[u].name; u ++) {
637*0957b409SSimon J. Gerraty if (cipher_suites[u].suite == suite) {
638*0957b409SSimon J. Gerraty return (cipher_suites[u].req
639*0957b409SSimon J. Gerraty & (REQ_ECDHE_RSA | REQ_ECDHE_ECDSA)) != 0;
640*0957b409SSimon J. Gerraty }
641*0957b409SSimon J. Gerraty }
642*0957b409SSimon J. Gerraty return 0;
643*0957b409SSimon J. Gerraty }
644*0957b409SSimon J. Gerraty
645*0957b409SSimon J. Gerraty /* see brssl.h */
646*0957b409SSimon J. Gerraty void
list_names(void)647*0957b409SSimon J. Gerraty list_names(void)
648*0957b409SSimon J. Gerraty {
649*0957b409SSimon J. Gerraty size_t u;
650*0957b409SSimon J. Gerraty
651*0957b409SSimon J. Gerraty printf("Protocol versions:\n");
652*0957b409SSimon J. Gerraty for (u = 0; protocol_versions[u].name; u ++) {
653*0957b409SSimon J. Gerraty printf(" %-8s %s\n",
654*0957b409SSimon J. Gerraty protocol_versions[u].name,
655*0957b409SSimon J. Gerraty protocol_versions[u].comment);
656*0957b409SSimon J. Gerraty }
657*0957b409SSimon J. Gerraty printf("Hash functions:\n");
658*0957b409SSimon J. Gerraty for (u = 0; hash_functions[u].name; u ++) {
659*0957b409SSimon J. Gerraty printf(" %-8s %s\n",
660*0957b409SSimon J. Gerraty hash_functions[u].name,
661*0957b409SSimon J. Gerraty hash_functions[u].comment);
662*0957b409SSimon J. Gerraty }
663*0957b409SSimon J. Gerraty printf("Cipher suites:\n");
664*0957b409SSimon J. Gerraty for (u = 0; cipher_suites[u].name; u ++) {
665*0957b409SSimon J. Gerraty printf(" %s\n %s\n",
666*0957b409SSimon J. Gerraty cipher_suites[u].name,
667*0957b409SSimon J. Gerraty cipher_suites[u].comment);
668*0957b409SSimon J. Gerraty }
669*0957b409SSimon J. Gerraty }
670*0957b409SSimon J. Gerraty
671*0957b409SSimon J. Gerraty /* see brssl.h */
672*0957b409SSimon J. Gerraty void
list_curves(void)673*0957b409SSimon J. Gerraty list_curves(void)
674*0957b409SSimon J. Gerraty {
675*0957b409SSimon J. Gerraty size_t u;
676*0957b409SSimon J. Gerraty for (u = 0; curves[u].name; u ++) {
677*0957b409SSimon J. Gerraty size_t v;
678*0957b409SSimon J. Gerraty
679*0957b409SSimon J. Gerraty for (v = 0; curves[u].sid[v]; v ++) {
680*0957b409SSimon J. Gerraty if (v == 0) {
681*0957b409SSimon J. Gerraty printf(" ");
682*0957b409SSimon J. Gerraty } else if (v == 1) {
683*0957b409SSimon J. Gerraty printf(" (");
684*0957b409SSimon J. Gerraty } else {
685*0957b409SSimon J. Gerraty printf(", ");
686*0957b409SSimon J. Gerraty }
687*0957b409SSimon J. Gerraty printf("%s", curves[u].sid[v]);
688*0957b409SSimon J. Gerraty }
689*0957b409SSimon J. Gerraty if (v > 1) {
690*0957b409SSimon J. Gerraty printf(")");
691*0957b409SSimon J. Gerraty }
692*0957b409SSimon J. Gerraty printf("\n");
693*0957b409SSimon J. Gerraty }
694*0957b409SSimon J. Gerraty }
695*0957b409SSimon J. Gerraty
696*0957b409SSimon J. Gerraty static int
is_ign(int c)697*0957b409SSimon J. Gerraty is_ign(int c)
698*0957b409SSimon J. Gerraty {
699*0957b409SSimon J. Gerraty if (c == 0) {
700*0957b409SSimon J. Gerraty return 0;
701*0957b409SSimon J. Gerraty }
702*0957b409SSimon J. Gerraty if (c <= 32 || c == '-' || c == '_' || c == '.'
703*0957b409SSimon J. Gerraty || c == '/' || c == '+' || c == ':')
704*0957b409SSimon J. Gerraty {
705*0957b409SSimon J. Gerraty return 1;
706*0957b409SSimon J. Gerraty }
707*0957b409SSimon J. Gerraty return 0;
708*0957b409SSimon J. Gerraty }
709*0957b409SSimon J. Gerraty
710*0957b409SSimon J. Gerraty /*
711*0957b409SSimon J. Gerraty * Get next non-ignored character, normalised:
712*0957b409SSimon J. Gerraty * ASCII letters are converted to lowercase
713*0957b409SSimon J. Gerraty * control characters, space, '-', '_', '.', '/', '+' and ':' are ignored
714*0957b409SSimon J. Gerraty * A terminating zero is returned as 0.
715*0957b409SSimon J. Gerraty */
716*0957b409SSimon J. Gerraty static int
next_char(const char ** ps,const char * limit)717*0957b409SSimon J. Gerraty next_char(const char **ps, const char *limit)
718*0957b409SSimon J. Gerraty {
719*0957b409SSimon J. Gerraty for (;;) {
720*0957b409SSimon J. Gerraty int c;
721*0957b409SSimon J. Gerraty
722*0957b409SSimon J. Gerraty if (*ps == limit) {
723*0957b409SSimon J. Gerraty return 0;
724*0957b409SSimon J. Gerraty }
725*0957b409SSimon J. Gerraty c = *(*ps) ++;
726*0957b409SSimon J. Gerraty if (c == 0) {
727*0957b409SSimon J. Gerraty return 0;
728*0957b409SSimon J. Gerraty }
729*0957b409SSimon J. Gerraty if (c >= 'A' && c <= 'Z') {
730*0957b409SSimon J. Gerraty c += 'a' - 'A';
731*0957b409SSimon J. Gerraty }
732*0957b409SSimon J. Gerraty if (!is_ign(c)) {
733*0957b409SSimon J. Gerraty return c;
734*0957b409SSimon J. Gerraty }
735*0957b409SSimon J. Gerraty }
736*0957b409SSimon J. Gerraty }
737*0957b409SSimon J. Gerraty
738*0957b409SSimon J. Gerraty /*
739*0957b409SSimon J. Gerraty * Partial string equality comparison, with normalisation.
740*0957b409SSimon J. Gerraty */
741*0957b409SSimon J. Gerraty static int
eqstr_chunk(const char * s1,size_t s1_len,const char * s2,size_t s2_len)742*0957b409SSimon J. Gerraty eqstr_chunk(const char *s1, size_t s1_len, const char *s2, size_t s2_len)
743*0957b409SSimon J. Gerraty {
744*0957b409SSimon J. Gerraty const char *lim1, *lim2;
745*0957b409SSimon J. Gerraty
746*0957b409SSimon J. Gerraty lim1 = s1 + s1_len;
747*0957b409SSimon J. Gerraty lim2 = s2 + s2_len;
748*0957b409SSimon J. Gerraty for (;;) {
749*0957b409SSimon J. Gerraty int c1, c2;
750*0957b409SSimon J. Gerraty
751*0957b409SSimon J. Gerraty c1 = next_char(&s1, lim1);
752*0957b409SSimon J. Gerraty c2 = next_char(&s2, lim2);
753*0957b409SSimon J. Gerraty if (c1 != c2) {
754*0957b409SSimon J. Gerraty return 0;
755*0957b409SSimon J. Gerraty }
756*0957b409SSimon J. Gerraty if (c1 == 0) {
757*0957b409SSimon J. Gerraty return 1;
758*0957b409SSimon J. Gerraty }
759*0957b409SSimon J. Gerraty }
760*0957b409SSimon J. Gerraty }
761*0957b409SSimon J. Gerraty
762*0957b409SSimon J. Gerraty /* see brssl.h */
763*0957b409SSimon J. Gerraty int
eqstr(const char * s1,const char * s2)764*0957b409SSimon J. Gerraty eqstr(const char *s1, const char *s2)
765*0957b409SSimon J. Gerraty {
766*0957b409SSimon J. Gerraty return eqstr_chunk(s1, strlen(s1), s2, strlen(s2));
767*0957b409SSimon J. Gerraty }
768*0957b409SSimon J. Gerraty
769*0957b409SSimon J. Gerraty static int
hexval(int c)770*0957b409SSimon J. Gerraty hexval(int c)
771*0957b409SSimon J. Gerraty {
772*0957b409SSimon J. Gerraty if (c >= '0' && c <= '9') {
773*0957b409SSimon J. Gerraty return c - '0';
774*0957b409SSimon J. Gerraty } else if (c >= 'A' && c <= 'F') {
775*0957b409SSimon J. Gerraty return c - 'A' + 10;
776*0957b409SSimon J. Gerraty } else if (c >= 'a' && c <= 'f') {
777*0957b409SSimon J. Gerraty return c - 'a' + 10;
778*0957b409SSimon J. Gerraty } else {
779*0957b409SSimon J. Gerraty return -1;
780*0957b409SSimon J. Gerraty }
781*0957b409SSimon J. Gerraty }
782*0957b409SSimon J. Gerraty
783*0957b409SSimon J. Gerraty /* see brssl.h */
784*0957b409SSimon J. Gerraty size_t
parse_size(const char * s)785*0957b409SSimon J. Gerraty parse_size(const char *s)
786*0957b409SSimon J. Gerraty {
787*0957b409SSimon J. Gerraty int radix;
788*0957b409SSimon J. Gerraty size_t acc;
789*0957b409SSimon J. Gerraty const char *t;
790*0957b409SSimon J. Gerraty
791*0957b409SSimon J. Gerraty t = s;
792*0957b409SSimon J. Gerraty if (t[0] == '0' && (t[1] == 'x' || t[1] == 'X')) {
793*0957b409SSimon J. Gerraty radix = 16;
794*0957b409SSimon J. Gerraty t += 2;
795*0957b409SSimon J. Gerraty } else {
796*0957b409SSimon J. Gerraty radix = 10;
797*0957b409SSimon J. Gerraty }
798*0957b409SSimon J. Gerraty acc = 0;
799*0957b409SSimon J. Gerraty for (;;) {
800*0957b409SSimon J. Gerraty int c, d;
801*0957b409SSimon J. Gerraty size_t z;
802*0957b409SSimon J. Gerraty
803*0957b409SSimon J. Gerraty c = *t ++;
804*0957b409SSimon J. Gerraty if (c == 0) {
805*0957b409SSimon J. Gerraty return acc;
806*0957b409SSimon J. Gerraty }
807*0957b409SSimon J. Gerraty d = hexval(c);
808*0957b409SSimon J. Gerraty if (d < 0 || d >= radix) {
809*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: not a valid digit: '%c'\n", c);
810*0957b409SSimon J. Gerraty return (size_t)-1;
811*0957b409SSimon J. Gerraty }
812*0957b409SSimon J. Gerraty z = acc * (size_t)radix + (size_t)d;
813*0957b409SSimon J. Gerraty if (z < (size_t)d || (z / (size_t)radix) != acc
814*0957b409SSimon J. Gerraty || z == (size_t)-1)
815*0957b409SSimon J. Gerraty {
816*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: value too large: %s\n", s);
817*0957b409SSimon J. Gerraty return (size_t)-1;
818*0957b409SSimon J. Gerraty }
819*0957b409SSimon J. Gerraty acc = z;
820*0957b409SSimon J. Gerraty }
821*0957b409SSimon J. Gerraty }
822*0957b409SSimon J. Gerraty
823*0957b409SSimon J. Gerraty /*
824*0957b409SSimon J. Gerraty * Comma-separated list enumeration. This returns a pointer to the first
825*0957b409SSimon J. Gerraty * word in the string, skipping leading ignored characters. '*len' is
826*0957b409SSimon J. Gerraty * set to the word length (not counting trailing ignored characters).
827*0957b409SSimon J. Gerraty * '*str' is updated to point to immediately after the next comma, or to
828*0957b409SSimon J. Gerraty * the terminating zero, whichever comes first.
829*0957b409SSimon J. Gerraty *
830*0957b409SSimon J. Gerraty * Empty words are skipped. If there is no next non-empty word, then this
831*0957b409SSimon J. Gerraty * function returns NULL and sets *len to 0.
832*0957b409SSimon J. Gerraty */
833*0957b409SSimon J. Gerraty static const char *
next_word(const char ** str,size_t * len)834*0957b409SSimon J. Gerraty next_word(const char **str, size_t *len)
835*0957b409SSimon J. Gerraty {
836*0957b409SSimon J. Gerraty int c;
837*0957b409SSimon J. Gerraty const char *begin;
838*0957b409SSimon J. Gerraty size_t u;
839*0957b409SSimon J. Gerraty
840*0957b409SSimon J. Gerraty /*
841*0957b409SSimon J. Gerraty * Find next non-ignored character which is not a comma.
842*0957b409SSimon J. Gerraty */
843*0957b409SSimon J. Gerraty for (;;) {
844*0957b409SSimon J. Gerraty c = **str;
845*0957b409SSimon J. Gerraty if (c == 0) {
846*0957b409SSimon J. Gerraty *len = 0;
847*0957b409SSimon J. Gerraty return NULL;
848*0957b409SSimon J. Gerraty }
849*0957b409SSimon J. Gerraty if (!is_ign(c) && c != ',') {
850*0957b409SSimon J. Gerraty break;
851*0957b409SSimon J. Gerraty }
852*0957b409SSimon J. Gerraty (*str) ++;
853*0957b409SSimon J. Gerraty }
854*0957b409SSimon J. Gerraty
855*0957b409SSimon J. Gerraty /*
856*0957b409SSimon J. Gerraty * Find next comma or terminator.
857*0957b409SSimon J. Gerraty */
858*0957b409SSimon J. Gerraty begin = *str;
859*0957b409SSimon J. Gerraty for (;;) {
860*0957b409SSimon J. Gerraty c = *(*str);
861*0957b409SSimon J. Gerraty if (c == 0 || c == ',') {
862*0957b409SSimon J. Gerraty break;
863*0957b409SSimon J. Gerraty }
864*0957b409SSimon J. Gerraty (*str) ++;
865*0957b409SSimon J. Gerraty }
866*0957b409SSimon J. Gerraty
867*0957b409SSimon J. Gerraty /*
868*0957b409SSimon J. Gerraty * Remove trailing ignored characters.
869*0957b409SSimon J. Gerraty */
870*0957b409SSimon J. Gerraty u = (size_t)(*str - begin);
871*0957b409SSimon J. Gerraty while (u > 0 && is_ign(begin[u - 1])) {
872*0957b409SSimon J. Gerraty u --;
873*0957b409SSimon J. Gerraty }
874*0957b409SSimon J. Gerraty if (c == ',') {
875*0957b409SSimon J. Gerraty (*str) ++;
876*0957b409SSimon J. Gerraty }
877*0957b409SSimon J. Gerraty *len = u;
878*0957b409SSimon J. Gerraty return begin;
879*0957b409SSimon J. Gerraty }
880*0957b409SSimon J. Gerraty
881*0957b409SSimon J. Gerraty /* see brssl.h */
882*0957b409SSimon J. Gerraty unsigned
parse_version(const char * name,size_t len)883*0957b409SSimon J. Gerraty parse_version(const char *name, size_t len)
884*0957b409SSimon J. Gerraty {
885*0957b409SSimon J. Gerraty size_t u;
886*0957b409SSimon J. Gerraty
887*0957b409SSimon J. Gerraty for (u = 0;; u ++) {
888*0957b409SSimon J. Gerraty const char *ref;
889*0957b409SSimon J. Gerraty
890*0957b409SSimon J. Gerraty ref = protocol_versions[u].name;
891*0957b409SSimon J. Gerraty if (ref == NULL) {
892*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: unrecognised protocol"
893*0957b409SSimon J. Gerraty " version name: '%s'\n", name);
894*0957b409SSimon J. Gerraty return 0;
895*0957b409SSimon J. Gerraty }
896*0957b409SSimon J. Gerraty if (eqstr_chunk(ref, strlen(ref), name, len)) {
897*0957b409SSimon J. Gerraty return protocol_versions[u].version;
898*0957b409SSimon J. Gerraty }
899*0957b409SSimon J. Gerraty }
900*0957b409SSimon J. Gerraty }
901*0957b409SSimon J. Gerraty
902*0957b409SSimon J. Gerraty /* see brssl.h */
903*0957b409SSimon J. Gerraty unsigned
parse_hash_functions(const char * arg)904*0957b409SSimon J. Gerraty parse_hash_functions(const char *arg)
905*0957b409SSimon J. Gerraty {
906*0957b409SSimon J. Gerraty unsigned r;
907*0957b409SSimon J. Gerraty
908*0957b409SSimon J. Gerraty r = 0;
909*0957b409SSimon J. Gerraty for (;;) {
910*0957b409SSimon J. Gerraty const char *name;
911*0957b409SSimon J. Gerraty size_t len;
912*0957b409SSimon J. Gerraty size_t u;
913*0957b409SSimon J. Gerraty
914*0957b409SSimon J. Gerraty name = next_word(&arg, &len);
915*0957b409SSimon J. Gerraty if (name == NULL) {
916*0957b409SSimon J. Gerraty break;
917*0957b409SSimon J. Gerraty }
918*0957b409SSimon J. Gerraty for (u = 0;; u ++) {
919*0957b409SSimon J. Gerraty const char *ref;
920*0957b409SSimon J. Gerraty
921*0957b409SSimon J. Gerraty ref = hash_functions[u].name;
922*0957b409SSimon J. Gerraty if (ref == 0) {
923*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: unrecognised"
924*0957b409SSimon J. Gerraty " hash function name: '");
925*0957b409SSimon J. Gerraty fwrite(name, 1, len, stderr);
926*0957b409SSimon J. Gerraty fprintf(stderr, "'\n");
927*0957b409SSimon J. Gerraty return 0;
928*0957b409SSimon J. Gerraty }
929*0957b409SSimon J. Gerraty if (eqstr_chunk(ref, strlen(ref), name, len)) {
930*0957b409SSimon J. Gerraty int id;
931*0957b409SSimon J. Gerraty
932*0957b409SSimon J. Gerraty id = (hash_functions[u].hclass->desc
933*0957b409SSimon J. Gerraty >> BR_HASHDESC_ID_OFF)
934*0957b409SSimon J. Gerraty & BR_HASHDESC_ID_MASK;
935*0957b409SSimon J. Gerraty r |= (unsigned)1 << id;
936*0957b409SSimon J. Gerraty break;
937*0957b409SSimon J. Gerraty }
938*0957b409SSimon J. Gerraty }
939*0957b409SSimon J. Gerraty }
940*0957b409SSimon J. Gerraty if (r == 0) {
941*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: no hash function name provided\n");
942*0957b409SSimon J. Gerraty }
943*0957b409SSimon J. Gerraty return r;
944*0957b409SSimon J. Gerraty }
945*0957b409SSimon J. Gerraty
946*0957b409SSimon J. Gerraty /* see brssl.h */
947*0957b409SSimon J. Gerraty cipher_suite *
parse_suites(const char * arg,size_t * num)948*0957b409SSimon J. Gerraty parse_suites(const char *arg, size_t *num)
949*0957b409SSimon J. Gerraty {
950*0957b409SSimon J. Gerraty VECTOR(cipher_suite) suites = VEC_INIT;
951*0957b409SSimon J. Gerraty cipher_suite *r;
952*0957b409SSimon J. Gerraty
953*0957b409SSimon J. Gerraty for (;;) {
954*0957b409SSimon J. Gerraty const char *name;
955*0957b409SSimon J. Gerraty size_t u, len;
956*0957b409SSimon J. Gerraty
957*0957b409SSimon J. Gerraty name = next_word(&arg, &len);
958*0957b409SSimon J. Gerraty if (name == NULL) {
959*0957b409SSimon J. Gerraty break;
960*0957b409SSimon J. Gerraty }
961*0957b409SSimon J. Gerraty for (u = 0;; u ++) {
962*0957b409SSimon J. Gerraty const char *ref;
963*0957b409SSimon J. Gerraty
964*0957b409SSimon J. Gerraty ref = cipher_suites[u].name;
965*0957b409SSimon J. Gerraty if (ref == NULL) {
966*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: unrecognised"
967*0957b409SSimon J. Gerraty " cipher suite '");
968*0957b409SSimon J. Gerraty fwrite(name, 1, len, stderr);
969*0957b409SSimon J. Gerraty fprintf(stderr, "'\n");
970*0957b409SSimon J. Gerraty return 0;
971*0957b409SSimon J. Gerraty }
972*0957b409SSimon J. Gerraty if (eqstr_chunk(ref, strlen(ref), name, len)) {
973*0957b409SSimon J. Gerraty VEC_ADD(suites, cipher_suites[u]);
974*0957b409SSimon J. Gerraty break;
975*0957b409SSimon J. Gerraty }
976*0957b409SSimon J. Gerraty }
977*0957b409SSimon J. Gerraty }
978*0957b409SSimon J. Gerraty if (VEC_LEN(suites) == 0) {
979*0957b409SSimon J. Gerraty fprintf(stderr, "ERROR: no cipher suite provided\n");
980*0957b409SSimon J. Gerraty }
981*0957b409SSimon J. Gerraty r = VEC_TOARRAY(suites);
982*0957b409SSimon J. Gerraty *num = VEC_LEN(suites);
983*0957b409SSimon J. Gerraty VEC_CLEAR(suites);
984*0957b409SSimon J. Gerraty return r;
985*0957b409SSimon J. Gerraty }
986*0957b409SSimon J. Gerraty
987*0957b409SSimon J. Gerraty /* see brssl.h */
988*0957b409SSimon J. Gerraty const char *
ec_curve_name(int curve)989*0957b409SSimon J. Gerraty ec_curve_name(int curve)
990*0957b409SSimon J. Gerraty {
991*0957b409SSimon J. Gerraty switch (curve) {
992*0957b409SSimon J. Gerraty case BR_EC_sect163k1: return "sect163k1";
993*0957b409SSimon J. Gerraty case BR_EC_sect163r1: return "sect163r1";
994*0957b409SSimon J. Gerraty case BR_EC_sect163r2: return "sect163r2";
995*0957b409SSimon J. Gerraty case BR_EC_sect193r1: return "sect193r1";
996*0957b409SSimon J. Gerraty case BR_EC_sect193r2: return "sect193r2";
997*0957b409SSimon J. Gerraty case BR_EC_sect233k1: return "sect233k1";
998*0957b409SSimon J. Gerraty case BR_EC_sect233r1: return "sect233r1";
999*0957b409SSimon J. Gerraty case BR_EC_sect239k1: return "sect239k1";
1000*0957b409SSimon J. Gerraty case BR_EC_sect283k1: return "sect283k1";
1001*0957b409SSimon J. Gerraty case BR_EC_sect283r1: return "sect283r1";
1002*0957b409SSimon J. Gerraty case BR_EC_sect409k1: return "sect409k1";
1003*0957b409SSimon J. Gerraty case BR_EC_sect409r1: return "sect409r1";
1004*0957b409SSimon J. Gerraty case BR_EC_sect571k1: return "sect571k1";
1005*0957b409SSimon J. Gerraty case BR_EC_sect571r1: return "sect571r1";
1006*0957b409SSimon J. Gerraty case BR_EC_secp160k1: return "secp160k1";
1007*0957b409SSimon J. Gerraty case BR_EC_secp160r1: return "secp160r1";
1008*0957b409SSimon J. Gerraty case BR_EC_secp160r2: return "secp160r2";
1009*0957b409SSimon J. Gerraty case BR_EC_secp192k1: return "secp192k1";
1010*0957b409SSimon J. Gerraty case BR_EC_secp192r1: return "secp192r1";
1011*0957b409SSimon J. Gerraty case BR_EC_secp224k1: return "secp224k1";
1012*0957b409SSimon J. Gerraty case BR_EC_secp224r1: return "secp224r1";
1013*0957b409SSimon J. Gerraty case BR_EC_secp256k1: return "secp256k1";
1014*0957b409SSimon J. Gerraty case BR_EC_secp256r1: return "secp256r1";
1015*0957b409SSimon J. Gerraty case BR_EC_secp384r1: return "secp384r1";
1016*0957b409SSimon J. Gerraty case BR_EC_secp521r1: return "secp521r1";
1017*0957b409SSimon J. Gerraty case BR_EC_brainpoolP256r1: return "brainpoolP256r1";
1018*0957b409SSimon J. Gerraty case BR_EC_brainpoolP384r1: return "brainpoolP384r1";
1019*0957b409SSimon J. Gerraty case BR_EC_brainpoolP512r1: return "brainpoolP512r1";
1020*0957b409SSimon J. Gerraty default:
1021*0957b409SSimon J. Gerraty return "unknown";
1022*0957b409SSimon J. Gerraty }
1023*0957b409SSimon J. Gerraty }
1024*0957b409SSimon J. Gerraty
1025*0957b409SSimon J. Gerraty /* see brssl.h */
1026*0957b409SSimon J. Gerraty int
get_curve_by_name(const char * str)1027*0957b409SSimon J. Gerraty get_curve_by_name(const char *str)
1028*0957b409SSimon J. Gerraty {
1029*0957b409SSimon J. Gerraty size_t u, v;
1030*0957b409SSimon J. Gerraty
1031*0957b409SSimon J. Gerraty for (u = 0; curves[u].name; u ++) {
1032*0957b409SSimon J. Gerraty for (v = 0; curves[u].sid[v]; v ++) {
1033*0957b409SSimon J. Gerraty if (eqstr(curves[u].sid[v], str)) {
1034*0957b409SSimon J. Gerraty return curves[u].id;
1035*0957b409SSimon J. Gerraty }
1036*0957b409SSimon J. Gerraty }
1037*0957b409SSimon J. Gerraty }
1038*0957b409SSimon J. Gerraty return -1;
1039*0957b409SSimon J. Gerraty }
1040*0957b409SSimon J. Gerraty
1041*0957b409SSimon J. Gerraty /* see brssl.h */
1042*0957b409SSimon J. Gerraty const char *
hash_function_name(int id)1043*0957b409SSimon J. Gerraty hash_function_name(int id)
1044*0957b409SSimon J. Gerraty {
1045*0957b409SSimon J. Gerraty switch (id) {
1046*0957b409SSimon J. Gerraty case br_md5sha1_ID: return "MD5+SHA-1";
1047*0957b409SSimon J. Gerraty case br_md5_ID: return "MD5";
1048*0957b409SSimon J. Gerraty case br_sha1_ID: return "SHA-1";
1049*0957b409SSimon J. Gerraty case br_sha224_ID: return "SHA-224";
1050*0957b409SSimon J. Gerraty case br_sha256_ID: return "SHA-256";
1051*0957b409SSimon J. Gerraty case br_sha384_ID: return "SHA-384";
1052*0957b409SSimon J. Gerraty case br_sha512_ID: return "SHA-512";
1053*0957b409SSimon J. Gerraty default:
1054*0957b409SSimon J. Gerraty return "unknown";
1055*0957b409SSimon J. Gerraty }
1056*0957b409SSimon J. Gerraty }
1057