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