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