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)
92 if (statem_in_error(s)) {
96 switch (SSL_state(s)) {
98 str = "before SSL initialization";
101 str = "SSL negotiation finished successfully";
104 /* SSLv3 additions */
105 case TLS_ST_CW_CLNT_HELLO:
106 str = "SSLv3/TLS write client hello";
108 case TLS_ST_CR_SRVR_HELLO:
109 str = "SSLv3/TLS read server hello";
112 str = "SSLv3/TLS read server certificate";
114 case TLS_ST_CR_KEY_EXCH:
115 str = "SSLv3/TLS read server key exchange";
117 case TLS_ST_CR_CERT_REQ:
118 str = "SSLv3/TLS read server certificate request";
120 case TLS_ST_CR_SESSION_TICKET:
121 str = "SSLv3/TLS read server session ticket";
123 case TLS_ST_CR_SRVR_DONE:
124 str = "SSLv3/TLS read server done";
127 str = "SSLv3/TLS write client certificate";
129 case TLS_ST_CW_KEY_EXCH:
130 str = "SSLv3/TLS write client key exchange";
132 case TLS_ST_CW_CERT_VRFY:
133 str = "SSLv3/TLS write certificate verify";
136 case TLS_ST_CW_CHANGE:
137 case TLS_ST_SW_CHANGE:
138 str = "SSLv3/TLS write change cipher spec";
140 case TLS_ST_CW_FINISHED:
141 case TLS_ST_SW_FINISHED:
142 str = "SSLv3/TLS write finished";
144 case TLS_ST_CR_CHANGE:
145 case TLS_ST_SR_CHANGE:
146 str = "SSLv3/TLS read change cipher spec";
148 case TLS_ST_CR_FINISHED:
149 case TLS_ST_SR_FINISHED:
150 str = "SSLv3/TLS read finished";
153 case TLS_ST_SR_CLNT_HELLO:
154 str = "SSLv3/TLS read client hello";
156 case TLS_ST_SW_HELLO_REQ:
157 str = "SSLv3/TLS write hello request";
159 case TLS_ST_SW_SRVR_HELLO:
160 str = "SSLv3/TLS write server hello";
163 str = "SSLv3/TLS write certificate";
165 case TLS_ST_SW_KEY_EXCH:
166 str = "SSLv3/TLS write key exchange";
168 case TLS_ST_SW_CERT_REQ:
169 str = "SSLv3/TLS write certificate request";
171 case TLS_ST_SW_SESSION_TICKET:
172 str = "SSLv3/TLS write session ticket";
174 case TLS_ST_SW_SRVR_DONE:
175 str = "SSLv3/TLS write server done";
178 str = "SSLv3/TLS read client certificate";
180 case TLS_ST_SR_KEY_EXCH:
181 str = "SSLv3/TLS read client key exchange";
183 case TLS_ST_SR_CERT_VRFY:
184 str = "SSLv3/TLS read certificate verify";
188 case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
189 str = "DTLS1 read hello verify request";
191 case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
192 str = "DTLS1 write hello verify request";
196 str = "unknown state";
203 const char *SSL_state_string(const SSL *s)
207 if (statem_in_error(s)) {
211 switch (SSL_state(s)) {
219 case TLS_ST_CW_CLNT_HELLO:
222 case TLS_ST_CR_SRVR_HELLO:
228 case TLS_ST_CR_KEY_EXCH:
231 case TLS_ST_CR_CERT_REQ:
234 case TLS_ST_CR_SRVR_DONE:
240 case TLS_ST_CW_KEY_EXCH:
243 case TLS_ST_CW_CERT_VRFY:
247 case TLS_ST_SW_CHANGE:
248 case TLS_ST_CW_CHANGE:
251 case TLS_ST_SW_FINISHED:
252 case TLS_ST_CW_FINISHED:
255 case TLS_ST_SR_CHANGE:
256 case TLS_ST_CR_CHANGE:
259 case TLS_ST_SR_FINISHED:
260 case TLS_ST_CR_FINISHED:
264 case TLS_ST_SW_HELLO_REQ:
267 case TLS_ST_SR_CLNT_HELLO:
270 case TLS_ST_SW_SRVR_HELLO:
276 case TLS_ST_SW_KEY_EXCH:
279 case TLS_ST_SW_CERT_REQ:
282 case TLS_ST_SW_SRVR_DONE:
288 case TLS_ST_SR_KEY_EXCH:
291 case TLS_ST_SR_CERT_VRFY:
296 case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
299 case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
310 const char *SSL_alert_type_string_long(int value)
313 if (value == SSL3_AL_WARNING)
315 else if (value == SSL3_AL_FATAL)
321 const char *SSL_alert_type_string(int value)
324 if (value == SSL3_AL_WARNING)
326 else if (value == SSL3_AL_FATAL)
332 const char *SSL_alert_desc_string(int value)
336 switch (value & 0xff) {
337 case SSL3_AD_CLOSE_NOTIFY:
340 case SSL3_AD_UNEXPECTED_MESSAGE:
343 case SSL3_AD_BAD_RECORD_MAC:
346 case SSL3_AD_DECOMPRESSION_FAILURE:
349 case SSL3_AD_HANDSHAKE_FAILURE:
352 case SSL3_AD_NO_CERTIFICATE:
355 case SSL3_AD_BAD_CERTIFICATE:
358 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
361 case SSL3_AD_CERTIFICATE_REVOKED:
364 case SSL3_AD_CERTIFICATE_EXPIRED:
367 case SSL3_AD_CERTIFICATE_UNKNOWN:
370 case SSL3_AD_ILLEGAL_PARAMETER:
373 case TLS1_AD_DECRYPTION_FAILED:
376 case TLS1_AD_RECORD_OVERFLOW:
379 case TLS1_AD_UNKNOWN_CA:
382 case TLS1_AD_ACCESS_DENIED:
385 case TLS1_AD_DECODE_ERROR:
388 case TLS1_AD_DECRYPT_ERROR:
391 case TLS1_AD_EXPORT_RESTRICTION:
394 case TLS1_AD_PROTOCOL_VERSION:
397 case TLS1_AD_INSUFFICIENT_SECURITY:
400 case TLS1_AD_INTERNAL_ERROR:
403 case TLS1_AD_USER_CANCELLED:
406 case TLS1_AD_NO_RENEGOTIATION:
409 case TLS1_AD_UNSUPPORTED_EXTENSION:
412 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
415 case TLS1_AD_UNRECOGNIZED_NAME:
418 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
421 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
424 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
434 const char *SSL_alert_desc_string_long(int value)
438 switch (value & 0xff) {
439 case SSL3_AD_CLOSE_NOTIFY:
440 str = "close notify";
442 case SSL3_AD_UNEXPECTED_MESSAGE:
443 str = "unexpected_message";
445 case SSL3_AD_BAD_RECORD_MAC:
446 str = "bad record mac";
448 case SSL3_AD_DECOMPRESSION_FAILURE:
449 str = "decompression failure";
451 case SSL3_AD_HANDSHAKE_FAILURE:
452 str = "handshake failure";
454 case SSL3_AD_NO_CERTIFICATE:
455 str = "no certificate";
457 case SSL3_AD_BAD_CERTIFICATE:
458 str = "bad certificate";
460 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
461 str = "unsupported certificate";
463 case SSL3_AD_CERTIFICATE_REVOKED:
464 str = "certificate revoked";
466 case SSL3_AD_CERTIFICATE_EXPIRED:
467 str = "certificate expired";
469 case SSL3_AD_CERTIFICATE_UNKNOWN:
470 str = "certificate unknown";
472 case SSL3_AD_ILLEGAL_PARAMETER:
473 str = "illegal parameter";
475 case TLS1_AD_DECRYPTION_FAILED:
476 str = "decryption failed";
478 case TLS1_AD_RECORD_OVERFLOW:
479 str = "record overflow";
481 case TLS1_AD_UNKNOWN_CA:
484 case TLS1_AD_ACCESS_DENIED:
485 str = "access denied";
487 case TLS1_AD_DECODE_ERROR:
488 str = "decode error";
490 case TLS1_AD_DECRYPT_ERROR:
491 str = "decrypt error";
493 case TLS1_AD_EXPORT_RESTRICTION:
494 str = "export restriction";
496 case TLS1_AD_PROTOCOL_VERSION:
497 str = "protocol version";
499 case TLS1_AD_INSUFFICIENT_SECURITY:
500 str = "insufficient security";
502 case TLS1_AD_INTERNAL_ERROR:
503 str = "internal error";
505 case TLS1_AD_USER_CANCELLED:
506 str = "user canceled";
508 case TLS1_AD_NO_RENEGOTIATION:
509 str = "no renegotiation";
511 case TLS1_AD_UNSUPPORTED_EXTENSION:
512 str = "unsupported extension";
514 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
515 str = "certificate unobtainable";
517 case TLS1_AD_UNRECOGNIZED_NAME:
518 str = "unrecognized name";
520 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
521 str = "bad certificate status response";
523 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
524 str = "bad certificate hash value";
526 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
527 str = "unknown PSK identity";