blob: 4703af48fc2d2bac831ad21ff2890f679ff4c228 [file] [log] [blame]
Adam Langley95c29f32014-06-20 12:00:00 -07001/* ssl/ssl_stat.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright 2005 Nokia. All rights reserved.
60 *
61 * The portions of the attached software ("Contribution") is developed by
62 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
63 * license.
64 *
65 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
66 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
67 * support (see RFC 4279) to OpenSSL.
68 *
69 * No patent licenses or other rights except those expressly stated in
70 * the OpenSSL open source license shall be deemed granted or received
71 * expressly, by implication, estoppel, or otherwise.
72 *
73 * No assurances are provided by Nokia that the Contribution does not
74 * infringe the patent or other intellectual property rights of any third
75 * party or that the license provides you with all the necessary rights
76 * to make use of the Contribution.
77 *
78 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
79 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
80 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
81 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
82 * OTHERWISE.
83 */
84
85#include <stdio.h>
86#include "ssl_locl.h"
87
Adam Langleyfcf25832014-12-18 17:42:32 -080088const char *SSL_state_string_long(const SSL *s) {
89 const char *str;
Adam Langley95c29f32014-06-20 12:00:00 -070090
Adam Langleyfcf25832014-12-18 17:42:32 -080091 switch (s->state) {
92 case SSL_ST_ACCEPT:
93 str = "before accept initialization";
94 break;
Adam Langley95c29f32014-06-20 12:00:00 -070095
Adam Langleyfcf25832014-12-18 17:42:32 -080096 case SSL_ST_CONNECT:
97 str = "before connect initialization";
98 break;
Adam Langley95c29f32014-06-20 12:00:00 -070099
Adam Langleyfcf25832014-12-18 17:42:32 -0800100 case SSL_ST_OK:
101 str = "SSL negotiation finished successfully";
102 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700103
Adam Langleyfcf25832014-12-18 17:42:32 -0800104 case SSL_ST_RENEGOTIATE:
105 str = "SSL renegotiate ciphers";
106 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700107
Adam Langleyfcf25832014-12-18 17:42:32 -0800108 case SSL_ST_BEFORE | SSL_ST_CONNECT:
109 str = "before/connect initialization";
110 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700111
Adam Langleyfcf25832014-12-18 17:42:32 -0800112 case SSL_ST_BEFORE | SSL_ST_ACCEPT:
113 str = "before/accept initialization";
114 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700115
Adam Langleyfcf25832014-12-18 17:42:32 -0800116 /* SSLv3 additions */
117 case SSL3_ST_CW_CLNT_HELLO_A:
118 str = "SSLv3 write client hello A";
119 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700120
Adam Langleyfcf25832014-12-18 17:42:32 -0800121 case SSL3_ST_CW_CLNT_HELLO_B:
122 str = "SSLv3 write client hello B";
123 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700124
Adam Langleyfcf25832014-12-18 17:42:32 -0800125 case SSL3_ST_CR_SRVR_HELLO_A:
126 str = "SSLv3 read server hello A";
127 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700128
Adam Langleyfcf25832014-12-18 17:42:32 -0800129 case SSL3_ST_CR_SRVR_HELLO_B:
130 str = "SSLv3 read server hello B";
131 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700132
Adam Langleyfcf25832014-12-18 17:42:32 -0800133 case SSL3_ST_CR_CERT_A:
134 str = "SSLv3 read server certificate A";
135 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700136
Adam Langleyfcf25832014-12-18 17:42:32 -0800137 case SSL3_ST_CR_CERT_B:
138 str = "SSLv3 read server certificate B";
139 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700140
Adam Langleyfcf25832014-12-18 17:42:32 -0800141 case SSL3_ST_CR_KEY_EXCH_A:
142 str = "SSLv3 read server key exchange A";
143 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700144
Adam Langleyfcf25832014-12-18 17:42:32 -0800145 case SSL3_ST_CR_KEY_EXCH_B:
146 str = "SSLv3 read server key exchange B";
147 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700148
Adam Langleyfcf25832014-12-18 17:42:32 -0800149 case SSL3_ST_CR_CERT_REQ_A:
150 str = "SSLv3 read server certificate request A";
151 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700152
Adam Langleyfcf25832014-12-18 17:42:32 -0800153 case SSL3_ST_CR_CERT_REQ_B:
154 str = "SSLv3 read server certificate request B";
155 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700156
Adam Langleyfcf25832014-12-18 17:42:32 -0800157 case SSL3_ST_CR_SESSION_TICKET_A:
158 str = "SSLv3 read server session ticket A";
159 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700160
Adam Langleyfcf25832014-12-18 17:42:32 -0800161 case SSL3_ST_CR_SESSION_TICKET_B:
162 str = "SSLv3 read server session ticket B";
163 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700164
Adam Langleyfcf25832014-12-18 17:42:32 -0800165 case SSL3_ST_CR_SRVR_DONE_A:
166 str = "SSLv3 read server done A";
167 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700168
Adam Langleyfcf25832014-12-18 17:42:32 -0800169 case SSL3_ST_CR_SRVR_DONE_B:
170 str = "SSLv3 read server done B";
171 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700172
Adam Langleyfcf25832014-12-18 17:42:32 -0800173 case SSL3_ST_CW_CERT_A:
174 str = "SSLv3 write client certificate A";
175 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700176
Adam Langleyfcf25832014-12-18 17:42:32 -0800177 case SSL3_ST_CW_CERT_B:
178 str = "SSLv3 write client certificate B";
179 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700180
Adam Langleyfcf25832014-12-18 17:42:32 -0800181 case SSL3_ST_CW_CERT_C:
182 str = "SSLv3 write client certificate C";
183 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700184
Adam Langleyfcf25832014-12-18 17:42:32 -0800185 case SSL3_ST_CW_CERT_D:
186 str = "SSLv3 write client certificate D";
187 break;
Adam Langley95c29f32014-06-20 12:00:00 -0700188
Adam Langleyfcf25832014-12-18 17:42:32 -0800189 case SSL3_ST_CW_KEY_EXCH_A:
190 str = "SSLv3 write client key exchange A";
191 break;
192
193 case SSL3_ST_CW_KEY_EXCH_B:
194 str = "SSLv3 write client key exchange B";
195 break;
196
197 case SSL3_ST_CW_CERT_VRFY_A:
198 str = "SSLv3 write certificate verify A";
199 break;
200
201 case SSL3_ST_CW_CERT_VRFY_B:
202 str = "SSLv3 write certificate verify B";
203 break;
204
205 case SSL3_ST_CW_CHANGE_A:
206 case SSL3_ST_SW_CHANGE_A:
207 str = "SSLv3 write change cipher spec A";
208 break;
209
210 case SSL3_ST_CW_CHANGE_B:
211 case SSL3_ST_SW_CHANGE_B:
212 str = "SSLv3 write change cipher spec B";
213 break;
214
215 case SSL3_ST_CW_FINISHED_A:
216 case SSL3_ST_SW_FINISHED_A:
217 str = "SSLv3 write finished A";
218 break;
219
220 case SSL3_ST_CW_FINISHED_B:
221 case SSL3_ST_SW_FINISHED_B:
222 str = "SSLv3 write finished B";
223 break;
224
225 case SSL3_ST_CR_CHANGE:
226 case SSL3_ST_SR_CHANGE:
227 str = "SSLv3 read change cipher spec";
228 break;
229
230 case SSL3_ST_CR_FINISHED_A:
231 case SSL3_ST_SR_FINISHED_A:
232 str = "SSLv3 read finished A";
233 break;
234
235 case SSL3_ST_CR_FINISHED_B:
236 case SSL3_ST_SR_FINISHED_B:
237 str = "SSLv3 read finished B";
238 break;
239
240 case SSL3_ST_CW_FLUSH:
241 case SSL3_ST_SW_FLUSH:
242 str = "SSLv3 flush data";
243 break;
244
245 case SSL3_ST_SR_CLNT_HELLO_A:
246 str = "SSLv3 read client hello A";
247 break;
248
249 case SSL3_ST_SR_CLNT_HELLO_B:
250 str = "SSLv3 read client hello B";
251 break;
252
253 case SSL3_ST_SR_CLNT_HELLO_C:
254 str = "SSLv3 read client hello C";
255 break;
256
257 case SSL3_ST_SR_CLNT_HELLO_D:
258 str = "SSLv3 read client hello D";
259 break;
260
261 case SSL3_ST_SW_HELLO_REQ_A:
262 str = "SSLv3 write hello request A";
263 break;
264
265 case SSL3_ST_SW_HELLO_REQ_B:
266 str = "SSLv3 write hello request B";
267 break;
268
269 case SSL3_ST_SW_HELLO_REQ_C:
270 str = "SSLv3 write hello request C";
271 break;
272
273 case SSL3_ST_SW_SRVR_HELLO_A:
274 str = "SSLv3 write server hello A";
275 break;
276
277 case SSL3_ST_SW_SRVR_HELLO_B:
278 str = "SSLv3 write server hello B";
279 break;
280
281 case SSL3_ST_SW_CERT_A:
282 str = "SSLv3 write certificate A";
283 break;
284
285 case SSL3_ST_SW_CERT_B:
286 str = "SSLv3 write certificate B";
287 break;
288
289 case SSL3_ST_SW_KEY_EXCH_A:
290 str = "SSLv3 write key exchange A";
291 break;
292
293 case SSL3_ST_SW_KEY_EXCH_B:
294 str = "SSLv3 write key exchange B";
295 break;
296
297 case SSL3_ST_SW_CERT_REQ_A:
298 str = "SSLv3 write certificate request A";
299 break;
300
301 case SSL3_ST_SW_CERT_REQ_B:
302 str = "SSLv3 write certificate request B";
303 break;
304
305 case SSL3_ST_SW_SESSION_TICKET_A:
306 str = "SSLv3 write session ticket A";
307 break;
308
309 case SSL3_ST_SW_SESSION_TICKET_B:
310 str = "SSLv3 write session ticket B";
311 break;
312
313 case SSL3_ST_SW_SRVR_DONE_A:
314 str = "SSLv3 write server done A";
315 break;
316
317 case SSL3_ST_SW_SRVR_DONE_B:
318 str = "SSLv3 write server done B";
319 break;
320
321 case SSL3_ST_SR_CERT_A:
322 str = "SSLv3 read client certificate A";
323 break;
324
325 case SSL3_ST_SR_CERT_B:
326 str = "SSLv3 read client certificate B";
327 break;
328
329 case SSL3_ST_SR_KEY_EXCH_A:
330 str = "SSLv3 read client key exchange A";
331 break;
332
333 case SSL3_ST_SR_KEY_EXCH_B:
334 str = "SSLv3 read client key exchange B";
335 break;
336
337 case SSL3_ST_SR_CERT_VRFY_A:
338 str = "SSLv3 read certificate verify A";
339 break;
340
341 case SSL3_ST_SR_CERT_VRFY_B:
342 str = "SSLv3 read certificate verify B";
343 break;
344
345 /* SSLv2/v3 compatibility states */
346 /* client */
347 case SSL23_ST_CW_CLNT_HELLO_A:
348 str = "SSLv2/v3 write client hello A";
349 break;
350
351 case SSL23_ST_CW_CLNT_HELLO_B:
352 str = "SSLv2/v3 write client hello B";
353 break;
354
355 case SSL23_ST_CR_SRVR_HELLO_A:
356 str = "SSLv2/v3 read server hello A";
357 break;
358
359 case SSL23_ST_CR_SRVR_HELLO_B:
360 str = "SSLv2/v3 read server hello B";
361 break;
362
363 /* server */
364 case SSL23_ST_SR_CLNT_HELLO:
365 str = "SSLv2/v3 read client hello";
366 break;
367
368 case SSL23_ST_SR_V2_CLNT_HELLO:
369 str = "SSLv2/v3 read v2 client hello";
370 break;
371
372 case SSL23_ST_SR_SWITCH_VERSION:
373 str = "SSLv2/v3 switch version";
374 break;
375
376 /* DTLS */
377 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
378 str = "DTLS1 read hello verify request A";
379 break;
380
381 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
382 str = "DTLS1 read hello verify request B";
383 break;
384
Adam Langleyfcf25832014-12-18 17:42:32 -0800385 default:
386 str = "unknown state";
387 break;
388 }
389
390 return str;
391}
392
393const char *SSL_rstate_string_long(const SSL *s) {
394 const char *str;
395
396 switch (s->rstate) {
397 case SSL_ST_READ_HEADER:
398 str = "read header";
399 break;
400
401 case SSL_ST_READ_BODY:
402 str = "read body";
403 break;
404
405 case SSL_ST_READ_DONE:
406 str = "read done";
407 break;
408
409 default:
410 str = "unknown";
411 break;
412 }
413
414 return str;
415}
416
417const char *SSL_state_string(const SSL *s) {
418 const char *str;
419
420 switch (s->state) {
421 case SSL_ST_ACCEPT:
422 str = "AINIT ";
423 break;
424
425 case SSL_ST_CONNECT:
426 str = "CINIT ";
427 break;
428
429 case SSL_ST_OK:
430 str = "SSLOK ";
431 break;
432
433 /* SSLv3 additions */
434 case SSL3_ST_SW_FLUSH:
435 case SSL3_ST_CW_FLUSH:
436 str = "3FLUSH";
437 break;
438
439 case SSL3_ST_CW_CLNT_HELLO_A:
440 str = "3WCH_A";
441 break;
442
443 case SSL3_ST_CW_CLNT_HELLO_B:
444 str = "3WCH_B";
445 break;
446
447 case SSL3_ST_CR_SRVR_HELLO_A:
448 str = "3RSH_A";
449 break;
450
451 case SSL3_ST_CR_SRVR_HELLO_B:
452 str = "3RSH_B";
453 break;
454
455 case SSL3_ST_CR_CERT_A:
456 str = "3RSC_A";
457 break;
458
459 case SSL3_ST_CR_CERT_B:
460 str = "3RSC_B";
461 break;
462
463 case SSL3_ST_CR_KEY_EXCH_A:
464 str = "3RSKEA";
465 break;
466
467 case SSL3_ST_CR_KEY_EXCH_B:
468 str = "3RSKEB";
469 break;
470
471 case SSL3_ST_CR_CERT_REQ_A:
472 str = "3RCR_A";
473 break;
474
475 case SSL3_ST_CR_CERT_REQ_B:
476 str = "3RCR_B";
477 break;
478
479 case SSL3_ST_CR_SRVR_DONE_A:
480 str = "3RSD_A";
481 break;
482
483 case SSL3_ST_CR_SRVR_DONE_B:
484 str = "3RSD_B";
485 break;
486
487 case SSL3_ST_CW_CERT_A:
488 str = "3WCC_A";
489 break;
490
491 case SSL3_ST_CW_CERT_B:
492 str = "3WCC_B";
493 break;
494
495 case SSL3_ST_CW_CERT_C:
496 str = "3WCC_C";
497 break;
498
499 case SSL3_ST_CW_CERT_D:
500 str = "3WCC_D";
501 break;
502
503 case SSL3_ST_CW_KEY_EXCH_A:
504 str = "3WCKEA";
505 break;
506
507 case SSL3_ST_CW_KEY_EXCH_B:
508 str = "3WCKEB";
509 break;
510
511 case SSL3_ST_CW_CERT_VRFY_A:
512 str = "3WCV_A";
513 break;
514
515 case SSL3_ST_CW_CERT_VRFY_B:
516 str = "3WCV_B";
517 break;
518
519 case SSL3_ST_SW_CHANGE_A:
520 case SSL3_ST_CW_CHANGE_A:
521 str = "3WCCSA";
522 break;
523
524 case SSL3_ST_SW_CHANGE_B:
525 case SSL3_ST_CW_CHANGE_B:
526 str = "3WCCSB";
527 break;
528
529 case SSL3_ST_SW_FINISHED_A:
530 case SSL3_ST_CW_FINISHED_A:
531 str = "3WFINA";
532 break;
533
534 case SSL3_ST_SW_FINISHED_B:
535 case SSL3_ST_CW_FINISHED_B:
536 str = "3WFINB";
537 break;
538
539 case SSL3_ST_CR_CHANGE:
540 case SSL3_ST_SR_CHANGE:
541 str = "3RCCS_";
542 break;
543
544 case SSL3_ST_SR_FINISHED_A:
545 case SSL3_ST_CR_FINISHED_A:
546 str = "3RFINA";
547 break;
548
549 case SSL3_ST_SR_FINISHED_B:
550 case SSL3_ST_CR_FINISHED_B:
551 str = "3RFINB";
552 break;
553
554 case SSL3_ST_SW_HELLO_REQ_A:
555 str = "3WHR_A";
556 break;
557
558 case SSL3_ST_SW_HELLO_REQ_B:
559 str = "3WHR_B";
560 break;
561
562 case SSL3_ST_SW_HELLO_REQ_C:
563 str = "3WHR_C";
564 break;
565
566 case SSL3_ST_SR_CLNT_HELLO_A:
567 str = "3RCH_A";
568 break;
569
570 case SSL3_ST_SR_CLNT_HELLO_B:
571 str = "3RCH_B";
572 break;
573
574 case SSL3_ST_SR_CLNT_HELLO_C:
575 str = "3RCH_C";
576 break;
577
578 case SSL3_ST_SR_CLNT_HELLO_D:
579 str = "3RCH_D";
580 break;
581
582 case SSL3_ST_SW_SRVR_HELLO_A:
583 str = "3WSH_A";
584 break;
585
586 case SSL3_ST_SW_SRVR_HELLO_B:
587 str = "3WSH_B";
588 break;
589
590 case SSL3_ST_SW_CERT_A:
591 str = "3WSC_A";
592 break;
593
594 case SSL3_ST_SW_CERT_B:
595 str = "3WSC_B";
596 break;
597
598 case SSL3_ST_SW_KEY_EXCH_A:
599 str = "3WSKEA";
600 break;
601
602 case SSL3_ST_SW_KEY_EXCH_B:
603 str = "3WSKEB";
604 break;
605
606 case SSL3_ST_SW_CERT_REQ_A:
607 str = "3WCR_A";
608 break;
609
610 case SSL3_ST_SW_CERT_REQ_B:
611 str = "3WCR_B";
612 break;
613
614 case SSL3_ST_SW_SRVR_DONE_A:
615 str = "3WSD_A";
616 break;
617
618 case SSL3_ST_SW_SRVR_DONE_B:
619 str = "3WSD_B";
620 break;
621
622 case SSL3_ST_SR_CERT_A:
623 str = "3RCC_A";
624 break;
625
626 case SSL3_ST_SR_CERT_B:
627 str = "3RCC_B";
628 break;
629
630 case SSL3_ST_SR_KEY_EXCH_A:
631 str = "3RCKEA";
632 break;
633
634 case SSL3_ST_SR_KEY_EXCH_B:
635 str = "3RCKEB";
636 break;
637
638 case SSL3_ST_SR_CERT_VRFY_A:
639 str = "3RCV_A";
640 break;
641
642 case SSL3_ST_SR_CERT_VRFY_B:
643 str = "3RCV_B";
644 break;
645
646 /* SSLv2/v3 compatibility states */
647 /* client */
648 case SSL23_ST_CW_CLNT_HELLO_A:
649 str = "23WCHA";
650 break;
651
652 case SSL23_ST_CW_CLNT_HELLO_B:
653 str = "23WCHB";
654 break;
655
656 case SSL23_ST_CR_SRVR_HELLO_A:
657 str = "23RSHA";
658 break;
659
660 case SSL23_ST_CR_SRVR_HELLO_B:
661 str = "23RSHA";
662 break;
663
664 /* server */
665 case SSL23_ST_SR_CLNT_HELLO:
666 str = "23RCH_";
667 break;
668
669 case SSL23_ST_SR_V2_CLNT_HELLO:
670 str = "23R2CH";
671 break;
672
673 case SSL23_ST_SR_SWITCH_VERSION:
674 str = "23RSW_";
675 break;
676
677 /* DTLS */
678 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
679 str = "DRCHVA";
680 break;
681
682 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
683 str = "DRCHVB";
684 break;
685
Adam Langleyfcf25832014-12-18 17:42:32 -0800686 default:
687 str = "UNKWN ";
688 break;
689 }
690
691 return str;
692}
693
694const char *SSL_alert_type_string_long(int value) {
695 value >>= 8;
696 if (value == SSL3_AL_WARNING) {
697 return "warning";
698 } else if (value == SSL3_AL_FATAL) {
699 return "fatal";
700 }
701
702 return "unknown";
703}
704
705const char *SSL_alert_type_string(int value) {
706 value >>= 8;
707 if (value == SSL3_AL_WARNING) {
708 return "W";
709 } else if (value == SSL3_AL_FATAL) {
710 return "F";
711 }
712
713 return "U";
714}
715
716const char *SSL_alert_desc_string(int value) {
717 const char *str;
718
719 switch (value & 0xff) {
720 case SSL3_AD_CLOSE_NOTIFY:
721 str = "CN";
722 break;
723
724 case SSL3_AD_UNEXPECTED_MESSAGE:
725 str = "UM";
726 break;
727
728 case SSL3_AD_BAD_RECORD_MAC:
729 str = "BM";
730 break;
731
732 case SSL3_AD_DECOMPRESSION_FAILURE:
733 str = "DF";
734 break;
735
736 case SSL3_AD_HANDSHAKE_FAILURE:
737 str = "HF";
738 break;
739
740 case SSL3_AD_NO_CERTIFICATE:
741 str = "NC";
742 break;
743
744 case SSL3_AD_BAD_CERTIFICATE:
745 str = "BC";
746 break;
747
748 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
749 str = "UC";
750 break;
751
752 case SSL3_AD_CERTIFICATE_REVOKED:
753 str = "CR";
754 break;
755
756 case SSL3_AD_CERTIFICATE_EXPIRED:
757 str = "CE";
758 break;
759
760 case SSL3_AD_CERTIFICATE_UNKNOWN:
761 str = "CU";
762 break;
763
764 case SSL3_AD_ILLEGAL_PARAMETER:
765 str = "IP";
766 break;
767
768 case TLS1_AD_DECRYPTION_FAILED:
769 str = "DC";
770 break;
771
772 case TLS1_AD_RECORD_OVERFLOW:
773 str = "RO";
774 break;
775
776 case TLS1_AD_UNKNOWN_CA:
777 str = "CA";
778 break;
779
780 case TLS1_AD_ACCESS_DENIED:
781 str = "AD";
782 break;
783
784 case TLS1_AD_DECODE_ERROR:
785 str = "DE";
786 break;
787
788 case TLS1_AD_DECRYPT_ERROR:
789 str = "CY";
790 break;
791
792 case TLS1_AD_EXPORT_RESTRICTION:
793 str = "ER";
794 break;
795
796 case TLS1_AD_PROTOCOL_VERSION:
797 str = "PV";
798 break;
799
800 case TLS1_AD_INSUFFICIENT_SECURITY:
801 str = "IS";
802 break;
803
804 case TLS1_AD_INTERNAL_ERROR:
805 str = "IE";
806 break;
807
808 case TLS1_AD_USER_CANCELLED:
809 str = "US";
810 break;
811
812 case TLS1_AD_NO_RENEGOTIATION:
813 str = "NR";
814 break;
815
816 case TLS1_AD_UNSUPPORTED_EXTENSION:
817 str = "UE";
818 break;
819
820 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
821 str = "CO";
822 break;
823
824 case TLS1_AD_UNRECOGNIZED_NAME:
825 str = "UN";
826 break;
827
828 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
829 str = "BR";
830 break;
831
832 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
833 str = "BH";
834 break;
835
836 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
837 str = "UP";
838 break;
839
840 default:
841 str = "UK";
842 break;
843 }
844
845 return str;
846}
847
848const char *SSL_alert_desc_string_long(int value) {
849 const char *str;
850
851 switch (value & 0xff) {
852 case SSL3_AD_CLOSE_NOTIFY:
853 str = "close notify";
854 break;
855
856 case SSL3_AD_UNEXPECTED_MESSAGE:
857 str = "unexpected_message";
858 break;
859
860 case SSL3_AD_BAD_RECORD_MAC:
861 str = "bad record mac";
862 break;
863
864 case SSL3_AD_DECOMPRESSION_FAILURE:
865 str = "decompression failure";
866 break;
867
868 case SSL3_AD_HANDSHAKE_FAILURE:
869 str = "handshake failure";
870 break;
871
872 case SSL3_AD_NO_CERTIFICATE:
873 str = "no certificate";
874 break;
875
876 case SSL3_AD_BAD_CERTIFICATE:
877 str = "bad certificate";
878 break;
879
880 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
881 str = "unsupported certificate";
882 break;
883
884 case SSL3_AD_CERTIFICATE_REVOKED:
885 str = "certificate revoked";
886 break;
887
888 case SSL3_AD_CERTIFICATE_EXPIRED:
889 str = "certificate expired";
890 break;
891
892 case SSL3_AD_CERTIFICATE_UNKNOWN:
893 str = "certificate unknown";
894 break;
895
896 case SSL3_AD_ILLEGAL_PARAMETER:
897 str = "illegal parameter";
898 break;
899
900 case TLS1_AD_DECRYPTION_FAILED:
901 str = "decryption failed";
902 break;
903
904 case TLS1_AD_RECORD_OVERFLOW:
905 str = "record overflow";
906 break;
907
908 case TLS1_AD_UNKNOWN_CA:
909 str = "unknown CA";
910 break;
911
912 case TLS1_AD_ACCESS_DENIED:
913 str = "access denied";
914 break;
915
916 case TLS1_AD_DECODE_ERROR:
917 str = "decode error";
918 break;
919
920 case TLS1_AD_DECRYPT_ERROR:
921 str = "decrypt error";
922 break;
923
924 case TLS1_AD_EXPORT_RESTRICTION:
925 str = "export restriction";
926 break;
927
928 case TLS1_AD_PROTOCOL_VERSION:
929 str = "protocol version";
930 break;
931
932 case TLS1_AD_INSUFFICIENT_SECURITY:
933 str = "insufficient security";
934 break;
935
936 case TLS1_AD_INTERNAL_ERROR:
937 str = "internal error";
938 break;
939
940 case TLS1_AD_USER_CANCELLED:
941 str = "user canceled";
942 break;
943
944 case TLS1_AD_NO_RENEGOTIATION:
945 str = "no renegotiation";
946 break;
947
948 case TLS1_AD_UNSUPPORTED_EXTENSION:
949 str = "unsupported extension";
950 break;
951
952 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
953 str = "certificate unobtainable";
954 break;
955
956 case TLS1_AD_UNRECOGNIZED_NAME:
957 str = "unrecognized name";
958 break;
959
960 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
961 str = "bad certificate status response";
962 break;
963
964 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
965 str = "bad certificate hash value";
966 break;
967
968 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
969 str = "unknown PSK identity";
970 break;
971
972 default:
973 str = "unknown";
974 break;
975 }
976
977 return str;
978}
979
980const char *SSL_rstate_string(const SSL *s) {
981 const char *str;
982
983 switch (s->rstate) {
984 case SSL_ST_READ_HEADER:
985 str = "RH";
986 break;
987
988 case SSL_ST_READ_BODY:
989 str = "RB";
990 break;
991
992 case SSL_ST_READ_DONE:
993 str = "RD";
994 break;
995
996 default:
997 str = "unknown";
998 break;
999 }
1000
1001 return str;
1002}