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