Add Error state
[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 /* SSLv2/v3 compatibility states */
306 /* client */
307     case SSL23_ST_CW_CLNT_HELLO_A:
308         str = "SSLv2/v3 write client hello A";
309         break;
310     case SSL23_ST_CW_CLNT_HELLO_B:
311         str = "SSLv2/v3 write client hello B";
312         break;
313     case SSL23_ST_CR_SRVR_HELLO_A:
314         str = "SSLv2/v3 read server hello A";
315         break;
316     case SSL23_ST_CR_SRVR_HELLO_B:
317         str = "SSLv2/v3 read server hello B";
318         break;
319 /* server */
320     case SSL23_ST_SR_CLNT_HELLO_A:
321         str = "SSLv2/v3 read client hello A";
322         break;
323     case SSL23_ST_SR_CLNT_HELLO_B:
324         str = "SSLv2/v3 read client hello B";
325         break;
326
327 /* DTLS */
328     case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
329         str = "DTLS1 read hello verify request A";
330         break;
331     case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
332         str = "DTLS1 read hello verify request B";
333         break;
334     case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
335         str = "DTLS1 write hello verify request A";
336         break;
337     case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
338         str = "DTLS1 write hello verify request B";
339         break;
340
341     default:
342         str = "unknown state";
343         break;
344     }
345     return (str);
346 }
347
348
349 const char *SSL_state_string(const SSL *s)
350 {
351     const char *str;
352
353     switch (s->state) {
354     case SSL_ST_BEFORE:
355         str = "PINIT ";
356         break;
357     case SSL_ST_ACCEPT:
358         str = "AINIT ";
359         break;
360     case SSL_ST_CONNECT:
361         str = "CINIT ";
362         break;
363     case SSL_ST_OK:
364         str = "SSLOK ";
365         break;
366     case SSL_ST_ERR:
367         str = "SSLERR";
368         break;
369
370 #ifndef OPENSSL_NO_SSL3
371 /* SSLv3 additions */
372     case SSL3_ST_SW_FLUSH:
373     case SSL3_ST_CW_FLUSH:
374         str = "3FLUSH";
375         break;
376     case SSL3_ST_CW_CLNT_HELLO_A:
377         str = "3WCH_A";
378         break;
379     case SSL3_ST_CW_CLNT_HELLO_B:
380         str = "3WCH_B";
381         break;
382     case SSL3_ST_CR_SRVR_HELLO_A:
383         str = "3RSH_A";
384         break;
385     case SSL3_ST_CR_SRVR_HELLO_B:
386         str = "3RSH_B";
387         break;
388     case SSL3_ST_CR_CERT_A:
389         str = "3RSC_A";
390         break;
391     case SSL3_ST_CR_CERT_B:
392         str = "3RSC_B";
393         break;
394     case SSL3_ST_CR_KEY_EXCH_A:
395         str = "3RSKEA";
396         break;
397     case SSL3_ST_CR_KEY_EXCH_B:
398         str = "3RSKEB";
399         break;
400     case SSL3_ST_CR_CERT_REQ_A:
401         str = "3RCR_A";
402         break;
403     case SSL3_ST_CR_CERT_REQ_B:
404         str = "3RCR_B";
405         break;
406     case SSL3_ST_CR_SRVR_DONE_A:
407         str = "3RSD_A";
408         break;
409     case SSL3_ST_CR_SRVR_DONE_B:
410         str = "3RSD_B";
411         break;
412     case SSL3_ST_CW_CERT_A:
413         str = "3WCC_A";
414         break;
415     case SSL3_ST_CW_CERT_B:
416         str = "3WCC_B";
417         break;
418     case SSL3_ST_CW_CERT_C:
419         str = "3WCC_C";
420         break;
421     case SSL3_ST_CW_CERT_D:
422         str = "3WCC_D";
423         break;
424     case SSL3_ST_CW_KEY_EXCH_A:
425         str = "3WCKEA";
426         break;
427     case SSL3_ST_CW_KEY_EXCH_B:
428         str = "3WCKEB";
429         break;
430     case SSL3_ST_CW_CERT_VRFY_A:
431         str = "3WCV_A";
432         break;
433     case SSL3_ST_CW_CERT_VRFY_B:
434         str = "3WCV_B";
435         break;
436
437     case SSL3_ST_SW_CHANGE_A:
438     case SSL3_ST_CW_CHANGE_A:
439         str = "3WCCSA";
440         break;
441     case SSL3_ST_SW_CHANGE_B:
442     case SSL3_ST_CW_CHANGE_B:
443         str = "3WCCSB";
444         break;
445     case SSL3_ST_SW_FINISHED_A:
446     case SSL3_ST_CW_FINISHED_A:
447         str = "3WFINA";
448         break;
449     case SSL3_ST_SW_FINISHED_B:
450     case SSL3_ST_CW_FINISHED_B:
451         str = "3WFINB";
452         break;
453     case SSL3_ST_SR_CHANGE_A:
454     case SSL3_ST_CR_CHANGE_A:
455         str = "3RCCSA";
456         break;
457     case SSL3_ST_SR_CHANGE_B:
458     case SSL3_ST_CR_CHANGE_B:
459         str = "3RCCSB";
460         break;
461     case SSL3_ST_SR_FINISHED_A:
462     case SSL3_ST_CR_FINISHED_A:
463         str = "3RFINA";
464         break;
465     case SSL3_ST_SR_FINISHED_B:
466     case SSL3_ST_CR_FINISHED_B:
467         str = "3RFINB";
468         break;
469
470     case SSL3_ST_SW_HELLO_REQ_A:
471         str = "3WHR_A";
472         break;
473     case SSL3_ST_SW_HELLO_REQ_B:
474         str = "3WHR_B";
475         break;
476     case SSL3_ST_SW_HELLO_REQ_C:
477         str = "3WHR_C";
478         break;
479     case SSL3_ST_SR_CLNT_HELLO_A:
480         str = "3RCH_A";
481         break;
482     case SSL3_ST_SR_CLNT_HELLO_B:
483         str = "3RCH_B";
484         break;
485     case SSL3_ST_SR_CLNT_HELLO_C:
486         str = "3RCH_C";
487         break;
488     case SSL3_ST_SW_SRVR_HELLO_A:
489         str = "3WSH_A";
490         break;
491     case SSL3_ST_SW_SRVR_HELLO_B:
492         str = "3WSH_B";
493         break;
494     case SSL3_ST_SW_CERT_A:
495         str = "3WSC_A";
496         break;
497     case SSL3_ST_SW_CERT_B:
498         str = "3WSC_B";
499         break;
500     case SSL3_ST_SW_KEY_EXCH_A:
501         str = "3WSKEA";
502         break;
503     case SSL3_ST_SW_KEY_EXCH_B:
504         str = "3WSKEB";
505         break;
506     case SSL3_ST_SW_CERT_REQ_A:
507         str = "3WCR_A";
508         break;
509     case SSL3_ST_SW_CERT_REQ_B:
510         str = "3WCR_B";
511         break;
512     case SSL3_ST_SW_SRVR_DONE_A:
513         str = "3WSD_A";
514         break;
515     case SSL3_ST_SW_SRVR_DONE_B:
516         str = "3WSD_B";
517         break;
518     case SSL3_ST_SR_CERT_A:
519         str = "3RCC_A";
520         break;
521     case SSL3_ST_SR_CERT_B:
522         str = "3RCC_B";
523         break;
524     case SSL3_ST_SR_KEY_EXCH_A:
525         str = "3RCKEA";
526         break;
527     case SSL3_ST_SR_KEY_EXCH_B:
528         str = "3RCKEB";
529         break;
530     case SSL3_ST_SR_CERT_VRFY_A:
531         str = "3RCV_A";
532         break;
533     case SSL3_ST_SR_CERT_VRFY_B:
534         str = "3RCV_B";
535         break;
536 #endif
537
538 /* SSLv2/v3 compatibility states */
539 /* client */
540     case SSL23_ST_CW_CLNT_HELLO_A:
541         str = "23WCHA";
542         break;
543     case SSL23_ST_CW_CLNT_HELLO_B:
544         str = "23WCHB";
545         break;
546     case SSL23_ST_CR_SRVR_HELLO_A:
547         str = "23RSHA";
548         break;
549     case SSL23_ST_CR_SRVR_HELLO_B:
550         str = "23RSHA";
551         break;
552 /* server */
553     case SSL23_ST_SR_CLNT_HELLO_A:
554         str = "23RCHA";
555         break;
556     case SSL23_ST_SR_CLNT_HELLO_B:
557         str = "23RCHB";
558         break;
559
560 /* DTLS */
561     case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
562         str = "DRCHVA";
563         break;
564     case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
565         str = "DRCHVB";
566         break;
567     case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
568         str = "DWCHVA";
569         break;
570     case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
571         str = "DWCHVB";
572         break;
573
574     default:
575         str = "UNKWN ";
576         break;
577     }
578     return (str);
579 }
580
581 const char *SSL_alert_type_string_long(int value)
582 {
583     value >>= 8;
584     if (value == SSL3_AL_WARNING)
585         return ("warning");
586     else if (value == SSL3_AL_FATAL)
587         return ("fatal");
588     else
589         return ("unknown");
590 }
591
592 const char *SSL_alert_type_string(int value)
593 {
594     value >>= 8;
595     if (value == SSL3_AL_WARNING)
596         return ("W");
597     else if (value == SSL3_AL_FATAL)
598         return ("F");
599     else
600         return ("U");
601 }
602
603 const char *SSL_alert_desc_string(int value)
604 {
605     const char *str;
606
607     switch (value & 0xff) {
608     case SSL3_AD_CLOSE_NOTIFY:
609         str = "CN";
610         break;
611     case SSL3_AD_UNEXPECTED_MESSAGE:
612         str = "UM";
613         break;
614     case SSL3_AD_BAD_RECORD_MAC:
615         str = "BM";
616         break;
617     case SSL3_AD_DECOMPRESSION_FAILURE:
618         str = "DF";
619         break;
620     case SSL3_AD_HANDSHAKE_FAILURE:
621         str = "HF";
622         break;
623     case SSL3_AD_NO_CERTIFICATE:
624         str = "NC";
625         break;
626     case SSL3_AD_BAD_CERTIFICATE:
627         str = "BC";
628         break;
629     case SSL3_AD_UNSUPPORTED_CERTIFICATE:
630         str = "UC";
631         break;
632     case SSL3_AD_CERTIFICATE_REVOKED:
633         str = "CR";
634         break;
635     case SSL3_AD_CERTIFICATE_EXPIRED:
636         str = "CE";
637         break;
638     case SSL3_AD_CERTIFICATE_UNKNOWN:
639         str = "CU";
640         break;
641     case SSL3_AD_ILLEGAL_PARAMETER:
642         str = "IP";
643         break;
644     case TLS1_AD_DECRYPTION_FAILED:
645         str = "DC";
646         break;
647     case TLS1_AD_RECORD_OVERFLOW:
648         str = "RO";
649         break;
650     case TLS1_AD_UNKNOWN_CA:
651         str = "CA";
652         break;
653     case TLS1_AD_ACCESS_DENIED:
654         str = "AD";
655         break;
656     case TLS1_AD_DECODE_ERROR:
657         str = "DE";
658         break;
659     case TLS1_AD_DECRYPT_ERROR:
660         str = "CY";
661         break;
662     case TLS1_AD_EXPORT_RESTRICTION:
663         str = "ER";
664         break;
665     case TLS1_AD_PROTOCOL_VERSION:
666         str = "PV";
667         break;
668     case TLS1_AD_INSUFFICIENT_SECURITY:
669         str = "IS";
670         break;
671     case TLS1_AD_INTERNAL_ERROR:
672         str = "IE";
673         break;
674     case TLS1_AD_USER_CANCELLED:
675         str = "US";
676         break;
677     case TLS1_AD_NO_RENEGOTIATION:
678         str = "NR";
679         break;
680     case TLS1_AD_UNSUPPORTED_EXTENSION:
681         str = "UE";
682         break;
683     case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
684         str = "CO";
685         break;
686     case TLS1_AD_UNRECOGNIZED_NAME:
687         str = "UN";
688         break;
689     case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
690         str = "BR";
691         break;
692     case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
693         str = "BH";
694         break;
695     case TLS1_AD_UNKNOWN_PSK_IDENTITY:
696         str = "UP";
697         break;
698     default:
699         str = "UK";
700         break;
701     }
702     return (str);
703 }
704
705 const char *SSL_alert_desc_string_long(int value)
706 {
707     const char *str;
708
709     switch (value & 0xff) {
710     case SSL3_AD_CLOSE_NOTIFY:
711         str = "close notify";
712         break;
713     case SSL3_AD_UNEXPECTED_MESSAGE:
714         str = "unexpected_message";
715         break;
716     case SSL3_AD_BAD_RECORD_MAC:
717         str = "bad record mac";
718         break;
719     case SSL3_AD_DECOMPRESSION_FAILURE:
720         str = "decompression failure";
721         break;
722     case SSL3_AD_HANDSHAKE_FAILURE:
723         str = "handshake failure";
724         break;
725     case SSL3_AD_NO_CERTIFICATE:
726         str = "no certificate";
727         break;
728     case SSL3_AD_BAD_CERTIFICATE:
729         str = "bad certificate";
730         break;
731     case SSL3_AD_UNSUPPORTED_CERTIFICATE:
732         str = "unsupported certificate";
733         break;
734     case SSL3_AD_CERTIFICATE_REVOKED:
735         str = "certificate revoked";
736         break;
737     case SSL3_AD_CERTIFICATE_EXPIRED:
738         str = "certificate expired";
739         break;
740     case SSL3_AD_CERTIFICATE_UNKNOWN:
741         str = "certificate unknown";
742         break;
743     case SSL3_AD_ILLEGAL_PARAMETER:
744         str = "illegal parameter";
745         break;
746     case TLS1_AD_DECRYPTION_FAILED:
747         str = "decryption failed";
748         break;
749     case TLS1_AD_RECORD_OVERFLOW:
750         str = "record overflow";
751         break;
752     case TLS1_AD_UNKNOWN_CA:
753         str = "unknown CA";
754         break;
755     case TLS1_AD_ACCESS_DENIED:
756         str = "access denied";
757         break;
758     case TLS1_AD_DECODE_ERROR:
759         str = "decode error";
760         break;
761     case TLS1_AD_DECRYPT_ERROR:
762         str = "decrypt error";
763         break;
764     case TLS1_AD_EXPORT_RESTRICTION:
765         str = "export restriction";
766         break;
767     case TLS1_AD_PROTOCOL_VERSION:
768         str = "protocol version";
769         break;
770     case TLS1_AD_INSUFFICIENT_SECURITY:
771         str = "insufficient security";
772         break;
773     case TLS1_AD_INTERNAL_ERROR:
774         str = "internal error";
775         break;
776     case TLS1_AD_USER_CANCELLED:
777         str = "user canceled";
778         break;
779     case TLS1_AD_NO_RENEGOTIATION:
780         str = "no renegotiation";
781         break;
782     case TLS1_AD_UNSUPPORTED_EXTENSION:
783         str = "unsupported extension";
784         break;
785     case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
786         str = "certificate unobtainable";
787         break;
788     case TLS1_AD_UNRECOGNIZED_NAME:
789         str = "unrecognized name";
790         break;
791     case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
792         str = "bad certificate status response";
793         break;
794     case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
795         str = "bad certificate hash value";
796         break;
797     case TLS1_AD_UNKNOWN_PSK_IDENTITY:
798         str = "unknown PSK identity";
799         break;
800     default:
801         str = "unknown";
802         break;
803     }
804     return (str);
805 }