2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
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.
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).
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.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
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)"
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
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.]
58 /* ====================================================================
59 * Copyright 2005 Nokia. All rights reserved.
61 * The portions of the attached software ("Contribution") is developed by
62 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
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.
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.
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.
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
88 const char *SSL_state_string_long(const SSL *s)
94 str = "before SSL initialization";
97 str = "before accept initialization";
100 str = "before connect initialization";
103 str = "SSL negotiation finished successfully";
105 case SSL_ST_RENEGOTIATE:
106 str = "SSL renegotiate ciphers";
108 case SSL_ST_BEFORE | SSL_ST_CONNECT:
109 str = "before/connect initialization";
111 case SSL_ST_OK | SSL_ST_CONNECT:
112 str = "ok/connect SSL initialization";
114 case SSL_ST_BEFORE | SSL_ST_ACCEPT:
115 str = "before/accept initialization";
117 case SSL_ST_OK | SSL_ST_ACCEPT:
118 str = "ok/accept SSL initialization";
124 #ifndef OPENSSL_NO_SSL3
125 /* SSLv3 additions */
126 case SSL3_ST_CW_CLNT_HELLO_A:
127 str = "SSLv3 write client hello A";
129 case SSL3_ST_CW_CLNT_HELLO_B:
130 str = "SSLv3 write client hello B";
132 case SSL3_ST_CR_SRVR_HELLO_A:
133 str = "SSLv3 read server hello A";
135 case SSL3_ST_CR_SRVR_HELLO_B:
136 str = "SSLv3 read server hello B";
138 case SSL3_ST_CR_CERT_A:
139 str = "SSLv3 read server certificate A";
141 case SSL3_ST_CR_CERT_B:
142 str = "SSLv3 read server certificate B";
144 case SSL3_ST_CR_KEY_EXCH_A:
145 str = "SSLv3 read server key exchange A";
147 case SSL3_ST_CR_KEY_EXCH_B:
148 str = "SSLv3 read server key exchange B";
150 case SSL3_ST_CR_CERT_REQ_A:
151 str = "SSLv3 read server certificate request A";
153 case SSL3_ST_CR_CERT_REQ_B:
154 str = "SSLv3 read server certificate request B";
156 case SSL3_ST_CR_SESSION_TICKET_A:
157 str = "SSLv3 read server session ticket A";
159 case SSL3_ST_CR_SESSION_TICKET_B:
160 str = "SSLv3 read server session ticket B";
162 case SSL3_ST_CR_SRVR_DONE_A:
163 str = "SSLv3 read server done A";
165 case SSL3_ST_CR_SRVR_DONE_B:
166 str = "SSLv3 read server done B";
168 case SSL3_ST_CW_CERT_A:
169 str = "SSLv3 write client certificate A";
171 case SSL3_ST_CW_CERT_B:
172 str = "SSLv3 write client certificate B";
174 case SSL3_ST_CW_CERT_C:
175 str = "SSLv3 write client certificate C";
177 case SSL3_ST_CW_CERT_D:
178 str = "SSLv3 write client certificate D";
180 case SSL3_ST_CW_KEY_EXCH_A:
181 str = "SSLv3 write client key exchange A";
183 case SSL3_ST_CW_KEY_EXCH_B:
184 str = "SSLv3 write client key exchange B";
186 case SSL3_ST_CW_CERT_VRFY_A:
187 str = "SSLv3 write certificate verify A";
189 case SSL3_ST_CW_CERT_VRFY_B:
190 str = "SSLv3 write certificate verify B";
193 case SSL3_ST_CW_CHANGE_A:
194 case SSL3_ST_SW_CHANGE_A:
195 str = "SSLv3 write change cipher spec A";
197 case SSL3_ST_CW_CHANGE_B:
198 case SSL3_ST_SW_CHANGE_B:
199 str = "SSLv3 write change cipher spec B";
201 case SSL3_ST_CW_FINISHED_A:
202 case SSL3_ST_SW_FINISHED_A:
203 str = "SSLv3 write finished A";
205 case SSL3_ST_CW_FINISHED_B:
206 case SSL3_ST_SW_FINISHED_B:
207 str = "SSLv3 write finished B";
209 case SSL3_ST_CR_CHANGE_A:
210 case SSL3_ST_SR_CHANGE_A:
211 str = "SSLv3 read change cipher spec A";
213 case SSL3_ST_CR_CHANGE_B:
214 case SSL3_ST_SR_CHANGE_B:
215 str = "SSLv3 read change cipher spec B";
217 case SSL3_ST_CR_FINISHED_A:
218 case SSL3_ST_SR_FINISHED_A:
219 str = "SSLv3 read finished A";
221 case SSL3_ST_CR_FINISHED_B:
222 case SSL3_ST_SR_FINISHED_B:
223 str = "SSLv3 read finished B";
226 case SSL3_ST_CW_FLUSH:
227 case SSL3_ST_SW_FLUSH:
228 str = "SSLv3 flush data";
231 case SSL3_ST_SR_CLNT_HELLO_A:
232 str = "SSLv3 read client hello A";
234 case SSL3_ST_SR_CLNT_HELLO_B:
235 str = "SSLv3 read client hello B";
237 case SSL3_ST_SR_CLNT_HELLO_C:
238 str = "SSLv3 read client hello C";
240 case SSL3_ST_SW_HELLO_REQ_A:
241 str = "SSLv3 write hello request A";
243 case SSL3_ST_SW_HELLO_REQ_B:
244 str = "SSLv3 write hello request B";
246 case SSL3_ST_SW_HELLO_REQ_C:
247 str = "SSLv3 write hello request C";
249 case SSL3_ST_SW_SRVR_HELLO_A:
250 str = "SSLv3 write server hello A";
252 case SSL3_ST_SW_SRVR_HELLO_B:
253 str = "SSLv3 write server hello B";
255 case SSL3_ST_SW_CERT_A:
256 str = "SSLv3 write certificate A";
258 case SSL3_ST_SW_CERT_B:
259 str = "SSLv3 write certificate B";
261 case SSL3_ST_SW_KEY_EXCH_A:
262 str = "SSLv3 write key exchange A";
264 case SSL3_ST_SW_KEY_EXCH_B:
265 str = "SSLv3 write key exchange B";
267 case SSL3_ST_SW_CERT_REQ_A:
268 str = "SSLv3 write certificate request A";
270 case SSL3_ST_SW_CERT_REQ_B:
271 str = "SSLv3 write certificate request B";
273 case SSL3_ST_SW_SESSION_TICKET_A:
274 str = "SSLv3 write session ticket A";
276 case SSL3_ST_SW_SESSION_TICKET_B:
277 str = "SSLv3 write session ticket B";
279 case SSL3_ST_SW_SRVR_DONE_A:
280 str = "SSLv3 write server done A";
282 case SSL3_ST_SW_SRVR_DONE_B:
283 str = "SSLv3 write server done B";
285 case SSL3_ST_SR_CERT_A:
286 str = "SSLv3 read client certificate A";
288 case SSL3_ST_SR_CERT_B:
289 str = "SSLv3 read client certificate B";
291 case SSL3_ST_SR_KEY_EXCH_A:
292 str = "SSLv3 read client key exchange A";
294 case SSL3_ST_SR_KEY_EXCH_B:
295 str = "SSLv3 read client key exchange B";
297 case SSL3_ST_SR_CERT_VRFY_A:
298 str = "SSLv3 read certificate verify A";
300 case SSL3_ST_SR_CERT_VRFY_B:
301 str = "SSLv3 read certificate verify B";
306 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
307 str = "DTLS1 read hello verify request A";
309 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
310 str = "DTLS1 read hello verify request B";
312 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
313 str = "DTLS1 write hello verify request A";
315 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
316 str = "DTLS1 write hello verify request B";
320 str = "unknown state";
327 const char *SSL_state_string(const SSL *s)
348 #ifndef OPENSSL_NO_SSL3
349 /* SSLv3 additions */
350 case SSL3_ST_SW_FLUSH:
351 case SSL3_ST_CW_FLUSH:
354 case SSL3_ST_CW_CLNT_HELLO_A:
357 case SSL3_ST_CW_CLNT_HELLO_B:
360 case SSL3_ST_CR_SRVR_HELLO_A:
363 case SSL3_ST_CR_SRVR_HELLO_B:
366 case SSL3_ST_CR_CERT_A:
369 case SSL3_ST_CR_CERT_B:
372 case SSL3_ST_CR_KEY_EXCH_A:
375 case SSL3_ST_CR_KEY_EXCH_B:
378 case SSL3_ST_CR_CERT_REQ_A:
381 case SSL3_ST_CR_CERT_REQ_B:
384 case SSL3_ST_CR_SRVR_DONE_A:
387 case SSL3_ST_CR_SRVR_DONE_B:
390 case SSL3_ST_CW_CERT_A:
393 case SSL3_ST_CW_CERT_B:
396 case SSL3_ST_CW_CERT_C:
399 case SSL3_ST_CW_CERT_D:
402 case SSL3_ST_CW_KEY_EXCH_A:
405 case SSL3_ST_CW_KEY_EXCH_B:
408 case SSL3_ST_CW_CERT_VRFY_A:
411 case SSL3_ST_CW_CERT_VRFY_B:
415 case SSL3_ST_SW_CHANGE_A:
416 case SSL3_ST_CW_CHANGE_A:
419 case SSL3_ST_SW_CHANGE_B:
420 case SSL3_ST_CW_CHANGE_B:
423 case SSL3_ST_SW_FINISHED_A:
424 case SSL3_ST_CW_FINISHED_A:
427 case SSL3_ST_SW_FINISHED_B:
428 case SSL3_ST_CW_FINISHED_B:
431 case SSL3_ST_SR_CHANGE_A:
432 case SSL3_ST_CR_CHANGE_A:
435 case SSL3_ST_SR_CHANGE_B:
436 case SSL3_ST_CR_CHANGE_B:
439 case SSL3_ST_SR_FINISHED_A:
440 case SSL3_ST_CR_FINISHED_A:
443 case SSL3_ST_SR_FINISHED_B:
444 case SSL3_ST_CR_FINISHED_B:
448 case SSL3_ST_SW_HELLO_REQ_A:
451 case SSL3_ST_SW_HELLO_REQ_B:
454 case SSL3_ST_SW_HELLO_REQ_C:
457 case SSL3_ST_SR_CLNT_HELLO_A:
460 case SSL3_ST_SR_CLNT_HELLO_B:
463 case SSL3_ST_SR_CLNT_HELLO_C:
466 case SSL3_ST_SW_SRVR_HELLO_A:
469 case SSL3_ST_SW_SRVR_HELLO_B:
472 case SSL3_ST_SW_CERT_A:
475 case SSL3_ST_SW_CERT_B:
478 case SSL3_ST_SW_KEY_EXCH_A:
481 case SSL3_ST_SW_KEY_EXCH_B:
484 case SSL3_ST_SW_CERT_REQ_A:
487 case SSL3_ST_SW_CERT_REQ_B:
490 case SSL3_ST_SW_SRVR_DONE_A:
493 case SSL3_ST_SW_SRVR_DONE_B:
496 case SSL3_ST_SR_CERT_A:
499 case SSL3_ST_SR_CERT_B:
502 case SSL3_ST_SR_KEY_EXCH_A:
505 case SSL3_ST_SR_KEY_EXCH_B:
508 case SSL3_ST_SR_CERT_VRFY_A:
511 case SSL3_ST_SR_CERT_VRFY_B:
517 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
520 case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
523 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
526 case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
537 const char *SSL_alert_type_string_long(int value)
540 if (value == SSL3_AL_WARNING)
542 else if (value == SSL3_AL_FATAL)
548 const char *SSL_alert_type_string(int value)
551 if (value == SSL3_AL_WARNING)
553 else if (value == SSL3_AL_FATAL)
559 const char *SSL_alert_desc_string(int value)
563 switch (value & 0xff) {
564 case SSL3_AD_CLOSE_NOTIFY:
567 case SSL3_AD_UNEXPECTED_MESSAGE:
570 case SSL3_AD_BAD_RECORD_MAC:
573 case SSL3_AD_DECOMPRESSION_FAILURE:
576 case SSL3_AD_HANDSHAKE_FAILURE:
579 case SSL3_AD_NO_CERTIFICATE:
582 case SSL3_AD_BAD_CERTIFICATE:
585 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
588 case SSL3_AD_CERTIFICATE_REVOKED:
591 case SSL3_AD_CERTIFICATE_EXPIRED:
594 case SSL3_AD_CERTIFICATE_UNKNOWN:
597 case SSL3_AD_ILLEGAL_PARAMETER:
600 case TLS1_AD_DECRYPTION_FAILED:
603 case TLS1_AD_RECORD_OVERFLOW:
606 case TLS1_AD_UNKNOWN_CA:
609 case TLS1_AD_ACCESS_DENIED:
612 case TLS1_AD_DECODE_ERROR:
615 case TLS1_AD_DECRYPT_ERROR:
618 case TLS1_AD_EXPORT_RESTRICTION:
621 case TLS1_AD_PROTOCOL_VERSION:
624 case TLS1_AD_INSUFFICIENT_SECURITY:
627 case TLS1_AD_INTERNAL_ERROR:
630 case TLS1_AD_USER_CANCELLED:
633 case TLS1_AD_NO_RENEGOTIATION:
636 case TLS1_AD_UNSUPPORTED_EXTENSION:
639 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
642 case TLS1_AD_UNRECOGNIZED_NAME:
645 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
648 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
651 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
661 const char *SSL_alert_desc_string_long(int value)
665 switch (value & 0xff) {
666 case SSL3_AD_CLOSE_NOTIFY:
667 str = "close notify";
669 case SSL3_AD_UNEXPECTED_MESSAGE:
670 str = "unexpected_message";
672 case SSL3_AD_BAD_RECORD_MAC:
673 str = "bad record mac";
675 case SSL3_AD_DECOMPRESSION_FAILURE:
676 str = "decompression failure";
678 case SSL3_AD_HANDSHAKE_FAILURE:
679 str = "handshake failure";
681 case SSL3_AD_NO_CERTIFICATE:
682 str = "no certificate";
684 case SSL3_AD_BAD_CERTIFICATE:
685 str = "bad certificate";
687 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
688 str = "unsupported certificate";
690 case SSL3_AD_CERTIFICATE_REVOKED:
691 str = "certificate revoked";
693 case SSL3_AD_CERTIFICATE_EXPIRED:
694 str = "certificate expired";
696 case SSL3_AD_CERTIFICATE_UNKNOWN:
697 str = "certificate unknown";
699 case SSL3_AD_ILLEGAL_PARAMETER:
700 str = "illegal parameter";
702 case TLS1_AD_DECRYPTION_FAILED:
703 str = "decryption failed";
705 case TLS1_AD_RECORD_OVERFLOW:
706 str = "record overflow";
708 case TLS1_AD_UNKNOWN_CA:
711 case TLS1_AD_ACCESS_DENIED:
712 str = "access denied";
714 case TLS1_AD_DECODE_ERROR:
715 str = "decode error";
717 case TLS1_AD_DECRYPT_ERROR:
718 str = "decrypt error";
720 case TLS1_AD_EXPORT_RESTRICTION:
721 str = "export restriction";
723 case TLS1_AD_PROTOCOL_VERSION:
724 str = "protocol version";
726 case TLS1_AD_INSUFFICIENT_SECURITY:
727 str = "insufficient security";
729 case TLS1_AD_INTERNAL_ERROR:
730 str = "internal error";
732 case TLS1_AD_USER_CANCELLED:
733 str = "user canceled";
735 case TLS1_AD_NO_RENEGOTIATION:
736 str = "no renegotiation";
738 case TLS1_AD_UNSUPPORTED_EXTENSION:
739 str = "unsupported extension";
741 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
742 str = "certificate unobtainable";
744 case TLS1_AD_UNRECOGNIZED_NAME:
745 str = "unrecognized name";
747 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
748 str = "bad certificate status response";
750 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
751 str = "bad certificate hash value";
753 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
754 str = "unknown PSK identity";