1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
/*
* Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Modified by Laurent Bercot <ska-skaware@skarnet.org>
* for inclusion in the sbearssl support library.
*/
#include <bearssl.h>
#include <s6-networking/sbearssl.h>
struct error_s
{
int err ;
const char *comment ;
} ;
static struct error_s errors[] =
{
{
BR_ERR_OK,
"No error."
" (BR_ERR_OK)"
},
{
BR_ERR_BAD_PARAM,
"Caller-provided parameter is incorrect."
" (BR_ERR_BAD_PARAM)"
},
{
BR_ERR_BAD_STATE,
"Operation requested by the caller cannot be applied with"
" the current context state (e.g. reading data while"
" outgoing data is waiting to be sent)."
" (BR_BAD_STATE)"
},
{
BR_ERR_UNSUPPORTED_VERSION,
"Incoming protocol or record version is unsupported."
" (BR_ERR_UNSUPPORTED_VERSION)"
},
{
BR_ERR_BAD_VERSION,
"Incoming record version does not match the expected version."
" (BR_ERR_BAD_VERSION)"
},
{
BR_ERR_BAD_LENGTH,
"Incoming record length is invalid."
" (BR_ERR_BAD_LENGTH)"
},
{
BR_ERR_TOO_LARGE,
"Incoming record is too large to be processed, or buffer"
" is too small for the handshake message to send."
" (BR_ERR_TOO_LARGE)"
},
{
BR_ERR_BAD_MAC,
"Decryption found an invalid padding, or the record MAC is"
" not correct."
" (BR_ERR_BAD_MAC)"
},
{
BR_ERR_NO_RANDOM,
"No initial entropy was provided, and none can be obtained"
" from the OS."
" (BR_ERR_NO_RANDOM)"
},
{
BR_ERR_UNKNOWN_TYPE,
"Incoming record type is unknown."
" (BR_ERR_UNKNOWN_TYPE)"
},
{
BR_ERR_UNEXPECTED,
"Incoming record or message has wrong type with regards to"
" the current engine state."
" (BR_ERR_UNEXPECTED)"
},
{
BR_ERR_BAD_CCS,
"ChangeCipherSpec message from the peer has invalid contents."
" (BR_ERR_BAD_CCS)"
},
{
BR_ERR_BAD_ALERT,
"Alert message from the peer has invalid contents"
" (odd length)."
" (BR_ERR_BAD_ALERT)"
},
{
BR_ERR_BAD_HANDSHAKE,
"Incoming handshake message decoding failed."
" (BR_ERR_BAD_HANDSHAKE)"
},
{
BR_ERR_OVERSIZED_ID,
"ServerHello contains a session ID which is larger than"
" 32 bytes."
" (BR_ERR_OVERSIZED_ID)"
},
{
BR_ERR_BAD_CIPHER_SUITE,
"Server wants to use a cipher suite that we did not claim"
" to support. This is also reported if we tried to advertise"
" a cipher suite that we do not support."
" (BR_ERR_BAD_CIPHER_SUITE)"
},
{
BR_ERR_BAD_COMPRESSION,
"Server wants to use a compression that we did not claim"
" to support."
" (BR_ERR_BAD_COMPRESSION)"
},
{
BR_ERR_BAD_FRAGLEN,
"Server's max fragment length does not match client's."
" (BR_ERR_BAD_FRAGLEN)"
},
{
BR_ERR_BAD_SECRENEG,
"Secure renegotiation failed."
" (BR_ERR_BAD_SECRENEG)"
},
{
BR_ERR_EXTRA_EXTENSION,
"Server sent an extension type that we did not announce,"
" or used the same extension type several times in a"
" single ServerHello."
" (BR_ERR_EXTRA_EXTENSION)"
},
{
BR_ERR_BAD_SNI,
"Invalid Server Name Indication contents (when used by"
" the server, this extension shall be empty)."
" (BR_ERR_BAD_SNI)"
},
{
BR_ERR_BAD_HELLO_DONE,
"Invalid ServerHelloDone from the server (length is not 0)."
" (BR_ERR_BAD_HELLO_DONE)"
},
{
BR_ERR_LIMIT_EXCEEDED,
"Internal limit exceeded (e.g. server's public key is too"
" large)."
" (BR_ERR_LIMIT_EXCEEDED)"
},
{
BR_ERR_BAD_FINISHED,
"Finished message from peer does not match the expected"
" value."
" (BR_ERR_BAD_FINISHED)"
},
{
BR_ERR_RESUME_MISMATCH,
"Session resumption attempt with distinct version or cipher"
" suite."
" (BR_ERR_RESUME_MISMATCH)"
},
{
BR_ERR_INVALID_ALGORITHM,
"Unsupported or invalid algorithm (ECDHE curve, signature"
" algorithm, hash function)."
" (BR_ERR_INVALID_ALGORITHM)"
},
{
BR_ERR_BAD_SIGNATURE,
"Invalid signature on ServerKeyExchange message."
" (BR_ERR_BAD_SIGNATURE)"
},
{
BR_ERR_IO,
"I/O error or premature close on transport stream."
" (BR_ERR_IO)"
},
{
BR_ERR_X509_INVALID_VALUE,
"Invalid value in an ASN.1 structure."
" (BR_ERR_X509_INVALID_VALUE)"
},
{
BR_ERR_X509_TRUNCATED,
"Truncated certificate or other ASN.1 object."
" (BR_ERR_X509_TRUNCATED)"
},
{
BR_ERR_X509_EMPTY_CHAIN,
"Empty certificate chain (no certificate at all)."
" (BR_ERR_X509_EMPTY_CHAIN)"
},
{
BR_ERR_X509_INNER_TRUNC,
"Decoding error: inner element extends beyond outer element"
" size."
" (BR_ERR_X509_INNER_TRUNC)"
},
{
BR_ERR_X509_BAD_TAG_CLASS,
"Decoding error: unsupported tag class (application or"
" private)."
" (BR_ERR_X509_BAD_TAG_CLASS)"
},
{
BR_ERR_X509_BAD_TAG_VALUE,
"Decoding error: unsupported tag value."
" (BR_ERR_X509_BAD_TAG_VALUE)"
},
{
BR_ERR_X509_INDEFINITE_LENGTH,
"Decoding error: indefinite length."
" (BR_ERR_X509_INDEFINITE_LENGTH)"
},
{
BR_ERR_X509_EXTRA_ELEMENT,
"Decoding error: extraneous element."
" (BR_ERR_X509_EXTRA_ELEMENT)"
},
{
BR_ERR_X509_UNEXPECTED,
"Decoding error: unexpected element."
" (BR_ERR_X509_UNEXPECTED)"
},
{
BR_ERR_X509_NOT_CONSTRUCTED,
"Decoding error: expected constructed element, but is"
" primitive."
" (BR_ERR_X509_NOT_CONSTRUCTED)"
},
{
BR_ERR_X509_NOT_PRIMITIVE,
"Decoding error: expected primitive element, but is"
" constructed."
" (BR_ERR_X509_NOT_PRIMITIVE)"
},
{
BR_ERR_X509_PARTIAL_BYTE,
"Decoding error: BIT STRING length is not multiple of 8."
" (BR_ERR_X509_PARTIAL_BYTE)"
},
{
BR_ERR_X509_BAD_BOOLEAN,
"Decoding error: BOOLEAN value has invalid length."
" (BR_ERR_X509_BAD_BOOLEAN)"
},
{
BR_ERR_X509_OVERFLOW,
"Decoding error: value is off-limits."
" (BR_ERR_X509_OVERFLOW)"
},
{
BR_ERR_X509_BAD_DN,
"Invalid distinguished name."
" (BR_ERR_X509_BAD_DN)"
},
{
BR_ERR_X509_BAD_TIME,
"Invalid date/time representation."
" (BR_ERR_X509_BAD_TIME)"
},
{
BR_ERR_X509_UNSUPPORTED,
"Certificate contains unsupported features that cannot be"
" ignored."
" (BR_ERR_X509_UNSUPPORTED)"
},
{
BR_ERR_X509_LIMIT_EXCEEDED,
"Key or signature size exceeds internal limits."
" (BR_ERR_X509_LIMIT_EXCEEDED)"
},
{
BR_ERR_X509_WRONG_KEY_TYPE,
"Key type does not match that which was expected."
" (BR_ERR_X509_WRONG_KEY_TYPE)"
},
{
BR_ERR_X509_BAD_SIGNATURE,
"Signature is invalid."
" (BR_ERR_X509_BAD_SIGNATURE)"
},
{
BR_ERR_X509_TIME_UNKNOWN,
"Validation time is unknown."
" (BR_ERR_X509_TIME_UNKNOWN)"
},
{
BR_ERR_X509_EXPIRED,
"Certificate is expired or not yet valid."
" (BR_ERR_X509_EXPIRED)"
},
{
BR_ERR_X509_DN_MISMATCH,
"Issuer/Subject DN mismatch in the chain."
" (BR_ERR_X509_DN_MISMATCH)"
},
{
BR_ERR_X509_BAD_SERVER_NAME,
"Expected server name was not found in the chain."
" (BR_ERR_X509_BAD_SERVER_NAME)"
},
{
BR_ERR_X509_CRITICAL_EXTENSION,
"Unknown critical extension in certificate."
" (BR_ERR_X509_CRITICAL_EXTENSION)"
},
{
BR_ERR_X509_NOT_CA,
"Not a CA, or path length constraint violation."
" (BR_ERR_X509_NOT_CA)"
},
{
BR_ERR_X509_FORBIDDEN_KEY_USAGE,
"Key Usage extension prohibits intended usage."
" (BR_ERR_X509_FORBIDDEN_KEY_USAGE)"
},
{
BR_ERR_X509_WEAK_PUBLIC_KEY,
"Public key found in certificate is too small."
" (BR_ERR_X509_WEAK_PUBLIC_KEY)"
},
{
BR_ERR_X509_NOT_TRUSTED,
"Chain could not be linked to a trust anchor."
" (BR_ERR_X509_NOT_TRUSTED)"
},
{ -1,
"Unknown BearSSL error."
}
} ;
char const *sbearssl_error_str (int err)
{
struct error_s *p = errors ;
while (p->err >= 0 && err != p->err) p++ ;
return p->comment ;
}
|