1 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
4 * This package is an SSL implementation written
5 * by Eric Young (eay@cryptsoft.com).
6 * The implementation was written so as to conform with Netscapes SSL.
8 * This library is free for commercial and non-commercial use as long as
9 * the following conditions are aheared to. The following conditions
10 * apply to all code found in this distribution, be it the RC4, RSA,
11 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
12 * included with this distribution is covered by the same copyright terms
13 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * Copyright remains Eric Young's, and as such any Copyright notices in
16 * the code are not to be removed.
17 * If this package is used in a product, Eric Young should be given attribution
18 * as the author of the parts of the library used.
19 * This can be in the form of a textual message at program startup or
20 * in documentation (online or textual) provided with the package.
22 * Redistribution and use in source and binary forms, with or without
23 * modification, are permitted provided that the following conditions
25 * 1. Redistributions of source code must retain the copyright
26 * notice, this list of conditions and the following disclaimer.
27 * 2. Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * 3. All advertising materials mentioning features or use of this software
31 * must display the following acknowledgement:
32 * "This product includes cryptographic software written by
33 * Eric Young (eay@cryptsoft.com)"
34 * The word 'cryptographic' can be left out if the rouines from the library
35 * being used are not cryptographic related :-).
36 * 4. If you include any Windows specific code (or a derivative thereof) from
37 * the apps directory (application code) you must include an acknowledgement:
38 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
41 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
43 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
44 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
45 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
46 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
48 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
49 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * The licence and distribution terms for any publically available version or
53 * derivative of this code cannot be changed. i.e. this code cannot simply be
54 * copied and put under another distribution licence
55 * [including the GNU Public Licence.]
57 /* ====================================================================
58 * Copyright 2005 Nokia. All rights reserved.
60 * The portions of the attached software ("Contribution") is developed by
61 * Nokia Corporation and is licensed pursuant to the OpenSSL open source
64 * The Contribution, originally written by Mika Kousa and Pasi Eronen of
65 * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites
66 * support (see RFC 4279) to OpenSSL.
68 * No patent licenses or other rights except those expressly stated in
69 * the OpenSSL open source license shall be deemed granted or received
70 * expressly, by implication, estoppel, or otherwise.
72 * No assurances are provided by Nokia that the Contribution does not
73 * infringe the patent or other intellectual property rights of any third
74 * party or that the license provides you with all the necessary rights
75 * to make use of the Contribution.
77 * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN
78 * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA
79 * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY
80 * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR
87 const char *SSL_state_string_long(const SSL *s)
91 if (ossl_statem_in_error(s)) {
95 switch (SSL_get_state(s)) {
97 str = "before SSL initialization";
100 str = "SSL negotiation finished successfully";
103 /* SSLv3 additions */
104 case TLS_ST_CW_CLNT_HELLO:
105 str = "SSLv3/TLS write client hello";
107 case TLS_ST_CR_SRVR_HELLO:
108 str = "SSLv3/TLS read server hello";
111 str = "SSLv3/TLS read server certificate";
113 case TLS_ST_CR_KEY_EXCH:
114 str = "SSLv3/TLS read server key exchange";
116 case TLS_ST_CR_CERT_REQ:
117 str = "SSLv3/TLS read server certificate request";
119 case TLS_ST_CR_SESSION_TICKET:
120 str = "SSLv3/TLS read server session ticket";
122 case TLS_ST_CR_SRVR_DONE:
123 str = "SSLv3/TLS read server done";
126 str = "SSLv3/TLS write client certificate";
128 case TLS_ST_CW_KEY_EXCH:
129 str = "SSLv3/TLS write client key exchange";
131 case TLS_ST_CW_CERT_VRFY:
132 str = "SSLv3/TLS write certificate verify";
135 case TLS_ST_CW_CHANGE:
136 case TLS_ST_SW_CHANGE:
137 str = "SSLv3/TLS write change cipher spec";
139 case TLS_ST_CW_FINISHED:
140 case TLS_ST_SW_FINISHED:
141 str = "SSLv3/TLS write finished";
143 case TLS_ST_CR_CHANGE:
144 case TLS_ST_SR_CHANGE:
145 str = "SSLv3/TLS read change cipher spec";
147 case TLS_ST_CR_FINISHED:
148 case TLS_ST_SR_FINISHED:
149 str = "SSLv3/TLS read finished";
152 case TLS_ST_SR_CLNT_HELLO:
153 str = "SSLv3/TLS read client hello";
155 case TLS_ST_SW_HELLO_REQ:
156 str = "SSLv3/TLS write hello request";
158 case TLS_ST_SW_SRVR_HELLO:
159 str = "SSLv3/TLS write server hello";
162 str = "SSLv3/TLS write certificate";
164 case TLS_ST_SW_KEY_EXCH:
165 str = "SSLv3/TLS write key exchange";
167 case TLS_ST_SW_CERT_REQ:
168 str = "SSLv3/TLS write certificate request";
170 case TLS_ST_SW_SESSION_TICKET:
171 str = "SSLv3/TLS write session ticket";
173 case TLS_ST_SW_SRVR_DONE:
174 str = "SSLv3/TLS write server done";
177 str = "SSLv3/TLS read client certificate";
179 case TLS_ST_SR_KEY_EXCH:
180 str = "SSLv3/TLS read client key exchange";
182 case TLS_ST_SR_CERT_VRFY:
183 str = "SSLv3/TLS read certificate verify";
187 case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
188 str = "DTLS1 read hello verify request";
190 case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
191 str = "DTLS1 write hello verify request";
195 str = "unknown state";
202 const char *SSL_state_string(const SSL *s)
206 if (ossl_statem_in_error(s)) {
210 switch (SSL_get_state(s)) {
218 case TLS_ST_CW_CLNT_HELLO:
221 case TLS_ST_CR_SRVR_HELLO:
227 case TLS_ST_CR_KEY_EXCH:
230 case TLS_ST_CR_CERT_REQ:
233 case TLS_ST_CR_SRVR_DONE:
239 case TLS_ST_CW_KEY_EXCH:
242 case TLS_ST_CW_CERT_VRFY:
246 case TLS_ST_SW_CHANGE:
247 case TLS_ST_CW_CHANGE:
250 case TLS_ST_SW_FINISHED:
251 case TLS_ST_CW_FINISHED:
254 case TLS_ST_SR_CHANGE:
255 case TLS_ST_CR_CHANGE:
258 case TLS_ST_SR_FINISHED:
259 case TLS_ST_CR_FINISHED:
263 case TLS_ST_SW_HELLO_REQ:
266 case TLS_ST_SR_CLNT_HELLO:
269 case TLS_ST_SW_SRVR_HELLO:
275 case TLS_ST_SW_KEY_EXCH:
278 case TLS_ST_SW_CERT_REQ:
281 case TLS_ST_SW_SRVR_DONE:
287 case TLS_ST_SR_KEY_EXCH:
290 case TLS_ST_SR_CERT_VRFY:
295 case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
298 case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
309 const char *SSL_alert_type_string_long(int value)
312 if (value == SSL3_AL_WARNING)
314 else if (value == SSL3_AL_FATAL)
320 const char *SSL_alert_type_string(int value)
323 if (value == SSL3_AL_WARNING)
325 else if (value == SSL3_AL_FATAL)
331 const char *SSL_alert_desc_string(int value)
335 switch (value & 0xff) {
336 case SSL3_AD_CLOSE_NOTIFY:
339 case SSL3_AD_UNEXPECTED_MESSAGE:
342 case SSL3_AD_BAD_RECORD_MAC:
345 case SSL3_AD_DECOMPRESSION_FAILURE:
348 case SSL3_AD_HANDSHAKE_FAILURE:
351 case SSL3_AD_NO_CERTIFICATE:
354 case SSL3_AD_BAD_CERTIFICATE:
357 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
360 case SSL3_AD_CERTIFICATE_REVOKED:
363 case SSL3_AD_CERTIFICATE_EXPIRED:
366 case SSL3_AD_CERTIFICATE_UNKNOWN:
369 case SSL3_AD_ILLEGAL_PARAMETER:
372 case TLS1_AD_DECRYPTION_FAILED:
375 case TLS1_AD_RECORD_OVERFLOW:
378 case TLS1_AD_UNKNOWN_CA:
381 case TLS1_AD_ACCESS_DENIED:
384 case TLS1_AD_DECODE_ERROR:
387 case TLS1_AD_DECRYPT_ERROR:
390 case TLS1_AD_EXPORT_RESTRICTION:
393 case TLS1_AD_PROTOCOL_VERSION:
396 case TLS1_AD_INSUFFICIENT_SECURITY:
399 case TLS1_AD_INTERNAL_ERROR:
402 case TLS1_AD_USER_CANCELLED:
405 case TLS1_AD_NO_RENEGOTIATION:
408 case TLS1_AD_UNSUPPORTED_EXTENSION:
411 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
414 case TLS1_AD_UNRECOGNIZED_NAME:
417 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
420 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
423 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
433 const char *SSL_alert_desc_string_long(int value)
437 switch (value & 0xff) {
438 case SSL3_AD_CLOSE_NOTIFY:
439 str = "close notify";
441 case SSL3_AD_UNEXPECTED_MESSAGE:
442 str = "unexpected_message";
444 case SSL3_AD_BAD_RECORD_MAC:
445 str = "bad record mac";
447 case SSL3_AD_DECOMPRESSION_FAILURE:
448 str = "decompression failure";
450 case SSL3_AD_HANDSHAKE_FAILURE:
451 str = "handshake failure";
453 case SSL3_AD_NO_CERTIFICATE:
454 str = "no certificate";
456 case SSL3_AD_BAD_CERTIFICATE:
457 str = "bad certificate";
459 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
460 str = "unsupported certificate";
462 case SSL3_AD_CERTIFICATE_REVOKED:
463 str = "certificate revoked";
465 case SSL3_AD_CERTIFICATE_EXPIRED:
466 str = "certificate expired";
468 case SSL3_AD_CERTIFICATE_UNKNOWN:
469 str = "certificate unknown";
471 case SSL3_AD_ILLEGAL_PARAMETER:
472 str = "illegal parameter";
474 case TLS1_AD_DECRYPTION_FAILED:
475 str = "decryption failed";
477 case TLS1_AD_RECORD_OVERFLOW:
478 str = "record overflow";
480 case TLS1_AD_UNKNOWN_CA:
483 case TLS1_AD_ACCESS_DENIED:
484 str = "access denied";
486 case TLS1_AD_DECODE_ERROR:
487 str = "decode error";
489 case TLS1_AD_DECRYPT_ERROR:
490 str = "decrypt error";
492 case TLS1_AD_EXPORT_RESTRICTION:
493 str = "export restriction";
495 case TLS1_AD_PROTOCOL_VERSION:
496 str = "protocol version";
498 case TLS1_AD_INSUFFICIENT_SECURITY:
499 str = "insufficient security";
501 case TLS1_AD_INTERNAL_ERROR:
502 str = "internal error";
504 case TLS1_AD_USER_CANCELLED:
505 str = "user canceled";
507 case TLS1_AD_NO_RENEGOTIATION:
508 str = "no renegotiation";
510 case TLS1_AD_UNSUPPORTED_EXTENSION:
511 str = "unsupported extension";
513 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
514 str = "certificate unobtainable";
516 case TLS1_AD_UNRECOGNIZED_NAME:
517 str = "unrecognized name";
519 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
520 str = "bad certificate status response";
522 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
523 str = "bad certificate hash value";
525 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
526 str = "unknown PSK identity";