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