Debian Codegraph @

external/boringssl/ssl/ssl_stat.c

raw
1 /* Copyright (C) 1995-1998 Eric Young ([email protected])
2 * All rights reserved.
3 *
4 * This package is an SSL implementation written
5 * by Eric Young ([email protected]).
6 * The implementation was written so as to conform with Netscapes SSL.
7 *
8 * This library is free for commercial and non-commercial use as long as
9 * the following conditions are aheared to. The following conditions
10 * apply to all code found in this distribution, be it the RC4, RSA,
11 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12 * included with this distribution is covered by the same copyright terms
13 * except that the holder is Tim Hudson ([email protected]).
14 *
15 * Copyright remains Eric Young's, and as such any Copyright notices in
16 * the code are not to be removed.
17 * If this package is used in a product, Eric Young should be given attribution
18 * as the author of the parts of the library used.
19 * This can be in the form of a textual message at program startup or
20 * in documentation (online or textual) provided with the package.
21 *
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
24 * are met:
25 * 1. Redistributions of source code must retain the copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 3. All advertising materials mentioning features or use of this software
31 * must display the following acknowledgement:
32 * "This product includes cryptographic software written by
33 * Eric Young ([email protected])"
34 * The word 'cryptographic' can be left out if the rouines from the library
35 * being used are not cryptographic related :-).
36 * 4. If you include any Windows specific code (or a derivative thereof) from
37 * the apps directory (application code) you must include an acknowledgement:
38 * "This product includes software written by Tim Hudson ([email protected])"
39 *
40 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50 * SUCH DAMAGE.
51 *
52 * The licence and distribution terms for any publically available version or
53 * derivative of this code cannot be changed. i.e. this code cannot simply be
54 * copied and put under another distribution licence
55 * [including the GNU Public Licence.]
56 */
57 /* ====================================================================
58 * Copyright 2005 Nokia. All rights reserved.
59 *
60 * The portions of the attached software ("Contribution") is developed by
61 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
62 * license.
63 *
64 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
65 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
66 * support (see RFC 4279) to OpenSSL.
67 *
68 * No patent licenses or other rights except those expressly stated in
69 * the OpenSSL open source license shall be deemed granted or received
70 * expressly, by implication, estoppel, or otherwise.
71 *
72 * No assurances are provided by Nokia that the Contribution does not
73 * infringe the patent or other intellectual property rights of any third
74 * party or that the license provides you with all the necessary rights
75 * to make use of the Contribution.
76 *
77 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
78 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
79 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
80 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
81 * OTHERWISE.
82 */
83
84 #include <openssl/ssl.h>
85
86 #include "internal.h"
87
88
89 const char *SSL_state_string_long(const SSL *ssl) {
90 switch (ssl->state) {
91 case SSL_ST_ACCEPT:
92 return "before accept initialization";
93
94 case SSL_ST_CONNECT:
95 return "before connect initialization";
96
97 case SSL_ST_OK:
98 return "SSL negotiation finished successfully";
99
100 case SSL_ST_RENEGOTIATE:
101 return "SSL renegotiate ciphers";
102
103 /* SSLv3 additions */
104 case SSL3_ST_CW_CLNT_HELLO_A:
105 return "SSLv3 write client hello A";
106
107 case SSL3_ST_CW_CLNT_HELLO_B:
108 return "SSLv3 write client hello B";
109
110 case SSL3_ST_CR_SRVR_HELLO_A:
111 return "SSLv3 read server hello A";
112
113 case SSL3_ST_CR_CERT_A:
114 return "SSLv3 read server certificate A";
115
116 case SSL3_ST_CR_KEY_EXCH_A:
117 return "SSLv3 read server key exchange A";
118
119 case SSL3_ST_CR_CERT_REQ_A:
120 return "SSLv3 read server certificate request A";
121
122 case SSL3_ST_CR_SESSION_TICKET_A:
123 return "SSLv3 read server session ticket A";
124
125 case SSL3_ST_CR_SRVR_DONE_A:
126 return "SSLv3 read server done A";
127
128 case SSL3_ST_CW_CERT_A:
129 return "SSLv3 write client certificate A";
130
131 case SSL3_ST_CW_CERT_B:
132 return "SSLv3 write client certificate B";
133
134 case SSL3_ST_CW_CERT_C:
135 return "SSLv3 write client certificate C";
136
137 case SSL3_ST_CW_CERT_D:
138 return "SSLv3 write client certificate D";
139
140 case SSL3_ST_CW_KEY_EXCH_A:
141 return "SSLv3 write client key exchange A";
142
143 case SSL3_ST_CW_KEY_EXCH_B:
144 return "SSLv3 write client key exchange B";
145
146 case SSL3_ST_CW_CERT_VRFY_A:
147 return "SSLv3 write certificate verify A";
148
149 case SSL3_ST_CW_CERT_VRFY_B:
150 return "SSLv3 write certificate verify B";
151
152 case SSL3_ST_CW_CHANGE_A:
153 case SSL3_ST_SW_CHANGE_A:
154 return "SSLv3 write change cipher spec A";
155
156 case SSL3_ST_CW_CHANGE_B:
157 case SSL3_ST_SW_CHANGE_B:
158 return "SSLv3 write change cipher spec B";
159
160 case SSL3_ST_CW_FINISHED_A:
161 case SSL3_ST_SW_FINISHED_A:
162 return "SSLv3 write finished A";
163
164 case SSL3_ST_CW_FINISHED_B:
165 case SSL3_ST_SW_FINISHED_B:
166 return "SSLv3 write finished B";
167
168 case SSL3_ST_CR_CHANGE:
169 case SSL3_ST_SR_CHANGE:
170 return "SSLv3 read change cipher spec";
171
172 case SSL3_ST_CR_FINISHED_A:
173 case SSL3_ST_SR_FINISHED_A:
174 return "SSLv3 read finished A";
175
176 case SSL3_ST_CW_FLUSH:
177 case SSL3_ST_SW_FLUSH:
178 return "SSLv3 flush data";
179
180 case SSL3_ST_SR_CLNT_HELLO_A:
181 return "SSLv3 read client hello A";
182
183 case SSL3_ST_SR_CLNT_HELLO_B:
184 return "SSLv3 read client hello B";
185
186 case SSL3_ST_SR_CLNT_HELLO_C:
187 return "SSLv3 read client hello C";
188
189 case SSL3_ST_SW_HELLO_REQ_A:
190 return "SSLv3 write hello request A";
191
192 case SSL3_ST_SW_HELLO_REQ_B:
193 return "SSLv3 write hello request B";
194
195 case SSL3_ST_SW_HELLO_REQ_C:
196 return "SSLv3 write hello request C";
197
198 case SSL3_ST_SW_SRVR_HELLO_A:
199 return "SSLv3 write server hello A";
200
201 case SSL3_ST_SW_SRVR_HELLO_B:
202 return "SSLv3 write server hello B";
203
204 case SSL3_ST_SW_CERT_A:
205 return "SSLv3 write certificate A";
206
207 case SSL3_ST_SW_CERT_B:
208 return "SSLv3 write certificate B";
209
210 case SSL3_ST_SW_KEY_EXCH_A:
211 return "SSLv3 write key exchange A";
212
213 case SSL3_ST_SW_KEY_EXCH_B:
214 return "SSLv3 write key exchange B";
215
216 case SSL3_ST_SW_CERT_REQ_A:
217 return "SSLv3 write certificate request A";
218
219 case SSL3_ST_SW_CERT_REQ_B:
220 return "SSLv3 write certificate request B";
221
222 case SSL3_ST_SW_SESSION_TICKET_A:
223 return "SSLv3 write session ticket A";
224
225 case SSL3_ST_SW_SESSION_TICKET_B:
226 return "SSLv3 write session ticket B";
227
228 case SSL3_ST_SW_SRVR_DONE_A:
229 return "SSLv3 write server done A";
230
231 case SSL3_ST_SW_SRVR_DONE_B:
232 return "SSLv3 write server done B";
233
234 case SSL3_ST_SR_CERT_A:
235 return "SSLv3 read client certificate A";
236
237 case SSL3_ST_SR_KEY_EXCH_A:
238 return "SSLv3 read client key exchange A";
239
240 case SSL3_ST_SR_KEY_EXCH_B:
241 return "SSLv3 read client key exchange B";
242
243 case SSL3_ST_SR_CERT_VRFY_A:
244 return "SSLv3 read certificate verify A";
245
246 /* DTLS */
247 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
248 return "DTLS1 read hello verify request A";
249
250 default:
251 return "unknown state";
252 }
253 }
254
255 const char *SSL_state_string(const SSL *ssl) {
256 switch (ssl->state) {
257 case SSL_ST_ACCEPT:
258 return "AINIT ";
259
260 case SSL_ST_CONNECT:
261 return "CINIT ";
262
263 case SSL_ST_OK:
264 return "SSLOK ";
265
266 /* SSLv3 additions */
267 case SSL3_ST_SW_FLUSH:
268 case SSL3_ST_CW_FLUSH:
269 return "3FLUSH";
270
271 case SSL3_ST_CW_CLNT_HELLO_A:
272 return "3WCH_A";
273
274 case SSL3_ST_CW_CLNT_HELLO_B:
275 return "3WCH_B";
276
277 case SSL3_ST_CR_SRVR_HELLO_A:
278 return "3RSH_A";
279
280 case SSL3_ST_CR_CERT_A:
281 return "3RSC_A";
282
283 case SSL3_ST_CR_KEY_EXCH_A:
284 return "3RSKEA";
285
286 case SSL3_ST_CR_CERT_REQ_A:
287 return "3RCR_A";
288
289 case SSL3_ST_CR_SRVR_DONE_A:
290 return "3RSD_A";
291
292 case SSL3_ST_CW_CERT_A:
293 return "3WCC_A";
294
295 case SSL3_ST_CW_CERT_B:
296 return "3WCC_B";
297
298 case SSL3_ST_CW_CERT_C:
299 return "3WCC_C";
300
301 case SSL3_ST_CW_CERT_D:
302 return "3WCC_D";
303
304 case SSL3_ST_CW_KEY_EXCH_A:
305 return "3WCKEA";
306
307 case SSL3_ST_CW_KEY_EXCH_B:
308 return "3WCKEB";
309
310 case SSL3_ST_CW_CERT_VRFY_A:
311 return "3WCV_A";
312
313 case SSL3_ST_CW_CERT_VRFY_B:
314 return "3WCV_B";
315
316 case SSL3_ST_SW_CHANGE_A:
317 case SSL3_ST_CW_CHANGE_A:
318 return "3WCCSA";
319
320 case SSL3_ST_SW_CHANGE_B:
321 case SSL3_ST_CW_CHANGE_B:
322 return "3WCCSB";
323
324 case SSL3_ST_SW_FINISHED_A:
325 case SSL3_ST_CW_FINISHED_A:
326 return "3WFINA";
327
328 case SSL3_ST_SW_FINISHED_B:
329 case SSL3_ST_CW_FINISHED_B:
330 return "3WFINB";
331
332 case SSL3_ST_CR_CHANGE:
333 case SSL3_ST_SR_CHANGE:
334 return "3RCCS_";
335
336 case SSL3_ST_SR_FINISHED_A:
337 case SSL3_ST_CR_FINISHED_A:
338 return "3RFINA";
339
340 case SSL3_ST_SW_HELLO_REQ_A:
341 return "3WHR_A";
342
343 case SSL3_ST_SW_HELLO_REQ_B:
344 return "3WHR_B";
345
346 case SSL3_ST_SW_HELLO_REQ_C:
347 return "3WHR_C";
348
349 case SSL3_ST_SR_CLNT_HELLO_A:
350 return "3RCH_A";
351
352 case SSL3_ST_SR_CLNT_HELLO_B:
353 return "3RCH_B";
354
355 case SSL3_ST_SR_CLNT_HELLO_C:
356 return "3RCH_C";
357
358 case SSL3_ST_SW_SRVR_HELLO_A:
359 return "3WSH_A";
360
361 case SSL3_ST_SW_SRVR_HELLO_B:
362 return "3WSH_B";
363
364 case SSL3_ST_SW_CERT_A:
365 return "3WSC_A";
366
367 case SSL3_ST_SW_CERT_B:
368 return "3WSC_B";
369
370 case SSL3_ST_SW_KEY_EXCH_A:
371 return "3WSKEA";
372
373 case SSL3_ST_SW_KEY_EXCH_B:
374 return "3WSKEB";
375
376 case SSL3_ST_SW_CERT_REQ_A:
377 return "3WCR_A";
378
379 case SSL3_ST_SW_CERT_REQ_B:
380 return "3WCR_B";
381
382 case SSL3_ST_SW_SRVR_DONE_A:
383 return "3WSD_A";
384
385 case SSL3_ST_SW_SRVR_DONE_B:
386 return "3WSD_B";
387
388 case SSL3_ST_SR_CERT_A:
389 return "3RCC_A";
390
391 case SSL3_ST_SR_KEY_EXCH_A:
392 return "3RCKEA";
393
394 case SSL3_ST_SR_CERT_VRFY_A:
395 return "3RCV_A";
396
397 /* DTLS */
398 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
399 return "DRCHVA";
400
401 default:
402 return "UNKWN ";
403 }
404 }
405
406 const char *SSL_alert_type_string_long(int value) {
407 value >>= 8;
408 if (value == SSL3_AL_WARNING) {
409 return "warning";
410 } else if (value == SSL3_AL_FATAL) {
411 return "fatal";
412 }
413
414 return "unknown";
415 }
416
417 const char *SSL_alert_type_string(int value) {
418 return "!";
419 }
420
421 const char *SSL_alert_desc_string(int value) {
422 return "!!";
423 }
424
425 const char *SSL_alert_desc_string_long(int value) {
426 switch (value & 0xff) {
427 case SSL3_AD_CLOSE_NOTIFY:
428 return "close notify";
429
430 case SSL3_AD_UNEXPECTED_MESSAGE:
431 return "unexpected_message";
432
433 case SSL3_AD_BAD_RECORD_MAC:
434 return "bad record mac";
435
436 case SSL3_AD_DECOMPRESSION_FAILURE:
437 return "decompression failure";
438
439 case SSL3_AD_HANDSHAKE_FAILURE:
440 return "handshake failure";
441
442 case SSL3_AD_NO_CERTIFICATE:
443 return "no certificate";
444
445 case SSL3_AD_BAD_CERTIFICATE:
446 return "bad certificate";
447
448 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
449 return "unsupported certificate";
450
451 case SSL3_AD_CERTIFICATE_REVOKED:
452 return "certificate revoked";
453
454 case SSL3_AD_CERTIFICATE_EXPIRED:
455 return "certificate expired";
456
457 case SSL3_AD_CERTIFICATE_UNKNOWN:
458 return "certificate unknown";
459
460 case SSL3_AD_ILLEGAL_PARAMETER:
461 return "illegal parameter";
462
463 case TLS1_AD_DECRYPTION_FAILED:
464 return "decryption failed";
465
466 case TLS1_AD_RECORD_OVERFLOW:
467 return "record overflow";
468
469 case TLS1_AD_UNKNOWN_CA:
470 return "unknown CA";
471
472 case TLS1_AD_ACCESS_DENIED:
473 return "access denied";
474
475 case TLS1_AD_DECODE_ERROR:
476 return "decode error";
477
478 case TLS1_AD_DECRYPT_ERROR:
479 return "decrypt error";
480
481 case TLS1_AD_EXPORT_RESTRICTION:
482 return "export restriction";
483
484 case TLS1_AD_PROTOCOL_VERSION:
485 return "protocol version";
486
487 case TLS1_AD_INSUFFICIENT_SECURITY:
488 return "insufficient security";
489
490 case TLS1_AD_INTERNAL_ERROR:
491 return "internal error";
492
493 case TLS1_AD_USER_CANCELLED:
494 return "user canceled";
495
496 case TLS1_AD_NO_RENEGOTIATION:
497 return "no renegotiation";
498
499 case TLS1_AD_UNSUPPORTED_EXTENSION:
500 return "unsupported extension";
501
502 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
503 return "certificate unobtainable";
504
505 case TLS1_AD_UNRECOGNIZED_NAME:
506 return "unrecognized name";
507
508 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
509 return "bad certificate status response";
510
511 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
512 return "bad certificate hash value";
513
514 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
515 return "unknown PSK identity";
516
517 case SSL3_AD_INAPPROPRIATE_FALLBACK:
518 return "inappropriate fallback";
519
520 default:
521 return "unknown";
522 }
523 }