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 88const char *SSL_state_string_long(const SSL *s) 89 { 90 const char *str; 91 92 switch (s->state) 93 { 94case SSL_ST_BEFORE: str="before SSL initialization"; break; 95case SSL_ST_ACCEPT: str="before accept initialization"; break; 96case SSL_ST_CONNECT: str="before connect initialization"; break; 97case SSL_ST_OK: str="SSL negotiation finished successfully"; break; 98case SSL_ST_RENEGOTIATE: str="SSL renegotiate ciphers"; break; 99case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break; 100case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break; 101case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break; 102case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break; 103#ifndef OPENSSL_NO_SSL2 104case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break; 105case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break; 106case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break; 107case SSL2_ST_SEND_CLIENT_HELLO_B: str="SSLv2 write client hello B"; break; 108case SSL2_ST_GET_SERVER_HELLO_A: str="SSLv2 read server hello A"; break; 109case SSL2_ST_GET_SERVER_HELLO_B: str="SSLv2 read server hello B"; break; 110case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="SSLv2 write client master key A"; break; 111case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="SSLv2 write client master key B"; break; 112case SSL2_ST_SEND_CLIENT_FINISHED_A: str="SSLv2 write client finished A"; break; 113case SSL2_ST_SEND_CLIENT_FINISHED_B: str="SSLv2 write client finished B"; break; 114case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="SSLv2 write client certificate A"; break; 115case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="SSLv2 write client certificate B"; break; 116case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="SSLv2 write client certificate C"; break; 117case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="SSLv2 write client certificate D"; break; 118case SSL2_ST_GET_SERVER_VERIFY_A: str="SSLv2 read server verify A"; break; 119case SSL2_ST_GET_SERVER_VERIFY_B: str="SSLv2 read server verify B"; break; 120case SSL2_ST_GET_SERVER_FINISHED_A: str="SSLv2 read server finished A"; break; 121case SSL2_ST_GET_SERVER_FINISHED_B: str="SSLv2 read server finished B"; break; 122case SSL2_ST_GET_CLIENT_HELLO_A: str="SSLv2 read client hello A"; break; 123case SSL2_ST_GET_CLIENT_HELLO_B: str="SSLv2 read client hello B"; break; 124case SSL2_ST_GET_CLIENT_HELLO_C: str="SSLv2 read client hello C"; break; 125case SSL2_ST_SEND_SERVER_HELLO_A: str="SSLv2 write server hello A"; break; 126case SSL2_ST_SEND_SERVER_HELLO_B: str="SSLv2 write server hello B"; break; 127case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="SSLv2 read client master key A"; break; 128case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="SSLv2 read client master key B"; break; 129case SSL2_ST_SEND_SERVER_VERIFY_A: str="SSLv2 write server verify A"; break; 130case SSL2_ST_SEND_SERVER_VERIFY_B: str="SSLv2 write server verify B"; break; 131case SSL2_ST_SEND_SERVER_VERIFY_C: str="SSLv2 write server verify C"; break; 132case SSL2_ST_GET_CLIENT_FINISHED_A: str="SSLv2 read client finished A"; break; 133case SSL2_ST_GET_CLIENT_FINISHED_B: str="SSLv2 read client finished B"; break; 134case SSL2_ST_SEND_SERVER_FINISHED_A: str="SSLv2 write server finished A"; break; 135case SSL2_ST_SEND_SERVER_FINISHED_B: str="SSLv2 write server finished B"; break; 136case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="SSLv2 write request certificate A"; break; 137case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="SSLv2 write request certificate B"; break; 138case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="SSLv2 write request certificate C"; break; 139case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="SSLv2 write request certificate D"; break; 140case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificate"; break; 141case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break; 142#endif 143 144#ifndef OPENSSL_NO_SSL3 145/* SSLv3 additions */ 146case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; 147case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; 148case SSL3_ST_CR_SRVR_HELLO_A: str="SSLv3 read server hello A"; break; 149case SSL3_ST_CR_SRVR_HELLO_B: str="SSLv3 read server hello B"; break; 150case SSL3_ST_CR_CERT_A: str="SSLv3 read server certificate A"; break; 151case SSL3_ST_CR_CERT_B: str="SSLv3 read server certificate B"; break; 152case SSL3_ST_CR_KEY_EXCH_A: str="SSLv3 read server key exchange A"; break; 153case SSL3_ST_CR_KEY_EXCH_B: str="SSLv3 read server key exchange B"; break; 154case SSL3_ST_CR_CERT_REQ_A: str="SSLv3 read server certificate request A"; break; 155case SSL3_ST_CR_CERT_REQ_B: str="SSLv3 read server certificate request B"; break; 156case SSL3_ST_CR_SESSION_TICKET_A: str="SSLv3 read server session ticket A";break; 157case SSL3_ST_CR_SESSION_TICKET_B: str="SSLv3 read server session ticket B";break; 158case SSL3_ST_CR_SRVR_DONE_A: str="SSLv3 read server done A"; break; 159case SSL3_ST_CR_SRVR_DONE_B: str="SSLv3 read server done B"; break; 160case SSL3_ST_CW_CERT_A: str="SSLv3 write client certificate A"; break; 161case SSL3_ST_CW_CERT_B: str="SSLv3 write client certificate B"; break; 162case SSL3_ST_CW_CERT_C: str="SSLv3 write client certificate C"; break; 163case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break; 164case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; 165case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; 166case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; 167case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break; 168 169case SSL3_ST_CW_CHANGE_A: 170case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; 171case SSL3_ST_CW_CHANGE_B: 172case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break; 173case SSL3_ST_CW_FINISHED_A: 174case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; 175case SSL3_ST_CW_FINISHED_B: 176case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break; 177case SSL3_ST_CR_CHANGE_A: 178case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; 179case SSL3_ST_CR_CHANGE_B: 180case SSL3_ST_SR_CHANGE_B: str="SSLv3 read change cipher spec B"; break; 181case SSL3_ST_CR_FINISHED_A: 182case SSL3_ST_SR_FINISHED_A: str="SSLv3 read finished A"; break; 183case SSL3_ST_CR_FINISHED_B: 184case SSL3_ST_SR_FINISHED_B: str="SSLv3 read finished B"; break; 185 186case SSL3_ST_CW_FLUSH: 187case SSL3_ST_SW_FLUSH: str="SSLv3 flush data"; break; 188 189case SSL3_ST_SR_CLNT_HELLO_A: str="SSLv3 read client hello A"; break; 190case SSL3_ST_SR_CLNT_HELLO_B: str="SSLv3 read client hello B"; break; 191case SSL3_ST_SR_CLNT_HELLO_C: str="SSLv3 read client hello C"; break; 192case SSL3_ST_SW_HELLO_REQ_A: str="SSLv3 write hello request A"; break; 193case SSL3_ST_SW_HELLO_REQ_B: str="SSLv3 write hello request B"; break; 194case SSL3_ST_SW_HELLO_REQ_C: str="SSLv3 write hello request C"; break; 195case SSL3_ST_SW_SRVR_HELLO_A: str="SSLv3 write server hello A"; break; 196case SSL3_ST_SW_SRVR_HELLO_B: str="SSLv3 write server hello B"; break; 197case SSL3_ST_SW_CERT_A: str="SSLv3 write certificate A"; break; 198case SSL3_ST_SW_CERT_B: str="SSLv3 write certificate B"; break; 199case SSL3_ST_SW_KEY_EXCH_A: str="SSLv3 write key exchange A"; break; 200case SSL3_ST_SW_KEY_EXCH_B: str="SSLv3 write key exchange B"; break; 201case SSL3_ST_SW_CERT_REQ_A: str="SSLv3 write certificate request A"; break; 202case SSL3_ST_SW_CERT_REQ_B: str="SSLv3 write certificate request B"; break; 203case SSL3_ST_SW_SESSION_TICKET_A: str="SSLv3 write session ticket A"; break; 204case SSL3_ST_SW_SESSION_TICKET_B: str="SSLv3 write session ticket B"; break; 205case SSL3_ST_SW_SRVR_DONE_A: str="SSLv3 write server done A"; break; 206case SSL3_ST_SW_SRVR_DONE_B: str="SSLv3 write server done B"; break; 207case SSL3_ST_SR_CERT_A: str="SSLv3 read client certificate A"; break; 208case SSL3_ST_SR_CERT_B: str="SSLv3 read client certificate B"; break; 209case SSL3_ST_SR_KEY_EXCH_A: str="SSLv3 read client key exchange A"; break; 210case SSL3_ST_SR_KEY_EXCH_B: str="SSLv3 read client key exchange B"; break; 211case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break; 212case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; 213#endif 214 215#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) 216/* SSLv2/v3 compatibility states */ 217/* client */ 218case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break; 219case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break; 220case SSL23_ST_CR_SRVR_HELLO_A: str="SSLv2/v3 read server hello A"; break; 221case SSL23_ST_CR_SRVR_HELLO_B: str="SSLv2/v3 read server hello B"; break; 222/* server */ 223case SSL23_ST_SR_CLNT_HELLO_A: str="SSLv2/v3 read client hello A"; break; 224case SSL23_ST_SR_CLNT_HELLO_B: str="SSLv2/v3 read client hello B"; break; 225#endif 226 227/* DTLS */ 228case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str="DTLS1 read hello verify request A"; break; 229case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str="DTLS1 read hello verify request B"; break; 230case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str="DTLS1 write hello verify request A"; break; 231case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str="DTLS1 write hello verify request B"; break; 232 233default: str="unknown state"; break; 234 } 235 return(str); 236 } 237 238const char *SSL_rstate_string_long(const SSL *s) 239 { 240 const char *str; 241 242 switch (s->rstate) 243 { 244 case SSL_ST_READ_HEADER: str="read header"; break; 245 case SSL_ST_READ_BODY: str="read body"; break; 246 case SSL_ST_READ_DONE: str="read done"; break; 247 default: str="unknown"; break; 248 } 249 return(str); 250 } 251 252const char *SSL_state_string(const SSL *s) 253 { 254 const char *str; 255 256 switch (s->state) 257 { 258case SSL_ST_BEFORE: str="PINIT "; break; 259case SSL_ST_ACCEPT: str="AINIT "; break; 260case SSL_ST_CONNECT: str="CINIT "; break; 261case SSL_ST_OK: str="SSLOK "; break; 262#ifndef OPENSSL_NO_SSL2 263case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break; 264case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break; 265case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break; 266case SSL2_ST_SEND_CLIENT_HELLO_B: str="2SCH_B"; break; 267case SSL2_ST_GET_SERVER_HELLO_A: str="2GSH_A"; break; 268case SSL2_ST_GET_SERVER_HELLO_B: str="2GSH_B"; break; 269case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="2SCMKA"; break; 270case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="2SCMKB"; break; 271case SSL2_ST_SEND_CLIENT_FINISHED_A: str="2SCF_A"; break; 272case SSL2_ST_SEND_CLIENT_FINISHED_B: str="2SCF_B"; break; 273case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="2SCC_A"; break; 274case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="2SCC_B"; break; 275case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="2SCC_C"; break; 276case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="2SCC_D"; break; 277case SSL2_ST_GET_SERVER_VERIFY_A: str="2GSV_A"; break; 278case SSL2_ST_GET_SERVER_VERIFY_B: str="2GSV_B"; break; 279case SSL2_ST_GET_SERVER_FINISHED_A: str="2GSF_A"; break; 280case SSL2_ST_GET_SERVER_FINISHED_B: str="2GSF_B"; break; 281case SSL2_ST_GET_CLIENT_HELLO_A: str="2GCH_A"; break; 282case SSL2_ST_GET_CLIENT_HELLO_B: str="2GCH_B"; break; 283case SSL2_ST_GET_CLIENT_HELLO_C: str="2GCH_C"; break; 284case SSL2_ST_SEND_SERVER_HELLO_A: str="2SSH_A"; break; 285case SSL2_ST_SEND_SERVER_HELLO_B: str="2SSH_B"; break; 286case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="2GCMKA"; break; 287case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="2GCMKA"; break; 288case SSL2_ST_SEND_SERVER_VERIFY_A: str="2SSV_A"; break; 289case SSL2_ST_SEND_SERVER_VERIFY_B: str="2SSV_B"; break; 290case SSL2_ST_SEND_SERVER_VERIFY_C: str="2SSV_C"; break; 291case SSL2_ST_GET_CLIENT_FINISHED_A: str="2GCF_A"; break; 292case SSL2_ST_GET_CLIENT_FINISHED_B: str="2GCF_B"; break; 293case SSL2_ST_SEND_SERVER_FINISHED_A: str="2SSF_A"; break; 294case SSL2_ST_SEND_SERVER_FINISHED_B: str="2SSF_B"; break; 295case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="2SRC_A"; break; 296case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="2SRC_B"; break; 297case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="2SRC_C"; break; 298case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="2SRC_D"; break; 299case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="2X9GSC"; break; 300case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break; 301#endif 302 303#ifndef OPENSSL_NO_SSL3 304/* SSLv3 additions */ 305case SSL3_ST_SW_FLUSH: 306case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; 307case SSL3_ST_CW_CLNT_HELLO_A: str="3WCH_A"; break; 308case SSL3_ST_CW_CLNT_HELLO_B: str="3WCH_B"; break; 309case SSL3_ST_CR_SRVR_HELLO_A: str="3RSH_A"; break; 310case SSL3_ST_CR_SRVR_HELLO_B: str="3RSH_B"; break; 311case SSL3_ST_CR_CERT_A: str="3RSC_A"; break; 312case SSL3_ST_CR_CERT_B: str="3RSC_B"; break; 313case SSL3_ST_CR_KEY_EXCH_A: str="3RSKEA"; break; 314case SSL3_ST_CR_KEY_EXCH_B: str="3RSKEB"; break; 315case SSL3_ST_CR_CERT_REQ_A: str="3RCR_A"; break; 316case SSL3_ST_CR_CERT_REQ_B: str="3RCR_B"; break; 317case SSL3_ST_CR_SRVR_DONE_A: str="3RSD_A"; break; 318case SSL3_ST_CR_SRVR_DONE_B: str="3RSD_B"; break; 319case SSL3_ST_CW_CERT_A: str="3WCC_A"; break; 320case SSL3_ST_CW_CERT_B: str="3WCC_B"; break; 321case SSL3_ST_CW_CERT_C: str="3WCC_C"; break; 322case SSL3_ST_CW_CERT_D: str="3WCC_D"; break; 323case SSL3_ST_CW_KEY_EXCH_A: str="3WCKEA"; break; 324case SSL3_ST_CW_KEY_EXCH_B: str="3WCKEB"; break; 325case SSL3_ST_CW_CERT_VRFY_A: str="3WCV_A"; break; 326case SSL3_ST_CW_CERT_VRFY_B: str="3WCV_B"; break; 327 328case SSL3_ST_SW_CHANGE_A: 329case SSL3_ST_CW_CHANGE_A: str="3WCCSA"; break; 330case SSL3_ST_SW_CHANGE_B: 331case SSL3_ST_CW_CHANGE_B: str="3WCCSB"; break; 332case SSL3_ST_SW_FINISHED_A: 333case SSL3_ST_CW_FINISHED_A: str="3WFINA"; break; 334case SSL3_ST_SW_FINISHED_B: 335case SSL3_ST_CW_FINISHED_B: str="3WFINB"; break; 336case SSL3_ST_SR_CHANGE_A: 337case SSL3_ST_CR_CHANGE_A: str="3RCCSA"; break; 338case SSL3_ST_SR_CHANGE_B: 339case SSL3_ST_CR_CHANGE_B: str="3RCCSB"; break; 340case SSL3_ST_SR_FINISHED_A: 341case SSL3_ST_CR_FINISHED_A: str="3RFINA"; break; 342case SSL3_ST_SR_FINISHED_B: 343case SSL3_ST_CR_FINISHED_B: str="3RFINB"; break; 344 345case SSL3_ST_SW_HELLO_REQ_A: str="3WHR_A"; break; 346case SSL3_ST_SW_HELLO_REQ_B: str="3WHR_B"; break; 347case SSL3_ST_SW_HELLO_REQ_C: str="3WHR_C"; break; 348case SSL3_ST_SR_CLNT_HELLO_A: str="3RCH_A"; break; 349case SSL3_ST_SR_CLNT_HELLO_B: str="3RCH_B"; break; 350case SSL3_ST_SR_CLNT_HELLO_C: str="3RCH_C"; break; 351case SSL3_ST_SW_SRVR_HELLO_A: str="3WSH_A"; break; 352case SSL3_ST_SW_SRVR_HELLO_B: str="3WSH_B"; break; 353case SSL3_ST_SW_CERT_A: str="3WSC_A"; break; 354case SSL3_ST_SW_CERT_B: str="3WSC_B"; break; 355case SSL3_ST_SW_KEY_EXCH_A: str="3WSKEA"; break; 356case SSL3_ST_SW_KEY_EXCH_B: str="3WSKEB"; break; 357case SSL3_ST_SW_CERT_REQ_A: str="3WCR_A"; break; 358case SSL3_ST_SW_CERT_REQ_B: str="3WCR_B"; break; 359case SSL3_ST_SW_SRVR_DONE_A: str="3WSD_A"; break; 360case SSL3_ST_SW_SRVR_DONE_B: str="3WSD_B"; break; 361case SSL3_ST_SR_CERT_A: str="3RCC_A"; break; 362case SSL3_ST_SR_CERT_B: str="3RCC_B"; break; 363case SSL3_ST_SR_KEY_EXCH_A: str="3RCKEA"; break; 364case SSL3_ST_SR_KEY_EXCH_B: str="3RCKEB"; break; 365case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break; 366case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; 367#endif 368 369#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) 370/* SSLv2/v3 compatibility states */ 371/* client */ 372case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break; 373case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break; 374case SSL23_ST_CR_SRVR_HELLO_A: str="23RSHA"; break; 375case SSL23_ST_CR_SRVR_HELLO_B: str="23RSHA"; break; 376/* server */ 377case SSL23_ST_SR_CLNT_HELLO_A: str="23RCHA"; break; 378case SSL23_ST_SR_CLNT_HELLO_B: str="23RCHB"; break; 379#endif 380/* DTLS */ 381case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_A: str="DRCHVA"; break; 382case DTLS1_ST_CR_HELLO_VERIFY_REQUEST_B: str="DRCHVB"; break; 383case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_A: str="DWCHVA"; break; 384case DTLS1_ST_SW_HELLO_VERIFY_REQUEST_B: str="DWCHVB"; break; 385 386default: str="UNKWN "; break; 387 } 388 return(str); 389 } 390 391const char *SSL_alert_type_string_long(int value) 392 { 393 value>>=8; 394 if (value == SSL3_AL_WARNING) 395 return("warning"); 396 else if (value == SSL3_AL_FATAL) 397 return("fatal"); 398 else 399 return("unknown"); 400 } 401 402const char *SSL_alert_type_string(int value) 403 { 404 value>>=8; 405 if (value == SSL3_AL_WARNING) 406 return("W"); 407 else if (value == SSL3_AL_FATAL) 408 return("F"); 409 else 410 return("U"); 411 } 412 413const char *SSL_alert_desc_string(int value) 414 { 415 const char *str; 416 417 switch (value & 0xff) 418 { 419 case SSL3_AD_CLOSE_NOTIFY: str="CN"; break; 420 case SSL3_AD_UNEXPECTED_MESSAGE: str="UM"; break; 421 case SSL3_AD_BAD_RECORD_MAC: str="BM"; break; 422 case SSL3_AD_DECOMPRESSION_FAILURE: str="DF"; break; 423 case SSL3_AD_HANDSHAKE_FAILURE: str="HF"; break; 424 case SSL3_AD_NO_CERTIFICATE: str="NC"; break; 425 case SSL3_AD_BAD_CERTIFICATE: str="BC"; break; 426 case SSL3_AD_UNSUPPORTED_CERTIFICATE: str="UC"; break; 427 case SSL3_AD_CERTIFICATE_REVOKED: str="CR"; break; 428 case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; 429 case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; 430 case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; 431 case TLS1_AD_DECRYPTION_FAILED: str="DC"; break; 432 case TLS1_AD_RECORD_OVERFLOW: str="RO"; break; 433 case TLS1_AD_UNKNOWN_CA: str="CA"; break; 434 case TLS1_AD_ACCESS_DENIED: str="AD"; break; 435 case TLS1_AD_DECODE_ERROR: str="DE"; break; 436 case TLS1_AD_DECRYPT_ERROR: str="CY"; break; 437 case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break; 438 case TLS1_AD_PROTOCOL_VERSION: str="PV"; break; 439 case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break; 440 case TLS1_AD_INTERNAL_ERROR: str="IE"; break; 441 case TLS1_AD_USER_CANCELLED: str="US"; break; 442 case TLS1_AD_NO_RENEGOTIATION: str="NR"; break; 443 case TLS1_AD_UNSUPPORTED_EXTENSION: str="UE"; break; 444 case TLS1_AD_CERTIFICATE_UNOBTAINABLE: str="CO"; break; 445 case TLS1_AD_UNRECOGNIZED_NAME: str="UN"; break; 446 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: str="BR"; break; 447 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: str="BH"; break; 448 case TLS1_AD_UNKNOWN_PSK_IDENTITY: str="UP"; break; 449 default: str="UK"; break; 450 } 451 return(str); 452 } 453 454const char *SSL_alert_desc_string_long(int value) 455 { 456 const char *str; 457 458 switch (value & 0xff) 459 { 460 case SSL3_AD_CLOSE_NOTIFY: 461 str="close notify"; 462 break; 463 case SSL3_AD_UNEXPECTED_MESSAGE: 464 str="unexpected_message"; 465 break; 466 case SSL3_AD_BAD_RECORD_MAC: 467 str="bad record mac"; 468 break; 469 case SSL3_AD_DECOMPRESSION_FAILURE: 470 str="decompression failure"; 471 break; 472 case SSL3_AD_HANDSHAKE_FAILURE: 473 str="handshake failure"; 474 break; 475 case SSL3_AD_NO_CERTIFICATE: 476 str="no certificate"; 477 break; 478 case SSL3_AD_BAD_CERTIFICATE: 479 str="bad certificate"; 480 break; 481 case SSL3_AD_UNSUPPORTED_CERTIFICATE: 482 str="unsupported certificate"; 483 break; 484 case SSL3_AD_CERTIFICATE_REVOKED: 485 str="certificate revoked"; 486 break; 487 case SSL3_AD_CERTIFICATE_EXPIRED: 488 str="certificate expired"; 489 break; 490 case SSL3_AD_CERTIFICATE_UNKNOWN: 491 str="certificate unknown"; 492 break; 493 case SSL3_AD_ILLEGAL_PARAMETER: 494 str="illegal parameter"; 495 break; 496 case TLS1_AD_DECRYPTION_FAILED: 497 str="decryption failed"; 498 break; 499 case TLS1_AD_RECORD_OVERFLOW: 500 str="record overflow"; 501 break; 502 case TLS1_AD_UNKNOWN_CA: 503 str="unknown CA"; 504 break; 505 case TLS1_AD_ACCESS_DENIED: 506 str="access denied"; 507 break; 508 case TLS1_AD_DECODE_ERROR: 509 str="decode error"; 510 break; 511 case TLS1_AD_DECRYPT_ERROR: 512 str="decrypt error"; 513 break; 514 case TLS1_AD_EXPORT_RESTRICTION: 515 str="export restriction"; 516 break; 517 case TLS1_AD_PROTOCOL_VERSION: 518 str="protocol version"; 519 break; 520 case TLS1_AD_INSUFFICIENT_SECURITY: 521 str="insufficient security"; 522 break; 523 case TLS1_AD_INTERNAL_ERROR: 524 str="internal error"; 525 break; 526 case TLS1_AD_USER_CANCELLED: 527 str="user canceled"; 528 break; 529 case TLS1_AD_NO_RENEGOTIATION: 530 str="no renegotiation"; 531 break; 532 case TLS1_AD_UNSUPPORTED_EXTENSION: 533 str="unsupported extension"; 534 break; 535 case TLS1_AD_CERTIFICATE_UNOBTAINABLE: 536 str="certificate unobtainable"; 537 break; 538 case TLS1_AD_UNRECOGNIZED_NAME: 539 str="unrecognized name"; 540 break; 541 case TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE: 542 str="bad certificate status response"; 543 break; 544 case TLS1_AD_BAD_CERTIFICATE_HASH_VALUE: 545 str="bad certificate hash value"; 546 break; 547 case TLS1_AD_UNKNOWN_PSK_IDENTITY: 548 str="unknown PSK identity"; 549 break; 550 default: str="unknown"; break; 551 } 552 return(str); 553 } 554 555const char *SSL_rstate_string(const SSL *s) 556 { 557 const char *str; 558 559 switch (s->rstate) 560 { 561 case SSL_ST_READ_HEADER:str="RH"; break; 562 case SSL_ST_READ_BODY: str="RB"; break; 563 case SSL_ST_READ_DONE: str="RD"; break; 564 default: str="unknown"; break; 565 } 566 return(str); 567 } 568