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)
89 if (ossl_statem_in_error(s))
92 switch (SSL_get_state(s)) {
94 return "before SSL initialization";
96 return "SSL negotiation finished successfully";
97 case TLS_ST_CW_CLNT_HELLO:
98 return "SSLv3/TLS write client hello";
99 case TLS_ST_CR_SRVR_HELLO:
100 return "SSLv3/TLS read server hello";
102 return "SSLv3/TLS read server certificate";
103 case TLS_ST_CR_KEY_EXCH:
104 return "SSLv3/TLS read server key exchange";
105 case TLS_ST_CR_CERT_REQ:
106 return "SSLv3/TLS read server certificate request";
107 case TLS_ST_CR_SESSION_TICKET:
108 return "SSLv3/TLS read server session ticket";
109 case TLS_ST_CR_SRVR_DONE:
110 return "SSLv3/TLS read server done";
112 return "SSLv3/TLS write client certificate";
113 case TLS_ST_CW_KEY_EXCH:
114 return "SSLv3/TLS write client key exchange";
115 case TLS_ST_CW_CERT_VRFY:
116 return "SSLv3/TLS write certificate verify";
117 case TLS_ST_CW_CHANGE:
118 case TLS_ST_SW_CHANGE:
119 return "SSLv3/TLS write change cipher spec";
120 case TLS_ST_CW_FINISHED:
121 case TLS_ST_SW_FINISHED:
122 return "SSLv3/TLS write finished";
123 case TLS_ST_CR_CHANGE:
124 case TLS_ST_SR_CHANGE:
125 return "SSLv3/TLS read change cipher spec";
126 case TLS_ST_CR_FINISHED:
127 case TLS_ST_SR_FINISHED:
128 return "SSLv3/TLS read finished";
129 case TLS_ST_SR_CLNT_HELLO:
130 return "SSLv3/TLS read client hello";
131 case TLS_ST_SW_HELLO_REQ:
132 return "SSLv3/TLS write hello request";
133 case TLS_ST_SW_SRVR_HELLO:
134 return "SSLv3/TLS write server hello";
136 return "SSLv3/TLS write certificate";
137 case TLS_ST_SW_KEY_EXCH:
138 return "SSLv3/TLS write key exchange";
139 case TLS_ST_SW_CERT_REQ:
140 return "SSLv3/TLS write certificate request";
141 case TLS_ST_SW_SESSION_TICKET:
142 return "SSLv3/TLS write session ticket";
143 case TLS_ST_SW_SRVR_DONE:
144 return "SSLv3/TLS write server done";
146 return "SSLv3/TLS read client certificate";
147 case TLS_ST_SR_KEY_EXCH:
148 return "SSLv3/TLS read client key exchange";
149 case TLS_ST_SR_CERT_VRFY:
150 return "SSLv3/TLS read certificate verify";
151 case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
152 return "DTLS1 read hello verify request";
153 case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
154 return "DTLS1 write hello verify request";
156 return "unknown state";
161 const char *SSL_state_string(const SSL *s)
163 if (ossl_statem_in_error(s))
166 switch (SSL_get_state(s)) {
171 case TLS_ST_CW_CLNT_HELLO:
173 case TLS_ST_CR_SRVR_HELLO:
177 case TLS_ST_CR_KEY_EXCH:
179 case TLS_ST_CR_CERT_REQ:
181 case TLS_ST_CR_SRVR_DONE:
185 case TLS_ST_CW_KEY_EXCH:
187 case TLS_ST_CW_CERT_VRFY:
189 case TLS_ST_SW_CHANGE:
190 case TLS_ST_CW_CHANGE:
192 case TLS_ST_SW_FINISHED:
193 case TLS_ST_CW_FINISHED:
195 case TLS_ST_SR_CHANGE:
196 case TLS_ST_CR_CHANGE:
198 case TLS_ST_SR_FINISHED:
199 case TLS_ST_CR_FINISHED:
201 case TLS_ST_SW_HELLO_REQ:
203 case TLS_ST_SR_CLNT_HELLO:
205 case TLS_ST_SW_SRVR_HELLO:
209 case TLS_ST_SW_KEY_EXCH:
211 case TLS_ST_SW_CERT_REQ:
213 case TLS_ST_SW_SRVR_DONE:
217 case TLS_ST_SR_KEY_EXCH:
219 case TLS_ST_SR_CERT_VRFY:
221 case DTLS_ST_CR_HELLO_VERIFY_REQUEST:
223 case DTLS_ST_SW_HELLO_VERIFY_REQUEST:
230 const char *SSL_alert_type_string_long(int value)
232 switch (value >> 8) {
233 case SSL3_AL_WARNING:
242 const char *SSL_alert_type_string(int value)
244 switch (value >> 8) {
245 case SSL3_AL_WARNING:
254 const char *SSL_alert_desc_string(int value)
256 switch (value & 0xff) {
257 case SSL3_AD_CLOSE_NOTIFY:
259 case SSL3_AD_UNEXPECTED_MESSAGE:
261 case SSL3_AD_BAD_RECORD_MAC:
263 case SSL3_AD_DECOMPRESSION_FAILURE:
265 case SSL3_AD_HANDSHAKE_FAILURE:
267 case SSL3_AD_NO_CERTIFICATE:
269 case SSL3_AD_BAD_CERTIFICATE:
271 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
273 case SSL3_AD_CERTIFICATE_REVOKED:
275 case SSL3_AD_CERTIFICATE_EXPIRED:
277 case SSL3_AD_CERTIFICATE_UNKNOWN:
279 case SSL3_AD_ILLEGAL_PARAMETER:
281 case TLS1_AD_DECRYPTION_FAILED:
283 case TLS1_AD_RECORD_OVERFLOW:
285 case TLS1_AD_UNKNOWN_CA:
287 case TLS1_AD_ACCESS_DENIED:
289 case TLS1_AD_DECODE_ERROR:
291 case TLS1_AD_DECRYPT_ERROR:
293 case TLS1_AD_EXPORT_RESTRICTION:
295 case TLS1_AD_PROTOCOL_VERSION:
297 case TLS1_AD_INSUFFICIENT_SECURITY:
299 case TLS1_AD_INTERNAL_ERROR:
301 case TLS1_AD_USER_CANCELLED:
303 case TLS1_AD_NO_RENEGOTIATION:
305 case TLS1_AD_UNSUPPORTED_EXTENSION:
307 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
309 case TLS1_AD_UNRECOGNIZED_NAME:
311 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
313 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
315 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
322 const char *SSL_alert_desc_string_long(int value)
324 switch (value & 0xff) {
325 case SSL3_AD_CLOSE_NOTIFY:
326 return "close notify";
327 case SSL3_AD_UNEXPECTED_MESSAGE:
328 return "unexpected_message";
329 case SSL3_AD_BAD_RECORD_MAC:
330 return "bad record mac";
331 case SSL3_AD_DECOMPRESSION_FAILURE:
332 return "decompression failure";
333 case SSL3_AD_HANDSHAKE_FAILURE:
334 return "handshake failure";
335 case SSL3_AD_NO_CERTIFICATE:
336 return "no certificate";
337 case SSL3_AD_BAD_CERTIFICATE:
338 return "bad certificate";
339 case SSL3_AD_UNSUPPORTED_CERTIFICATE:
340 return "unsupported certificate";
341 case SSL3_AD_CERTIFICATE_REVOKED:
342 return "certificate revoked";
343 case SSL3_AD_CERTIFICATE_EXPIRED:
344 return "certificate expired";
345 case SSL3_AD_CERTIFICATE_UNKNOWN:
346 return "certificate unknown";
347 case SSL3_AD_ILLEGAL_PARAMETER:
348 return "illegal parameter";
349 case TLS1_AD_DECRYPTION_FAILED:
350 return "decryption failed";
351 case TLS1_AD_RECORD_OVERFLOW:
352 return "record overflow";
353 case TLS1_AD_UNKNOWN_CA:
355 case TLS1_AD_ACCESS_DENIED:
356 return "access denied";
357 case TLS1_AD_DECODE_ERROR:
358 return "decode error";
359 case TLS1_AD_DECRYPT_ERROR:
360 return "decrypt error";
361 case TLS1_AD_EXPORT_RESTRICTION:
362 return "export restriction";
363 case TLS1_AD_PROTOCOL_VERSION:
364 return "protocol version";
365 case TLS1_AD_INSUFFICIENT_SECURITY:
366 return "insufficient security";
367 case TLS1_AD_INTERNAL_ERROR:
368 return "internal error";
369 case TLS1_AD_USER_CANCELLED:
370 return "user canceled";
371 case TLS1_AD_NO_RENEGOTIATION:
372 return "no renegotiation";
373 case TLS1_AD_UNSUPPORTED_EXTENSION:
374 return "unsupported extension";
375 case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
376 return "certificate unobtainable";
377 case TLS1_AD_UNRECOGNIZED_NAME:
378 return "unrecognized name";
379 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
380 return "bad certificate status response";
381 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
382 return "bad certificate hash value";
383 case TLS1_AD_UNKNOWN_PSK_IDENTITY:
384 return "unknown PSK identity";