xref: /openbsd-src/lib/libssl/ssl_stat.c (revision 5ad04d351680822078003e2b066cfc9680d6157d)
1 /* 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 
88 const char *
89 SSL_state_string_long(const SSL *s)
90 {
91 	const char *str;
92 
93 	switch (s->state) {
94 	case SSL_ST_BEFORE:
95 		str="before SSL initialization"; break;
96 	case SSL_ST_ACCEPT:
97 		str="before accept initialization"; break;
98 	case SSL_ST_CONNECT:
99 		str="before connect initialization"; break;
100 	case SSL_ST_OK:
101 		str="SSL negotiation finished successfully"; break;
102 	case SSL_ST_RENEGOTIATE:
103 		str="SSL renegotiate ciphers"; break;
104 	case SSL_ST_BEFORE|SSL_ST_CONNECT:
105 		str="before/connect initialization"; break;
106 	case SSL_ST_OK|SSL_ST_CONNECT:
107 		str="ok/connect SSL initialization"; break;
108 	case SSL_ST_BEFORE|SSL_ST_ACCEPT:
109 		str="before/accept initialization"; break;
110 	case SSL_ST_OK|SSL_ST_ACCEPT:
111 		str="ok/accept SSL initialization"; break;
112 /* SSLv3 additions */
113 	case SSL3_ST_CW_CLNT_HELLO_A:
114 		str="SSLv3 write client hello A"; break;
115 	case SSL3_ST_CW_CLNT_HELLO_B:
116 		str="SSLv3 write client hello B"; break;
117 	case SSL3_ST_CR_SRVR_HELLO_A:
118 		str="SSLv3 read server hello A"; break;
119 	case SSL3_ST_CR_SRVR_HELLO_B:
120 		str="SSLv3 read server hello B"; break;
121 	case SSL3_ST_CR_CERT_A:
122 		str="SSLv3 read server certificate A"; break;
123 	case SSL3_ST_CR_CERT_B:
124 		str="SSLv3 read server certificate B"; break;
125 	case SSL3_ST_CR_KEY_EXCH_A:
126 		str="SSLv3 read server key exchange A"; break;
127 	case SSL3_ST_CR_KEY_EXCH_B:
128 		str="SSLv3 read server key exchange B"; break;
129 	case SSL3_ST_CR_CERT_REQ_A:
130 		str="SSLv3 read server certificate request A"; break;
131 	case SSL3_ST_CR_CERT_REQ_B:
132 		str="SSLv3 read server certificate request B"; break;
133 	case SSL3_ST_CR_SESSION_TICKET_A:
134 		str="SSLv3 read server session ticket A";break;
135 	case SSL3_ST_CR_SESSION_TICKET_B:
136 		str="SSLv3 read server session ticket B";break;
137 	case SSL3_ST_CR_SRVR_DONE_A:
138 		str="SSLv3 read server done A"; break;
139 	case SSL3_ST_CR_SRVR_DONE_B:
140 		str="SSLv3 read server done B"; break;
141 	case SSL3_ST_CW_CERT_A:
142 		str="SSLv3 write client certificate A"; break;
143 	case SSL3_ST_CW_CERT_B:
144 		str="SSLv3 write client certificate B"; break;
145 	case SSL3_ST_CW_CERT_C:
146 		str="SSLv3 write client certificate C"; break;
147 	case SSL3_ST_CW_CERT_D:
148 		str="SSLv3 write client certificate D"; break;
149 	case SSL3_ST_CW_KEY_EXCH_A:
150 		str="SSLv3 write client key exchange A"; break;
151 	case SSL3_ST_CW_KEY_EXCH_B:
152 		str="SSLv3 write client key exchange B"; break;
153 	case SSL3_ST_CW_CERT_VRFY_A:
154 		str="SSLv3 write certificate verify A"; break;
155 	case SSL3_ST_CW_CERT_VRFY_B:
156 		str="SSLv3 write certificate verify B"; break;
157 
158 		case SSL3_ST_CW_CHANGE_A:
159 	case SSL3_ST_SW_CHANGE_A:
160 		str="SSLv3 write change cipher spec A"; break;
161 		case SSL3_ST_CW_CHANGE_B:
162 	case SSL3_ST_SW_CHANGE_B:
163 		str="SSLv3 write change cipher spec B"; break;
164 		case SSL3_ST_CW_FINISHED_A:
165 	case SSL3_ST_SW_FINISHED_A:
166 		str="SSLv3 write finished A"; break;
167 		case SSL3_ST_CW_FINISHED_B:
168 	case SSL3_ST_SW_FINISHED_B:
169 		str="SSLv3 write finished B"; break;
170 		case SSL3_ST_CR_CHANGE_A:
171 	case SSL3_ST_SR_CHANGE_A:
172 		str="SSLv3 read change cipher spec A"; break;
173 		case SSL3_ST_CR_CHANGE_B:
174 	case SSL3_ST_SR_CHANGE_B:
175 		str="SSLv3 read change cipher spec B"; break;
176 		case SSL3_ST_CR_FINISHED_A:
177 	case SSL3_ST_SR_FINISHED_A:
178 		str="SSLv3 read finished A"; break;
179 		case SSL3_ST_CR_FINISHED_B:
180 	case SSL3_ST_SR_FINISHED_B:
181 		str="SSLv3 read finished B"; break;
182 
183 		case SSL3_ST_CW_FLUSH:
184 	case SSL3_ST_SW_FLUSH:
185 		str="SSLv3 flush data"; break;
186 
187 	case SSL3_ST_SR_CLNT_HELLO_A:
188 		str="SSLv3 read client hello A"; break;
189 	case SSL3_ST_SR_CLNT_HELLO_B:
190 		str="SSLv3 read client hello B"; break;
191 	case SSL3_ST_SR_CLNT_HELLO_C:
192 		str="SSLv3 read client hello C"; break;
193 	case SSL3_ST_SW_HELLO_REQ_A:
194 		str="SSLv3 write hello request A"; break;
195 	case SSL3_ST_SW_HELLO_REQ_B:
196 		str="SSLv3 write hello request B"; break;
197 	case SSL3_ST_SW_HELLO_REQ_C:
198 		str="SSLv3 write hello request C"; break;
199 	case SSL3_ST_SW_SRVR_HELLO_A:
200 		str="SSLv3 write server hello A"; break;
201 	case SSL3_ST_SW_SRVR_HELLO_B:
202 		str="SSLv3 write server hello B"; break;
203 	case SSL3_ST_SW_CERT_A:
204 		str="SSLv3 write certificate A"; break;
205 	case SSL3_ST_SW_CERT_B:
206 		str="SSLv3 write certificate B"; break;
207 	case SSL3_ST_SW_KEY_EXCH_A:
208 		str="SSLv3 write key exchange A"; break;
209 	case SSL3_ST_SW_KEY_EXCH_B:
210 		str="SSLv3 write key exchange B"; break;
211 	case SSL3_ST_SW_CERT_REQ_A:
212 		str="SSLv3 write certificate request A"; break;
213 	case SSL3_ST_SW_CERT_REQ_B:
214 		str="SSLv3 write certificate request B"; break;
215 	case SSL3_ST_SW_SESSION_TICKET_A:
216 		str="SSLv3 write session ticket A"; break;
217 	case SSL3_ST_SW_SESSION_TICKET_B:
218 		str="SSLv3 write session ticket B"; break;
219 	case SSL3_ST_SW_SRVR_DONE_A:
220 		str="SSLv3 write server done A"; break;
221 	case SSL3_ST_SW_SRVR_DONE_B:
222 		str="SSLv3 write server done B"; break;
223 	case SSL3_ST_SR_CERT_A:
224 		str="SSLv3 read client certificate A"; break;
225 	case SSL3_ST_SR_CERT_B:
226 		str="SSLv3 read client certificate B"; break;
227 	case SSL3_ST_SR_KEY_EXCH_A:
228 		str="SSLv3 read client key exchange A"; break;
229 	case SSL3_ST_SR_KEY_EXCH_B:
230 		str="SSLv3 read client key exchange B"; break;
231 	case SSL3_ST_SR_CERT_VRFY_A:
232 		str="SSLv3 read certificate verify A"; break;
233 	case SSL3_ST_SR_CERT_VRFY_B:
234 		str="SSLv3 read certificate verify B"; break;
235 
236 /* DTLS */
237 	case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
238 		str="DTLS1 read hello verify request A"; break;
239 	case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
240 		str="DTLS1 read hello verify request B"; break;
241 	case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
242 		str="DTLS1 write hello verify request A"; break;
243 	case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
244 		str="DTLS1 write hello verify request B"; break;
245 
246 	default:
247 		str="unknown state"; break;
248 	}
249 	return (str);
250 }
251 
252 const char *
253 SSL_rstate_string_long(const SSL *s)
254 {
255 	const char *str;
256 
257 	switch (s->rstate) {
258 	case SSL_ST_READ_HEADER:
259 		str="read header"; break;
260 	case SSL_ST_READ_BODY:
261 		str="read body"; break;
262 	case SSL_ST_READ_DONE:
263 		str="read done"; break;
264 	default:
265 		str="unknown"; break;
266 	}
267 	return (str);
268 }
269 
270 const char *
271 SSL_state_string(const SSL *s)
272 {
273 	const char *str;
274 
275 	switch (s->state) {
276 	case SSL_ST_BEFORE:
277 		str="PINIT "; break;
278 	case SSL_ST_ACCEPT:
279 		str="AINIT "; break;
280 	case SSL_ST_CONNECT:
281 		str="CINIT "; break;
282 	case SSL_ST_OK:
283 		str="SSLOK "; break;
284 
285 /* SSLv3 additions */
286 		case SSL3_ST_SW_FLUSH:
287 	case SSL3_ST_CW_FLUSH:
288 		str="3FLUSH"; break;
289 	case SSL3_ST_CW_CLNT_HELLO_A:
290 		str="3WCH_A"; break;
291 	case SSL3_ST_CW_CLNT_HELLO_B:
292 		str="3WCH_B"; break;
293 	case SSL3_ST_CR_SRVR_HELLO_A:
294 		str="3RSH_A"; break;
295 	case SSL3_ST_CR_SRVR_HELLO_B:
296 		str="3RSH_B"; break;
297 	case SSL3_ST_CR_CERT_A:
298 		str="3RSC_A"; break;
299 	case SSL3_ST_CR_CERT_B:
300 		str="3RSC_B"; break;
301 	case SSL3_ST_CR_KEY_EXCH_A:
302 		str="3RSKEA"; break;
303 	case SSL3_ST_CR_KEY_EXCH_B:
304 		str="3RSKEB"; break;
305 	case SSL3_ST_CR_CERT_REQ_A:
306 		str="3RCR_A"; break;
307 	case SSL3_ST_CR_CERT_REQ_B:
308 		str="3RCR_B"; break;
309 	case SSL3_ST_CR_SRVR_DONE_A:
310 		str="3RSD_A"; break;
311 	case SSL3_ST_CR_SRVR_DONE_B:
312 		str="3RSD_B"; break;
313 	case SSL3_ST_CW_CERT_A:
314 		str="3WCC_A"; break;
315 	case SSL3_ST_CW_CERT_B:
316 		str="3WCC_B"; break;
317 	case SSL3_ST_CW_CERT_C:
318 		str="3WCC_C"; break;
319 	case SSL3_ST_CW_CERT_D:
320 		str="3WCC_D"; break;
321 	case SSL3_ST_CW_KEY_EXCH_A:
322 		str="3WCKEA"; break;
323 	case SSL3_ST_CW_KEY_EXCH_B:
324 		str="3WCKEB"; break;
325 	case SSL3_ST_CW_CERT_VRFY_A:
326 		str="3WCV_A"; break;
327 	case SSL3_ST_CW_CERT_VRFY_B:
328 		str="3WCV_B"; break;
329 
330 		case SSL3_ST_SW_CHANGE_A:
331 	case SSL3_ST_CW_CHANGE_A:
332 		str="3WCCSA"; break;
333 		case SSL3_ST_SW_CHANGE_B:
334 	case SSL3_ST_CW_CHANGE_B:
335 		str="3WCCSB"; break;
336 		case SSL3_ST_SW_FINISHED_A:
337 	case SSL3_ST_CW_FINISHED_A:
338 		str="3WFINA"; break;
339 		case SSL3_ST_SW_FINISHED_B:
340 	case SSL3_ST_CW_FINISHED_B:
341 		str="3WFINB"; break;
342 		case SSL3_ST_SR_CHANGE_A:
343 	case SSL3_ST_CR_CHANGE_A:
344 		str="3RCCSA"; break;
345 		case SSL3_ST_SR_CHANGE_B:
346 	case SSL3_ST_CR_CHANGE_B:
347 		str="3RCCSB"; break;
348 		case SSL3_ST_SR_FINISHED_A:
349 	case SSL3_ST_CR_FINISHED_A:
350 		str="3RFINA"; break;
351 		case SSL3_ST_SR_FINISHED_B:
352 	case SSL3_ST_CR_FINISHED_B:
353 		str="3RFINB"; break;
354 
355 	case SSL3_ST_SW_HELLO_REQ_A:
356 		str="3WHR_A"; break;
357 	case SSL3_ST_SW_HELLO_REQ_B:
358 		str="3WHR_B"; break;
359 	case SSL3_ST_SW_HELLO_REQ_C:
360 		str="3WHR_C"; break;
361 	case SSL3_ST_SR_CLNT_HELLO_A:
362 		str="3RCH_A"; break;
363 	case SSL3_ST_SR_CLNT_HELLO_B:
364 		str="3RCH_B"; break;
365 	case SSL3_ST_SR_CLNT_HELLO_C:
366 		str="3RCH_C"; break;
367 	case SSL3_ST_SW_SRVR_HELLO_A:
368 		str="3WSH_A"; break;
369 	case SSL3_ST_SW_SRVR_HELLO_B:
370 		str="3WSH_B"; break;
371 	case SSL3_ST_SW_CERT_A:
372 		str="3WSC_A"; break;
373 	case SSL3_ST_SW_CERT_B:
374 		str="3WSC_B"; break;
375 	case SSL3_ST_SW_KEY_EXCH_A:
376 		str="3WSKEA"; break;
377 	case SSL3_ST_SW_KEY_EXCH_B:
378 		str="3WSKEB"; break;
379 	case SSL3_ST_SW_CERT_REQ_A:
380 		str="3WCR_A"; break;
381 	case SSL3_ST_SW_CERT_REQ_B:
382 		str="3WCR_B"; break;
383 	case SSL3_ST_SW_SRVR_DONE_A:
384 		str="3WSD_A"; break;
385 	case SSL3_ST_SW_SRVR_DONE_B:
386 		str="3WSD_B"; break;
387 	case SSL3_ST_SR_CERT_A:
388 		str="3RCC_A"; break;
389 	case SSL3_ST_SR_CERT_B:
390 		str="3RCC_B"; break;
391 	case SSL3_ST_SR_KEY_EXCH_A:
392 		str="3RCKEA"; break;
393 	case SSL3_ST_SR_KEY_EXCH_B:
394 		str="3RCKEB"; break;
395 	case SSL3_ST_SR_CERT_VRFY_A:
396 		str="3RCV_A"; break;
397 	case SSL3_ST_SR_CERT_VRFY_B:
398 		str="3RCV_B"; break;
399 /* DTLS */
400 	case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
401 		str="DRCHVA"; break;
402 	case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
403 		str="DRCHVB"; break;
404 	case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
405 		str="DWCHVA"; break;
406 	case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
407 		str="DWCHVB"; break;
408 
409 	default:
410 		str="UNKWN "; break;
411 	}
412 	return (str);
413 }
414 
415 const char *
416 SSL_alert_type_string_long(int value)
417 {
418 	value>>=8;
419 	if (value == SSL3_AL_WARNING)
420 		return("warning");
421 	else if (value == SSL3_AL_FATAL)
422 		return("fatal");
423 	else
424 		return("unknown");
425 }
426 
427 const char *
428 SSL_alert_type_string(int value)
429 {
430 	value>>=8;
431 	if (value == SSL3_AL_WARNING)
432 		return("W");
433 	else if (value == SSL3_AL_FATAL)
434 		return("F");
435 	else
436 		return("U");
437 }
438 
439 const char *
440 SSL_alert_desc_string(int value)
441 {
442 	const char *str;
443 
444 	switch (value & 0xff) {
445 	case SSL3_AD_CLOSE_NOTIFY:
446 		str="CN"; break;
447 	case SSL3_AD_UNEXPECTED_MESSAGE:
448 		str="UM"; break;
449 	case SSL3_AD_BAD_RECORD_MAC:
450 		str="BM"; break;
451 	case SSL3_AD_DECOMPRESSION_FAILURE:
452 		str="DF"; break;
453 	case SSL3_AD_HANDSHAKE_FAILURE:
454 		str="HF"; break;
455 	case SSL3_AD_NO_CERTIFICATE:
456 		str="NC"; break;
457 	case SSL3_AD_BAD_CERTIFICATE:
458 		str="BC"; break;
459 	case SSL3_AD_UNSUPPORTED_CERTIFICATE:
460 		str="UC"; break;
461 	case SSL3_AD_CERTIFICATE_REVOKED:
462 		str="CR"; break;
463 	case SSL3_AD_CERTIFICATE_EXPIRED:
464 		str="CE"; break;
465 	case SSL3_AD_CERTIFICATE_UNKNOWN:
466 		str="CU"; break;
467 	case SSL3_AD_ILLEGAL_PARAMETER:
468 		str="IP"; break;
469 	case TLS1_AD_DECRYPTION_FAILED:
470 		str="DC"; break;
471 	case TLS1_AD_RECORD_OVERFLOW:
472 		str="RO"; break;
473 	case TLS1_AD_UNKNOWN_CA:
474 		str="CA"; break;
475 	case TLS1_AD_ACCESS_DENIED:
476 		str="AD"; break;
477 	case TLS1_AD_DECODE_ERROR:
478 		str="DE"; break;
479 	case TLS1_AD_DECRYPT_ERROR:
480 		str="CY"; break;
481 	case TLS1_AD_EXPORT_RESTRICTION:
482 		str="ER"; break;
483 	case TLS1_AD_PROTOCOL_VERSION:
484 		str="PV"; break;
485 	case TLS1_AD_INSUFFICIENT_SECURITY:
486 		str="IS"; break;
487 	case TLS1_AD_INTERNAL_ERROR:
488 		str="IE"; break;
489 	case TLS1_AD_USER_CANCELLED:
490 		str="US"; break;
491 	case TLS1_AD_NO_RENEGOTIATION:
492 		str="NR"; break;
493 	case TLS1_AD_UNSUPPORTED_EXTENSION:
494 		str="UE"; break;
495 	case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
496 		str="CO"; break;
497 	case TLS1_AD_UNRECOGNIZED_NAME:
498 		str="UN"; break;
499 	case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
500 		str="BR"; break;
501 	case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
502 		str="BH"; break;
503 	case TLS1_AD_UNKNOWN_PSK_IDENTITY:
504 		str="UP"; break;
505 	default:
506 		str="UK"; break;
507 	}
508 	return (str);
509 }
510 
511 const char *
512 SSL_alert_desc_string_long(int value)
513 {
514 	const char *str;
515 
516 	switch (value & 0xff) {
517 	case SSL3_AD_CLOSE_NOTIFY:
518 		str="close notify";
519 		break;
520 	case SSL3_AD_UNEXPECTED_MESSAGE:
521 		str="unexpected_message";
522 		break;
523 	case SSL3_AD_BAD_RECORD_MAC:
524 		str="bad record mac";
525 		break;
526 	case SSL3_AD_DECOMPRESSION_FAILURE:
527 		str="decompression failure";
528 		break;
529 	case SSL3_AD_HANDSHAKE_FAILURE:
530 		str="handshake failure";
531 		break;
532 	case SSL3_AD_NO_CERTIFICATE:
533 		str="no certificate";
534 		break;
535 	case SSL3_AD_BAD_CERTIFICATE:
536 		str="bad certificate";
537 		break;
538 	case SSL3_AD_UNSUPPORTED_CERTIFICATE:
539 		str="unsupported certificate";
540 		break;
541 	case SSL3_AD_CERTIFICATE_REVOKED:
542 		str="certificate revoked";
543 		break;
544 	case SSL3_AD_CERTIFICATE_EXPIRED:
545 		str="certificate expired";
546 		break;
547 	case SSL3_AD_CERTIFICATE_UNKNOWN:
548 		str="certificate unknown";
549 		break;
550 	case SSL3_AD_ILLEGAL_PARAMETER:
551 		str="illegal parameter";
552 		break;
553 	case TLS1_AD_DECRYPTION_FAILED:
554 		str="decryption failed";
555 		break;
556 	case TLS1_AD_RECORD_OVERFLOW:
557 		str="record overflow";
558 		break;
559 	case TLS1_AD_UNKNOWN_CA:
560 		str="unknown CA";
561 		break;
562 	case TLS1_AD_ACCESS_DENIED:
563 		str="access denied";
564 		break;
565 	case TLS1_AD_DECODE_ERROR:
566 		str="decode error";
567 		break;
568 	case TLS1_AD_DECRYPT_ERROR:
569 		str="decrypt error";
570 		break;
571 	case TLS1_AD_EXPORT_RESTRICTION:
572 		str="export restriction";
573 		break;
574 	case TLS1_AD_PROTOCOL_VERSION:
575 		str="protocol version";
576 		break;
577 	case TLS1_AD_INSUFFICIENT_SECURITY:
578 		str="insufficient security";
579 		break;
580 	case TLS1_AD_INTERNAL_ERROR:
581 		str="internal error";
582 		break;
583 	case TLS1_AD_USER_CANCELLED:
584 		str="user canceled";
585 		break;
586 	case TLS1_AD_NO_RENEGOTIATION:
587 		str="no renegotiation";
588 		break;
589 	case TLS1_AD_UNSUPPORTED_EXTENSION:
590 		str="unsupported extension";
591 		break;
592 	case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
593 		str="certificate unobtainable";
594 		break;
595 	case TLS1_AD_UNRECOGNIZED_NAME:
596 		str="unrecognized name";
597 		break;
598 	case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
599 		str="bad certificate status response";
600 		break;
601 	case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
602 		str="bad certificate hash value";
603 		break;
604 	case TLS1_AD_UNKNOWN_PSK_IDENTITY:
605 		str="unknown PSK identity";
606 		break;
607 	default:
608 		str="unknown"; break;
609 	}
610 	return (str);
611 }
612 
613 const char *
614 SSL_rstate_string(const SSL *s)
615 {
616 	const char *str;
617 
618 	switch (s->rstate) {
619 	case SSL_ST_READ_HEADER:
620 		str="RH"; break;
621 	case SSL_ST_READ_BODY:
622 		str="RB"; break;
623 	case SSL_ST_READ_DONE:
624 		str="RD"; break;
625 	default:
626 		str="unknown"; break;
627 	}
628 	return (str);
629 }
630