Line data Source code
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 0 : const char *SSL_state_string_long(const SSL *s)
89 : {
90 : const char *str;
91 :
92 0 : 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 0 : break;
99 : case SSL_ST_CONNECT:
100 : str = "before connect initialization";
101 0 : break;
102 : case SSL_ST_OK:
103 : str = "SSL negotiation finished successfully";
104 0 : break;
105 : case SSL_ST_RENEGOTIATE:
106 : str = "SSL renegotiate ciphers";
107 0 : break;
108 : case SSL_ST_BEFORE | SSL_ST_CONNECT:
109 : str = "before/connect initialization";
110 0 : break;
111 : case SSL_ST_OK | SSL_ST_CONNECT:
112 : str = "ok/connect SSL initialization";
113 0 : break;
114 : case SSL_ST_BEFORE | SSL_ST_ACCEPT:
115 : str = "before/accept initialization";
116 0 : break;
117 : case SSL_ST_OK | SSL_ST_ACCEPT:
118 : str = "ok/accept SSL initialization";
119 0 : break;
120 : case SSL_ST_ERR:
121 : str = "error";
122 0 : break;
123 : #ifndef OPENSSL_NO_SSL2
124 : case SSL2_ST_CLIENT_START_ENCRYPTION:
125 : str = "SSLv2 client start encryption";
126 0 : break;
127 : case SSL2_ST_SERVER_START_ENCRYPTION:
128 : str = "SSLv2 server start encryption";
129 0 : break;
130 : case SSL2_ST_SEND_CLIENT_HELLO_A:
131 : str = "SSLv2 write client hello A";
132 0 : break;
133 : case SSL2_ST_SEND_CLIENT_HELLO_B:
134 : str = "SSLv2 write client hello B";
135 0 : break;
136 : case SSL2_ST_GET_SERVER_HELLO_A:
137 : str = "SSLv2 read server hello A";
138 0 : break;
139 : case SSL2_ST_GET_SERVER_HELLO_B:
140 : str = "SSLv2 read server hello B";
141 0 : break;
142 : case SSL2_ST_SEND_CLIENT_MASTER_KEY_A:
143 : str = "SSLv2 write client master key A";
144 0 : break;
145 : case SSL2_ST_SEND_CLIENT_MASTER_KEY_B:
146 : str = "SSLv2 write client master key B";
147 0 : break;
148 : case SSL2_ST_SEND_CLIENT_FINISHED_A:
149 : str = "SSLv2 write client finished A";
150 0 : break;
151 : case SSL2_ST_SEND_CLIENT_FINISHED_B:
152 : str = "SSLv2 write client finished B";
153 0 : break;
154 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_A:
155 : str = "SSLv2 write client certificate A";
156 0 : break;
157 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_B:
158 : str = "SSLv2 write client certificate B";
159 0 : break;
160 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_C:
161 : str = "SSLv2 write client certificate C";
162 0 : break;
163 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_D:
164 : str = "SSLv2 write client certificate D";
165 0 : break;
166 : case SSL2_ST_GET_SERVER_VERIFY_A:
167 : str = "SSLv2 read server verify A";
168 0 : break;
169 : case SSL2_ST_GET_SERVER_VERIFY_B:
170 : str = "SSLv2 read server verify B";
171 0 : break;
172 : case SSL2_ST_GET_SERVER_FINISHED_A:
173 : str = "SSLv2 read server finished A";
174 0 : break;
175 : case SSL2_ST_GET_SERVER_FINISHED_B:
176 : str = "SSLv2 read server finished B";
177 0 : break;
178 : case SSL2_ST_GET_CLIENT_HELLO_A:
179 : str = "SSLv2 read client hello A";
180 0 : break;
181 : case SSL2_ST_GET_CLIENT_HELLO_B:
182 : str = "SSLv2 read client hello B";
183 0 : break;
184 : case SSL2_ST_GET_CLIENT_HELLO_C:
185 : str = "SSLv2 read client hello C";
186 0 : break;
187 : case SSL2_ST_SEND_SERVER_HELLO_A:
188 : str = "SSLv2 write server hello A";
189 0 : break;
190 : case SSL2_ST_SEND_SERVER_HELLO_B:
191 : str = "SSLv2 write server hello B";
192 0 : break;
193 : case SSL2_ST_GET_CLIENT_MASTER_KEY_A:
194 : str = "SSLv2 read client master key A";
195 0 : break;
196 : case SSL2_ST_GET_CLIENT_MASTER_KEY_B:
197 : str = "SSLv2 read client master key B";
198 0 : break;
199 : case SSL2_ST_SEND_SERVER_VERIFY_A:
200 : str = "SSLv2 write server verify A";
201 0 : break;
202 : case SSL2_ST_SEND_SERVER_VERIFY_B:
203 : str = "SSLv2 write server verify B";
204 0 : break;
205 : case SSL2_ST_SEND_SERVER_VERIFY_C:
206 : str = "SSLv2 write server verify C";
207 0 : break;
208 : case SSL2_ST_GET_CLIENT_FINISHED_A:
209 : str = "SSLv2 read client finished A";
210 0 : break;
211 : case SSL2_ST_GET_CLIENT_FINISHED_B:
212 : str = "SSLv2 read client finished B";
213 0 : break;
214 : case SSL2_ST_SEND_SERVER_FINISHED_A:
215 : str = "SSLv2 write server finished A";
216 0 : break;
217 : case SSL2_ST_SEND_SERVER_FINISHED_B:
218 : str = "SSLv2 write server finished B";
219 0 : break;
220 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_A:
221 : str = "SSLv2 write request certificate A";
222 0 : break;
223 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_B:
224 : str = "SSLv2 write request certificate B";
225 0 : break;
226 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_C:
227 : str = "SSLv2 write request certificate C";
228 0 : break;
229 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_D:
230 : str = "SSLv2 write request certificate D";
231 0 : break;
232 : case SSL2_ST_X509_GET_SERVER_CERTIFICATE:
233 : str = "SSLv2 X509 read server certificate";
234 0 : break;
235 : case SSL2_ST_X509_GET_CLIENT_CERTIFICATE:
236 : str = "SSLv2 X509 read client certificate";
237 0 : break;
238 : #endif
239 :
240 : #ifndef OPENSSL_NO_SSL3
241 : /* SSLv3 additions */
242 : case SSL3_ST_CW_CLNT_HELLO_A:
243 : str = "SSLv3 write client hello A";
244 0 : break;
245 : case SSL3_ST_CW_CLNT_HELLO_B:
246 : str = "SSLv3 write client hello B";
247 0 : break;
248 : case SSL3_ST_CR_SRVR_HELLO_A:
249 : str = "SSLv3 read server hello A";
250 0 : break;
251 : case SSL3_ST_CR_SRVR_HELLO_B:
252 : str = "SSLv3 read server hello B";
253 0 : break;
254 : case SSL3_ST_CR_CERT_A:
255 : str = "SSLv3 read server certificate A";
256 0 : break;
257 : case SSL3_ST_CR_CERT_B:
258 : str = "SSLv3 read server certificate B";
259 0 : break;
260 : case SSL3_ST_CR_KEY_EXCH_A:
261 : str = "SSLv3 read server key exchange A";
262 0 : break;
263 : case SSL3_ST_CR_KEY_EXCH_B:
264 : str = "SSLv3 read server key exchange B";
265 0 : break;
266 : case SSL3_ST_CR_CERT_REQ_A:
267 : str = "SSLv3 read server certificate request A";
268 0 : break;
269 : case SSL3_ST_CR_CERT_REQ_B:
270 : str = "SSLv3 read server certificate request B";
271 0 : break;
272 : case SSL3_ST_CR_SESSION_TICKET_A:
273 : str = "SSLv3 read server session ticket A";
274 0 : break;
275 : case SSL3_ST_CR_SESSION_TICKET_B:
276 : str = "SSLv3 read server session ticket B";
277 0 : break;
278 : case SSL3_ST_CR_SRVR_DONE_A:
279 : str = "SSLv3 read server done A";
280 0 : break;
281 : case SSL3_ST_CR_SRVR_DONE_B:
282 : str = "SSLv3 read server done B";
283 0 : break;
284 : case SSL3_ST_CW_CERT_A:
285 : str = "SSLv3 write client certificate A";
286 0 : break;
287 : case SSL3_ST_CW_CERT_B:
288 : str = "SSLv3 write client certificate B";
289 0 : break;
290 : case SSL3_ST_CW_CERT_C:
291 : str = "SSLv3 write client certificate C";
292 0 : break;
293 : case SSL3_ST_CW_CERT_D:
294 : str = "SSLv3 write client certificate D";
295 0 : break;
296 : case SSL3_ST_CW_KEY_EXCH_A:
297 : str = "SSLv3 write client key exchange A";
298 0 : break;
299 : case SSL3_ST_CW_KEY_EXCH_B:
300 : str = "SSLv3 write client key exchange B";
301 0 : break;
302 : case SSL3_ST_CW_CERT_VRFY_A:
303 : str = "SSLv3 write certificate verify A";
304 0 : break;
305 : case SSL3_ST_CW_CERT_VRFY_B:
306 : str = "SSLv3 write certificate verify B";
307 0 : break;
308 :
309 : case SSL3_ST_CW_CHANGE_A:
310 : case SSL3_ST_SW_CHANGE_A:
311 : str = "SSLv3 write change cipher spec A";
312 0 : break;
313 : case SSL3_ST_CW_CHANGE_B:
314 : case SSL3_ST_SW_CHANGE_B:
315 : str = "SSLv3 write change cipher spec B";
316 0 : break;
317 : case SSL3_ST_CW_FINISHED_A:
318 : case SSL3_ST_SW_FINISHED_A:
319 : str = "SSLv3 write finished A";
320 0 : break;
321 : case SSL3_ST_CW_FINISHED_B:
322 : case SSL3_ST_SW_FINISHED_B:
323 : str = "SSLv3 write finished B";
324 0 : break;
325 : case SSL3_ST_CR_CHANGE_A:
326 : case SSL3_ST_SR_CHANGE_A:
327 : str = "SSLv3 read change cipher spec A";
328 0 : break;
329 : case SSL3_ST_CR_CHANGE_B:
330 : case SSL3_ST_SR_CHANGE_B:
331 : str = "SSLv3 read change cipher spec B";
332 0 : break;
333 : case SSL3_ST_CR_FINISHED_A:
334 : case SSL3_ST_SR_FINISHED_A:
335 : str = "SSLv3 read finished A";
336 0 : break;
337 : case SSL3_ST_CR_FINISHED_B:
338 : case SSL3_ST_SR_FINISHED_B:
339 : str = "SSLv3 read finished B";
340 0 : break;
341 :
342 : case SSL3_ST_CW_FLUSH:
343 : case SSL3_ST_SW_FLUSH:
344 : str = "SSLv3 flush data";
345 0 : break;
346 :
347 : case SSL3_ST_SR_CLNT_HELLO_A:
348 : str = "SSLv3 read client hello A";
349 0 : break;
350 : case SSL3_ST_SR_CLNT_HELLO_B:
351 : str = "SSLv3 read client hello B";
352 0 : break;
353 : case SSL3_ST_SR_CLNT_HELLO_C:
354 : str = "SSLv3 read client hello C";
355 0 : break;
356 : case SSL3_ST_SW_HELLO_REQ_A:
357 : str = "SSLv3 write hello request A";
358 0 : break;
359 : case SSL3_ST_SW_HELLO_REQ_B:
360 : str = "SSLv3 write hello request B";
361 0 : break;
362 : case SSL3_ST_SW_HELLO_REQ_C:
363 : str = "SSLv3 write hello request C";
364 0 : break;
365 : case SSL3_ST_SW_SRVR_HELLO_A:
366 : str = "SSLv3 write server hello A";
367 0 : break;
368 : case SSL3_ST_SW_SRVR_HELLO_B:
369 : str = "SSLv3 write server hello B";
370 0 : break;
371 : case SSL3_ST_SW_CERT_A:
372 : str = "SSLv3 write certificate A";
373 0 : break;
374 : case SSL3_ST_SW_CERT_B:
375 : str = "SSLv3 write certificate B";
376 0 : break;
377 : case SSL3_ST_SW_KEY_EXCH_A:
378 : str = "SSLv3 write key exchange A";
379 0 : break;
380 : case SSL3_ST_SW_KEY_EXCH_B:
381 : str = "SSLv3 write key exchange B";
382 0 : break;
383 : case SSL3_ST_SW_CERT_REQ_A:
384 : str = "SSLv3 write certificate request A";
385 0 : break;
386 : case SSL3_ST_SW_CERT_REQ_B:
387 : str = "SSLv3 write certificate request B";
388 0 : break;
389 : case SSL3_ST_SW_SESSION_TICKET_A:
390 : str = "SSLv3 write session ticket A";
391 0 : break;
392 : case SSL3_ST_SW_SESSION_TICKET_B:
393 : str = "SSLv3 write session ticket B";
394 0 : break;
395 : case SSL3_ST_SW_SRVR_DONE_A:
396 : str = "SSLv3 write server done A";
397 0 : break;
398 : case SSL3_ST_SW_SRVR_DONE_B:
399 : str = "SSLv3 write server done B";
400 0 : break;
401 : case SSL3_ST_SR_CERT_A:
402 : str = "SSLv3 read client certificate A";
403 0 : break;
404 : case SSL3_ST_SR_CERT_B:
405 : str = "SSLv3 read client certificate B";
406 0 : break;
407 : case SSL3_ST_SR_KEY_EXCH_A:
408 : str = "SSLv3 read client key exchange A";
409 0 : break;
410 : case SSL3_ST_SR_KEY_EXCH_B:
411 : str = "SSLv3 read client key exchange B";
412 0 : break;
413 : case SSL3_ST_SR_CERT_VRFY_A:
414 : str = "SSLv3 read certificate verify A";
415 0 : break;
416 : case SSL3_ST_SR_CERT_VRFY_B:
417 : str = "SSLv3 read certificate verify B";
418 0 : break;
419 : #endif
420 :
421 : /* SSLv2/v3 compatibility states */
422 : /* client */
423 : case SSL23_ST_CW_CLNT_HELLO_A:
424 : str = "SSLv2/v3 write client hello A";
425 0 : break;
426 : case SSL23_ST_CW_CLNT_HELLO_B:
427 : str = "SSLv2/v3 write client hello B";
428 0 : break;
429 : case SSL23_ST_CR_SRVR_HELLO_A:
430 : str = "SSLv2/v3 read server hello A";
431 0 : break;
432 : case SSL23_ST_CR_SRVR_HELLO_B:
433 : str = "SSLv2/v3 read server hello B";
434 0 : break;
435 : /* server */
436 : case SSL23_ST_SR_CLNT_HELLO_A:
437 : str = "SSLv2/v3 read client hello A";
438 0 : break;
439 : case SSL23_ST_SR_CLNT_HELLO_B:
440 : str = "SSLv2/v3 read client hello B";
441 0 : break;
442 :
443 : /* DTLS */
444 : case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
445 : str = "DTLS1 read hello verify request A";
446 0 : break;
447 : case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
448 : str = "DTLS1 read hello verify request B";
449 0 : break;
450 : case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
451 : str = "DTLS1 write hello verify request A";
452 0 : break;
453 : case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
454 : str = "DTLS1 write hello verify request B";
455 0 : break;
456 :
457 : default:
458 : str = "unknown state";
459 0 : break;
460 : }
461 0 : return (str);
462 : }
463 :
464 0 : const char *SSL_rstate_string_long(const SSL *s)
465 : {
466 : const char *str;
467 :
468 0 : switch (s->rstate) {
469 : case SSL_ST_READ_HEADER:
470 : str = "read header";
471 : break;
472 : case SSL_ST_READ_BODY:
473 : str = "read body";
474 0 : break;
475 : case SSL_ST_READ_DONE:
476 : str = "read done";
477 0 : break;
478 : default:
479 : str = "unknown";
480 0 : break;
481 : }
482 0 : return (str);
483 : }
484 :
485 0 : const char *SSL_state_string(const SSL *s)
486 : {
487 : const char *str;
488 :
489 0 : switch (s->state) {
490 : case SSL_ST_BEFORE:
491 : str = "PINIT ";
492 : break;
493 : case SSL_ST_ACCEPT:
494 : str = "AINIT ";
495 0 : break;
496 : case SSL_ST_CONNECT:
497 : str = "CINIT ";
498 0 : break;
499 : case SSL_ST_OK:
500 : str = "SSLOK ";
501 0 : break;
502 : case SSL_ST_ERR:
503 : str = "SSLERR";
504 0 : break;
505 : #ifndef OPENSSL_NO_SSL2
506 : case SSL2_ST_CLIENT_START_ENCRYPTION:
507 : str = "2CSENC";
508 0 : break;
509 : case SSL2_ST_SERVER_START_ENCRYPTION:
510 : str = "2SSENC";
511 0 : break;
512 : case SSL2_ST_SEND_CLIENT_HELLO_A:
513 : str = "2SCH_A";
514 0 : break;
515 : case SSL2_ST_SEND_CLIENT_HELLO_B:
516 : str = "2SCH_B";
517 0 : break;
518 : case SSL2_ST_GET_SERVER_HELLO_A:
519 : str = "2GSH_A";
520 0 : break;
521 : case SSL2_ST_GET_SERVER_HELLO_B:
522 : str = "2GSH_B";
523 0 : break;
524 : case SSL2_ST_SEND_CLIENT_MASTER_KEY_A:
525 : str = "2SCMKA";
526 0 : break;
527 : case SSL2_ST_SEND_CLIENT_MASTER_KEY_B:
528 : str = "2SCMKB";
529 0 : break;
530 : case SSL2_ST_SEND_CLIENT_FINISHED_A:
531 : str = "2SCF_A";
532 0 : break;
533 : case SSL2_ST_SEND_CLIENT_FINISHED_B:
534 : str = "2SCF_B";
535 0 : break;
536 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_A:
537 : str = "2SCC_A";
538 0 : break;
539 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_B:
540 : str = "2SCC_B";
541 0 : break;
542 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_C:
543 : str = "2SCC_C";
544 0 : break;
545 : case SSL2_ST_SEND_CLIENT_CERTIFICATE_D:
546 : str = "2SCC_D";
547 0 : break;
548 : case SSL2_ST_GET_SERVER_VERIFY_A:
549 : str = "2GSV_A";
550 0 : break;
551 : case SSL2_ST_GET_SERVER_VERIFY_B:
552 : str = "2GSV_B";
553 0 : break;
554 : case SSL2_ST_GET_SERVER_FINISHED_A:
555 : str = "2GSF_A";
556 0 : break;
557 : case SSL2_ST_GET_SERVER_FINISHED_B:
558 : str = "2GSF_B";
559 0 : break;
560 : case SSL2_ST_GET_CLIENT_HELLO_A:
561 : str = "2GCH_A";
562 0 : break;
563 : case SSL2_ST_GET_CLIENT_HELLO_B:
564 : str = "2GCH_B";
565 0 : break;
566 : case SSL2_ST_GET_CLIENT_HELLO_C:
567 : str = "2GCH_C";
568 0 : break;
569 : case SSL2_ST_SEND_SERVER_HELLO_A:
570 : str = "2SSH_A";
571 0 : break;
572 : case SSL2_ST_SEND_SERVER_HELLO_B:
573 : str = "2SSH_B";
574 0 : break;
575 : case SSL2_ST_GET_CLIENT_MASTER_KEY_A:
576 : str = "2GCMKA";
577 0 : break;
578 : case SSL2_ST_GET_CLIENT_MASTER_KEY_B:
579 : str = "2GCMKA";
580 0 : break;
581 : case SSL2_ST_SEND_SERVER_VERIFY_A:
582 : str = "2SSV_A";
583 0 : break;
584 : case SSL2_ST_SEND_SERVER_VERIFY_B:
585 : str = "2SSV_B";
586 0 : break;
587 : case SSL2_ST_SEND_SERVER_VERIFY_C:
588 : str = "2SSV_C";
589 0 : break;
590 : case SSL2_ST_GET_CLIENT_FINISHED_A:
591 : str = "2GCF_A";
592 0 : break;
593 : case SSL2_ST_GET_CLIENT_FINISHED_B:
594 : str = "2GCF_B";
595 0 : break;
596 : case SSL2_ST_SEND_SERVER_FINISHED_A:
597 : str = "2SSF_A";
598 0 : break;
599 : case SSL2_ST_SEND_SERVER_FINISHED_B:
600 : str = "2SSF_B";
601 0 : break;
602 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_A:
603 : str = "2SRC_A";
604 0 : break;
605 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_B:
606 : str = "2SRC_B";
607 0 : break;
608 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_C:
609 : str = "2SRC_C";
610 0 : break;
611 : case SSL2_ST_SEND_REQUEST_CERTIFICATE_D:
612 : str = "2SRC_D";
613 0 : break;
614 : case SSL2_ST_X509_GET_SERVER_CERTIFICATE:
615 : str = "2X9GSC";
616 0 : break;
617 : case SSL2_ST_X509_GET_CLIENT_CERTIFICATE:
618 : str = "2X9GCC";
619 0 : break;
620 : #endif
621 :
622 : #ifndef OPENSSL_NO_SSL3
623 : /* SSLv3 additions */
624 : case SSL3_ST_SW_FLUSH:
625 : case SSL3_ST_CW_FLUSH:
626 : str = "3FLUSH";
627 0 : break;
628 : case SSL3_ST_CW_CLNT_HELLO_A:
629 : str = "3WCH_A";
630 0 : break;
631 : case SSL3_ST_CW_CLNT_HELLO_B:
632 : str = "3WCH_B";
633 0 : break;
634 : case SSL3_ST_CR_SRVR_HELLO_A:
635 : str = "3RSH_A";
636 0 : break;
637 : case SSL3_ST_CR_SRVR_HELLO_B:
638 : str = "3RSH_B";
639 0 : break;
640 : case SSL3_ST_CR_CERT_A:
641 : str = "3RSC_A";
642 0 : break;
643 : case SSL3_ST_CR_CERT_B:
644 : str = "3RSC_B";
645 0 : break;
646 : case SSL3_ST_CR_KEY_EXCH_A:
647 : str = "3RSKEA";
648 0 : break;
649 : case SSL3_ST_CR_KEY_EXCH_B:
650 : str = "3RSKEB";
651 0 : break;
652 : case SSL3_ST_CR_CERT_REQ_A:
653 : str = "3RCR_A";
654 0 : break;
655 : case SSL3_ST_CR_CERT_REQ_B:
656 : str = "3RCR_B";
657 0 : break;
658 : case SSL3_ST_CR_SRVR_DONE_A:
659 : str = "3RSD_A";
660 0 : break;
661 : case SSL3_ST_CR_SRVR_DONE_B:
662 : str = "3RSD_B";
663 0 : break;
664 : case SSL3_ST_CW_CERT_A:
665 : str = "3WCC_A";
666 0 : break;
667 : case SSL3_ST_CW_CERT_B:
668 : str = "3WCC_B";
669 0 : break;
670 : case SSL3_ST_CW_CERT_C:
671 : str = "3WCC_C";
672 0 : break;
673 : case SSL3_ST_CW_CERT_D:
674 : str = "3WCC_D";
675 0 : break;
676 : case SSL3_ST_CW_KEY_EXCH_A:
677 : str = "3WCKEA";
678 0 : break;
679 : case SSL3_ST_CW_KEY_EXCH_B:
680 : str = "3WCKEB";
681 0 : break;
682 : case SSL3_ST_CW_CERT_VRFY_A:
683 : str = "3WCV_A";
684 0 : break;
685 : case SSL3_ST_CW_CERT_VRFY_B:
686 : str = "3WCV_B";
687 0 : break;
688 :
689 : case SSL3_ST_SW_CHANGE_A:
690 : case SSL3_ST_CW_CHANGE_A:
691 : str = "3WCCSA";
692 0 : break;
693 : case SSL3_ST_SW_CHANGE_B:
694 : case SSL3_ST_CW_CHANGE_B:
695 : str = "3WCCSB";
696 0 : break;
697 : case SSL3_ST_SW_FINISHED_A:
698 : case SSL3_ST_CW_FINISHED_A:
699 : str = "3WFINA";
700 0 : break;
701 : case SSL3_ST_SW_FINISHED_B:
702 : case SSL3_ST_CW_FINISHED_B:
703 : str = "3WFINB";
704 0 : break;
705 : case SSL3_ST_SR_CHANGE_A:
706 : case SSL3_ST_CR_CHANGE_A:
707 : str = "3RCCSA";
708 0 : break;
709 : case SSL3_ST_SR_CHANGE_B:
710 : case SSL3_ST_CR_CHANGE_B:
711 : str = "3RCCSB";
712 0 : break;
713 : case SSL3_ST_SR_FINISHED_A:
714 : case SSL3_ST_CR_FINISHED_A:
715 : str = "3RFINA";
716 0 : break;
717 : case SSL3_ST_SR_FINISHED_B:
718 : case SSL3_ST_CR_FINISHED_B:
719 : str = "3RFINB";
720 0 : break;
721 :
722 : case SSL3_ST_SW_HELLO_REQ_A:
723 : str = "3WHR_A";
724 0 : break;
725 : case SSL3_ST_SW_HELLO_REQ_B:
726 : str = "3WHR_B";
727 0 : break;
728 : case SSL3_ST_SW_HELLO_REQ_C:
729 : str = "3WHR_C";
730 0 : break;
731 : case SSL3_ST_SR_CLNT_HELLO_A:
732 : str = "3RCH_A";
733 0 : break;
734 : case SSL3_ST_SR_CLNT_HELLO_B:
735 : str = "3RCH_B";
736 0 : break;
737 : case SSL3_ST_SR_CLNT_HELLO_C:
738 : str = "3RCH_C";
739 0 : break;
740 : case SSL3_ST_SW_SRVR_HELLO_A:
741 : str = "3WSH_A";
742 0 : break;
743 : case SSL3_ST_SW_SRVR_HELLO_B:
744 : str = "3WSH_B";
745 0 : break;
746 : case SSL3_ST_SW_CERT_A:
747 : str = "3WSC_A";
748 0 : break;
749 : case SSL3_ST_SW_CERT_B:
750 : str = "3WSC_B";
751 0 : break;
752 : case SSL3_ST_SW_KEY_EXCH_A:
753 : str = "3WSKEA";
754 0 : break;
755 : case SSL3_ST_SW_KEY_EXCH_B:
756 : str = "3WSKEB";
757 0 : break;
758 : case SSL3_ST_SW_CERT_REQ_A:
759 : str = "3WCR_A";
760 0 : break;
761 : case SSL3_ST_SW_CERT_REQ_B:
762 : str = "3WCR_B";
763 0 : break;
764 : case SSL3_ST_SW_SRVR_DONE_A:
765 : str = "3WSD_A";
766 0 : break;
767 : case SSL3_ST_SW_SRVR_DONE_B:
768 : str = "3WSD_B";
769 0 : break;
770 : case SSL3_ST_SR_CERT_A:
771 : str = "3RCC_A";
772 0 : break;
773 : case SSL3_ST_SR_CERT_B:
774 : str = "3RCC_B";
775 0 : break;
776 : case SSL3_ST_SR_KEY_EXCH_A:
777 : str = "3RCKEA";
778 0 : break;
779 : case SSL3_ST_SR_KEY_EXCH_B:
780 : str = "3RCKEB";
781 0 : break;
782 : case SSL3_ST_SR_CERT_VRFY_A:
783 : str = "3RCV_A";
784 0 : break;
785 : case SSL3_ST_SR_CERT_VRFY_B:
786 : str = "3RCV_B";
787 0 : break;
788 : #endif
789 :
790 : /* SSLv2/v3 compatibility states */
791 : /* client */
792 : case SSL23_ST_CW_CLNT_HELLO_A:
793 : str = "23WCHA";
794 0 : break;
795 : case SSL23_ST_CW_CLNT_HELLO_B:
796 : str = "23WCHB";
797 0 : break;
798 : case SSL23_ST_CR_SRVR_HELLO_A:
799 : str = "23RSHA";
800 0 : break;
801 : case SSL23_ST_CR_SRVR_HELLO_B:
802 : str = "23RSHA";
803 0 : break;
804 : /* server */
805 : case SSL23_ST_SR_CLNT_HELLO_A:
806 : str = "23RCHA";
807 0 : break;
808 : case SSL23_ST_SR_CLNT_HELLO_B:
809 : str = "23RCHB";
810 0 : break;
811 :
812 : /* DTLS */
813 : case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A:
814 : str = "DRCHVA";
815 0 : break;
816 : case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B:
817 : str = "DRCHVB";
818 0 : break;
819 : case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A:
820 : str = "DWCHVA";
821 0 : break;
822 : case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B:
823 : str = "DWCHVB";
824 0 : break;
825 :
826 : default:
827 : str = "UNKWN ";
828 0 : break;
829 : }
830 0 : return (str);
831 : }
832 :
833 0 : const char *SSL_alert_type_string_long(int value)
834 : {
835 0 : value >>= 8;
836 0 : if (value == SSL3_AL_WARNING)
837 : return ("warning");
838 0 : else if (value == SSL3_AL_FATAL)
839 : return ("fatal");
840 : else
841 0 : return ("unknown");
842 : }
843 :
844 0 : const char *SSL_alert_type_string(int value)
845 : {
846 0 : value >>= 8;
847 0 : if (value == SSL3_AL_WARNING)
848 : return ("W");
849 0 : else if (value == SSL3_AL_FATAL)
850 : return ("F");
851 : else
852 0 : return ("U");
853 : }
854 :
855 0 : const char *SSL_alert_desc_string(int value)
856 : {
857 : const char *str;
858 :
859 0 : switch (value & 0xff) {
860 : case SSL3_AD_CLOSE_NOTIFY:
861 : str = "CN";
862 : break;
863 : case SSL3_AD_UNEXPECTED_MESSAGE:
864 : str = "UM";
865 0 : break;
866 : case SSL3_AD_BAD_RECORD_MAC:
867 : str = "BM";
868 0 : break;
869 : case SSL3_AD_DECOMPRESSION_FAILURE:
870 : str = "DF";
871 0 : break;
872 : case SSL3_AD_HANDSHAKE_FAILURE:
873 : str = "HF";
874 0 : break;
875 : case SSL3_AD_NO_CERTIFICATE:
876 : str = "NC";
877 0 : break;
878 : case SSL3_AD_BAD_CERTIFICATE:
879 : str = "BC";
880 0 : break;
881 : case SSL3_AD_UNSUPPORTED_CERTIFICATE:
882 : str = "UC";
883 0 : break;
884 : case SSL3_AD_CERTIFICATE_REVOKED:
885 : str = "CR";
886 0 : break;
887 : case SSL3_AD_CERTIFICATE_EXPIRED:
888 : str = "CE";
889 0 : break;
890 : case SSL3_AD_CERTIFICATE_UNKNOWN:
891 : str = "CU";
892 0 : break;
893 : case SSL3_AD_ILLEGAL_PARAMETER:
894 : str = "IP";
895 0 : break;
896 : case TLS1_AD_DECRYPTION_FAILED:
897 : str = "DC";
898 0 : break;
899 : case TLS1_AD_RECORD_OVERFLOW:
900 : str = "RO";
901 0 : break;
902 : case TLS1_AD_UNKNOWN_CA:
903 : str = "CA";
904 0 : break;
905 : case TLS1_AD_ACCESS_DENIED:
906 : str = "AD";
907 0 : break;
908 : case TLS1_AD_DECODE_ERROR:
909 : str = "DE";
910 0 : break;
911 : case TLS1_AD_DECRYPT_ERROR:
912 : str = "CY";
913 0 : break;
914 : case TLS1_AD_EXPORT_RESTRICTION:
915 : str = "ER";
916 0 : break;
917 : case TLS1_AD_PROTOCOL_VERSION:
918 : str = "PV";
919 0 : break;
920 : case TLS1_AD_INSUFFICIENT_SECURITY:
921 : str = "IS";
922 0 : break;
923 : case TLS1_AD_INTERNAL_ERROR:
924 : str = "IE";
925 0 : break;
926 : case TLS1_AD_USER_CANCELLED:
927 : str = "US";
928 0 : break;
929 : case TLS1_AD_NO_RENEGOTIATION:
930 : str = "NR";
931 0 : break;
932 : case TLS1_AD_UNSUPPORTED_EXTENSION:
933 : str = "UE";
934 0 : break;
935 : case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
936 : str = "CO";
937 0 : break;
938 : case TLS1_AD_UNRECOGNIZED_NAME:
939 : str = "UN";
940 0 : break;
941 : case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
942 : str = "BR";
943 0 : break;
944 : case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
945 : str = "BH";
946 0 : break;
947 : case TLS1_AD_UNKNOWN_PSK_IDENTITY:
948 : str = "UP";
949 0 : break;
950 : default:
951 : str = "UK";
952 0 : break;
953 : }
954 0 : return (str);
955 : }
956 :
957 0 : const char *SSL_alert_desc_string_long(int value)
958 : {
959 : const char *str;
960 :
961 0 : switch (value & 0xff) {
962 : case SSL3_AD_CLOSE_NOTIFY:
963 : str = "close notify";
964 : break;
965 : case SSL3_AD_UNEXPECTED_MESSAGE:
966 : str = "unexpected_message";
967 0 : break;
968 : case SSL3_AD_BAD_RECORD_MAC:
969 : str = "bad record mac";
970 0 : break;
971 : case SSL3_AD_DECOMPRESSION_FAILURE:
972 : str = "decompression failure";
973 0 : break;
974 : case SSL3_AD_HANDSHAKE_FAILURE:
975 : str = "handshake failure";
976 0 : break;
977 : case SSL3_AD_NO_CERTIFICATE:
978 : str = "no certificate";
979 0 : break;
980 : case SSL3_AD_BAD_CERTIFICATE:
981 : str = "bad certificate";
982 0 : break;
983 : case SSL3_AD_UNSUPPORTED_CERTIFICATE:
984 : str = "unsupported certificate";
985 0 : break;
986 : case SSL3_AD_CERTIFICATE_REVOKED:
987 : str = "certificate revoked";
988 0 : break;
989 : case SSL3_AD_CERTIFICATE_EXPIRED:
990 : str = "certificate expired";
991 0 : break;
992 : case SSL3_AD_CERTIFICATE_UNKNOWN:
993 : str = "certificate unknown";
994 0 : break;
995 : case SSL3_AD_ILLEGAL_PARAMETER:
996 : str = "illegal parameter";
997 0 : break;
998 : case TLS1_AD_DECRYPTION_FAILED:
999 : str = "decryption failed";
1000 0 : break;
1001 : case TLS1_AD_RECORD_OVERFLOW:
1002 : str = "record overflow";
1003 0 : break;
1004 : case TLS1_AD_UNKNOWN_CA:
1005 : str = "unknown CA";
1006 0 : break;
1007 : case TLS1_AD_ACCESS_DENIED:
1008 : str = "access denied";
1009 0 : break;
1010 : case TLS1_AD_DECODE_ERROR:
1011 : str = "decode error";
1012 0 : break;
1013 : case TLS1_AD_DECRYPT_ERROR:
1014 : str = "decrypt error";
1015 0 : break;
1016 : case TLS1_AD_EXPORT_RESTRICTION:
1017 : str = "export restriction";
1018 0 : break;
1019 : case TLS1_AD_PROTOCOL_VERSION:
1020 : str = "protocol version";
1021 0 : break;
1022 : case TLS1_AD_INSUFFICIENT_SECURITY:
1023 : str = "insufficient security";
1024 0 : break;
1025 : case TLS1_AD_INTERNAL_ERROR:
1026 : str = "internal error";
1027 0 : break;
1028 : case TLS1_AD_USER_CANCELLED:
1029 : str = "user canceled";
1030 0 : break;
1031 : case TLS1_AD_NO_RENEGOTIATION:
1032 : str = "no renegotiation";
1033 0 : break;
1034 : case TLS1_AD_UNSUPPORTED_EXTENSION:
1035 : str = "unsupported extension";
1036 0 : break;
1037 : case TLS1_AD_CERTIFICATE_UNOBTAINABLE:
1038 : str = "certificate unobtainable";
1039 0 : break;
1040 : case TLS1_AD_UNRECOGNIZED_NAME:
1041 : str = "unrecognized name";
1042 0 : break;
1043 : case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE:
1044 : str = "bad certificate status response";
1045 0 : break;
1046 : case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE:
1047 : str = "bad certificate hash value";
1048 0 : break;
1049 : case TLS1_AD_UNKNOWN_PSK_IDENTITY:
1050 : str = "unknown PSK identity";
1051 0 : break;
1052 : default:
1053 : str = "unknown";
1054 0 : break;
1055 : }
1056 0 : return (str);
1057 : }
1058 :
1059 0 : const char *SSL_rstate_string(const SSL *s)
1060 : {
1061 : const char *str;
1062 :
1063 0 : switch (s->rstate) {
1064 : case SSL_ST_READ_HEADER:
1065 : str = "RH";
1066 : break;
1067 : case SSL_ST_READ_BODY:
1068 : str = "RB";
1069 0 : break;
1070 : case SSL_ST_READ_DONE:
1071 : str = "RD";
1072 0 : break;
1073 : default:
1074 : str = "unknown";
1075 0 : break;
1076 : }
1077 0 : return (str);
1078 : }
|