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