1*0Sstevel@tonic-gate /* ssl/ssl_stat.c */ 2*0Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3*0Sstevel@tonic-gate * All rights reserved. 4*0Sstevel@tonic-gate * 5*0Sstevel@tonic-gate * This package is an SSL implementation written 6*0Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com). 7*0Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as 10*0Sstevel@tonic-gate * the following conditions are aheared to. The following conditions 11*0Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA, 12*0Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13*0Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms 14*0Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15*0Sstevel@tonic-gate * 16*0Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in 17*0Sstevel@tonic-gate * the code are not to be removed. 18*0Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution 19*0Sstevel@tonic-gate * as the author of the parts of the library used. 20*0Sstevel@tonic-gate * This can be in the form of a textual message at program startup or 21*0Sstevel@tonic-gate * in documentation (online or textual) provided with the package. 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 24*0Sstevel@tonic-gate * modification, are permitted provided that the following conditions 25*0Sstevel@tonic-gate * are met: 26*0Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright 27*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 28*0Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 29*0Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 30*0Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 31*0Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 32*0Sstevel@tonic-gate * must display the following acknowledgement: 33*0Sstevel@tonic-gate * "This product includes cryptographic software written by 34*0Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)" 35*0Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library 36*0Sstevel@tonic-gate * being used are not cryptographic related :-). 37*0Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from 38*0Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement: 39*0Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40*0Sstevel@tonic-gate * 41*0Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42*0Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43*0Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44*0Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45*0Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46*0Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47*0Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48*0Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49*0Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50*0Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51*0Sstevel@tonic-gate * SUCH DAMAGE. 52*0Sstevel@tonic-gate * 53*0Sstevel@tonic-gate * The licence and distribution terms for any publically available version or 54*0Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be 55*0Sstevel@tonic-gate * copied and put under another distribution licence 56*0Sstevel@tonic-gate * [including the GNU Public Licence.] 57*0Sstevel@tonic-gate */ 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate #include <stdio.h> 60*0Sstevel@tonic-gate #include "ssl_locl.h" 61*0Sstevel@tonic-gate 62*0Sstevel@tonic-gate const char *SSL_state_string_long(const SSL *s) 63*0Sstevel@tonic-gate { 64*0Sstevel@tonic-gate const char *str; 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate switch (s->state) 67*0Sstevel@tonic-gate { 68*0Sstevel@tonic-gate case SSL_ST_BEFORE: str="before SSL initialization"; break; 69*0Sstevel@tonic-gate case SSL_ST_ACCEPT: str="before accept initialization"; break; 70*0Sstevel@tonic-gate case SSL_ST_CONNECT: str="before connect initialization"; break; 71*0Sstevel@tonic-gate case SSL_ST_OK: str="SSL negotiation finished successfully"; break; 72*0Sstevel@tonic-gate case SSL_ST_RENEGOTIATE: str="SSL renegotiate ciphers"; break; 73*0Sstevel@tonic-gate case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break; 74*0Sstevel@tonic-gate case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break; 75*0Sstevel@tonic-gate case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break; 76*0Sstevel@tonic-gate case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break; 77*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SSL2 78*0Sstevel@tonic-gate case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break; 79*0Sstevel@tonic-gate case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break; 80*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break; 81*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_HELLO_B: str="SSLv2 write client hello B"; break; 82*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_HELLO_A: str="SSLv2 read server hello A"; break; 83*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_HELLO_B: str="SSLv2 read server hello B"; break; 84*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="SSLv2 write client master key A"; break; 85*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="SSLv2 write client master key B"; break; 86*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_FINISHED_A: str="SSLv2 write client finished A"; break; 87*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_FINISHED_B: str="SSLv2 write client finished B"; break; 88*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="SSLv2 write client certificate A"; break; 89*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="SSLv2 write client certificate B"; break; 90*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="SSLv2 write client certificate C"; break; 91*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="SSLv2 write client certificate D"; break; 92*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_VERIFY_A: str="SSLv2 read server verify A"; break; 93*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_VERIFY_B: str="SSLv2 read server verify B"; break; 94*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_FINISHED_A: str="SSLv2 read server finished A"; break; 95*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_FINISHED_B: str="SSLv2 read server finished B"; break; 96*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_HELLO_A: str="SSLv2 read client hello A"; break; 97*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_HELLO_B: str="SSLv2 read client hello B"; break; 98*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_HELLO_C: str="SSLv2 read client hello C"; break; 99*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_HELLO_A: str="SSLv2 write server hello A"; break; 100*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_HELLO_B: str="SSLv2 write server hello B"; break; 101*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="SSLv2 read client master key A"; break; 102*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="SSLv2 read client master key B"; break; 103*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_VERIFY_A: str="SSLv2 write server verify A"; break; 104*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_VERIFY_B: str="SSLv2 write server verify B"; break; 105*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_VERIFY_C: str="SSLv2 write server verify C"; break; 106*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_FINISHED_A: str="SSLv2 read client finished A"; break; 107*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_FINISHED_B: str="SSLv2 read client finished B"; break; 108*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_FINISHED_A: str="SSLv2 write server finished A"; break; 109*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_FINISHED_B: str="SSLv2 write server finished B"; break; 110*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="SSLv2 write request certificate A"; break; 111*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="SSLv2 write request certificate B"; break; 112*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="SSLv2 write request certificate C"; break; 113*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="SSLv2 write request certificate D"; break; 114*0Sstevel@tonic-gate case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificate"; break; 115*0Sstevel@tonic-gate case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break; 116*0Sstevel@tonic-gate #endif 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SSL3 119*0Sstevel@tonic-gate /* SSLv3 additions */ 120*0Sstevel@tonic-gate case SSL3_ST_CW_CLNT_HELLO_A: str="SSLv3 write client hello A"; break; 121*0Sstevel@tonic-gate case SSL3_ST_CW_CLNT_HELLO_B: str="SSLv3 write client hello B"; break; 122*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_HELLO_A: str="SSLv3 read server hello A"; break; 123*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_HELLO_B: str="SSLv3 read server hello B"; break; 124*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_A: str="SSLv3 read server certificate A"; break; 125*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_B: str="SSLv3 read server certificate B"; break; 126*0Sstevel@tonic-gate case SSL3_ST_CR_KEY_EXCH_A: str="SSLv3 read server key exchange A"; break; 127*0Sstevel@tonic-gate case SSL3_ST_CR_KEY_EXCH_B: str="SSLv3 read server key exchange B"; break; 128*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_REQ_A: str="SSLv3 read server certificate request A"; break; 129*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_REQ_B: str="SSLv3 read server certificate request B"; break; 130*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_DONE_A: str="SSLv3 read server done A"; break; 131*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_DONE_B: str="SSLv3 read server done B"; break; 132*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_A: str="SSLv3 write client certificate A"; break; 133*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_B: str="SSLv3 write client certificate B"; break; 134*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_C: str="SSLv3 write client certificate C"; break; 135*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_D: str="SSLv3 write client certificate D"; break; 136*0Sstevel@tonic-gate case SSL3_ST_CW_KEY_EXCH_A: str="SSLv3 write client key exchange A"; break; 137*0Sstevel@tonic-gate case SSL3_ST_CW_KEY_EXCH_B: str="SSLv3 write client key exchange B"; break; 138*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_VRFY_A: str="SSLv3 write certificate verify A"; break; 139*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_VRFY_B: str="SSLv3 write certificate verify B"; break; 140*0Sstevel@tonic-gate 141*0Sstevel@tonic-gate case SSL3_ST_CW_CHANGE_A: 142*0Sstevel@tonic-gate case SSL3_ST_SW_CHANGE_A: str="SSLv3 write change cipher spec A"; break; 143*0Sstevel@tonic-gate case SSL3_ST_CW_CHANGE_B: 144*0Sstevel@tonic-gate case SSL3_ST_SW_CHANGE_B: str="SSLv3 write change cipher spec B"; break; 145*0Sstevel@tonic-gate case SSL3_ST_CW_FINISHED_A: 146*0Sstevel@tonic-gate case SSL3_ST_SW_FINISHED_A: str="SSLv3 write finished A"; break; 147*0Sstevel@tonic-gate case SSL3_ST_CW_FINISHED_B: 148*0Sstevel@tonic-gate case SSL3_ST_SW_FINISHED_B: str="SSLv3 write finished B"; break; 149*0Sstevel@tonic-gate case SSL3_ST_CR_CHANGE_A: 150*0Sstevel@tonic-gate case SSL3_ST_SR_CHANGE_A: str="SSLv3 read change cipher spec A"; break; 151*0Sstevel@tonic-gate case SSL3_ST_CR_CHANGE_B: 152*0Sstevel@tonic-gate case SSL3_ST_SR_CHANGE_B: str="SSLv3 read change cipher spec B"; break; 153*0Sstevel@tonic-gate case SSL3_ST_CR_FINISHED_A: 154*0Sstevel@tonic-gate case SSL3_ST_SR_FINISHED_A: str="SSLv3 read finished A"; break; 155*0Sstevel@tonic-gate case SSL3_ST_CR_FINISHED_B: 156*0Sstevel@tonic-gate case SSL3_ST_SR_FINISHED_B: str="SSLv3 read finished B"; break; 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate case SSL3_ST_CW_FLUSH: 159*0Sstevel@tonic-gate case SSL3_ST_SW_FLUSH: str="SSLv3 flush data"; break; 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate case SSL3_ST_SR_CLNT_HELLO_A: str="SSLv3 read client hello A"; break; 162*0Sstevel@tonic-gate case SSL3_ST_SR_CLNT_HELLO_B: str="SSLv3 read client hello B"; break; 163*0Sstevel@tonic-gate case SSL3_ST_SR_CLNT_HELLO_C: str="SSLv3 read client hello C"; break; 164*0Sstevel@tonic-gate case SSL3_ST_SW_HELLO_REQ_A: str="SSLv3 write hello request A"; break; 165*0Sstevel@tonic-gate case SSL3_ST_SW_HELLO_REQ_B: str="SSLv3 write hello request B"; break; 166*0Sstevel@tonic-gate case SSL3_ST_SW_HELLO_REQ_C: str="SSLv3 write hello request C"; break; 167*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_HELLO_A: str="SSLv3 write server hello A"; break; 168*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_HELLO_B: str="SSLv3 write server hello B"; break; 169*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_A: str="SSLv3 write certificate A"; break; 170*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_B: str="SSLv3 write certificate B"; break; 171*0Sstevel@tonic-gate case SSL3_ST_SW_KEY_EXCH_A: str="SSLv3 write key exchange A"; break; 172*0Sstevel@tonic-gate case SSL3_ST_SW_KEY_EXCH_B: str="SSLv3 write key exchange B"; break; 173*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_REQ_A: str="SSLv3 write certificate request A"; break; 174*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_REQ_B: str="SSLv3 write certificate request B"; break; 175*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_DONE_A: str="SSLv3 write server done A"; break; 176*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_DONE_B: str="SSLv3 write server done B"; break; 177*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_A: str="SSLv3 read client certificate A"; break; 178*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_B: str="SSLv3 read client certificate B"; break; 179*0Sstevel@tonic-gate case SSL3_ST_SR_KEY_EXCH_A: str="SSLv3 read client key exchange A"; break; 180*0Sstevel@tonic-gate case SSL3_ST_SR_KEY_EXCH_B: str="SSLv3 read client key exchange B"; break; 181*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_VRFY_A: str="SSLv3 read certificate verify A"; break; 182*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_VRFY_B: str="SSLv3 read certificate verify B"; break; 183*0Sstevel@tonic-gate #endif 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) 186*0Sstevel@tonic-gate /* SSLv2/v3 compatibility states */ 187*0Sstevel@tonic-gate /* client */ 188*0Sstevel@tonic-gate case SSL23_ST_CW_CLNT_HELLO_A: str="SSLv2/v3 write client hello A"; break; 189*0Sstevel@tonic-gate case SSL23_ST_CW_CLNT_HELLO_B: str="SSLv2/v3 write client hello B"; break; 190*0Sstevel@tonic-gate case SSL23_ST_CR_SRVR_HELLO_A: str="SSLv2/v3 read server hello A"; break; 191*0Sstevel@tonic-gate case SSL23_ST_CR_SRVR_HELLO_B: str="SSLv2/v3 read server hello B"; break; 192*0Sstevel@tonic-gate /* server */ 193*0Sstevel@tonic-gate case SSL23_ST_SR_CLNT_HELLO_A: str="SSLv2/v3 read client hello A"; break; 194*0Sstevel@tonic-gate case SSL23_ST_SR_CLNT_HELLO_B: str="SSLv2/v3 read client hello B"; break; 195*0Sstevel@tonic-gate #endif 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate default: str="unknown state"; break; 198*0Sstevel@tonic-gate } 199*0Sstevel@tonic-gate return(str); 200*0Sstevel@tonic-gate } 201*0Sstevel@tonic-gate 202*0Sstevel@tonic-gate const char *SSL_rstate_string_long(const SSL *s) 203*0Sstevel@tonic-gate { 204*0Sstevel@tonic-gate const char *str; 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate switch (s->rstate) 207*0Sstevel@tonic-gate { 208*0Sstevel@tonic-gate case SSL_ST_READ_HEADER: str="read header"; break; 209*0Sstevel@tonic-gate case SSL_ST_READ_BODY: str="read body"; break; 210*0Sstevel@tonic-gate case SSL_ST_READ_DONE: str="read done"; break; 211*0Sstevel@tonic-gate default: str="unknown"; break; 212*0Sstevel@tonic-gate } 213*0Sstevel@tonic-gate return(str); 214*0Sstevel@tonic-gate } 215*0Sstevel@tonic-gate 216*0Sstevel@tonic-gate const char *SSL_state_string(const SSL *s) 217*0Sstevel@tonic-gate { 218*0Sstevel@tonic-gate const char *str; 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gate switch (s->state) 221*0Sstevel@tonic-gate { 222*0Sstevel@tonic-gate case SSL_ST_BEFORE: str="PINIT "; break; 223*0Sstevel@tonic-gate case SSL_ST_ACCEPT: str="AINIT "; break; 224*0Sstevel@tonic-gate case SSL_ST_CONNECT: str="CINIT "; break; 225*0Sstevel@tonic-gate case SSL_ST_OK: str="SSLOK "; break; 226*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SSL2 227*0Sstevel@tonic-gate case SSL2_ST_CLIENT_START_ENCRYPTION: str="2CSENC"; break; 228*0Sstevel@tonic-gate case SSL2_ST_SERVER_START_ENCRYPTION: str="2SSENC"; break; 229*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_HELLO_A: str="2SCH_A"; break; 230*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_HELLO_B: str="2SCH_B"; break; 231*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_HELLO_A: str="2GSH_A"; break; 232*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_HELLO_B: str="2GSH_B"; break; 233*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="2SCMKA"; break; 234*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="2SCMKB"; break; 235*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_FINISHED_A: str="2SCF_A"; break; 236*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_FINISHED_B: str="2SCF_B"; break; 237*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="2SCC_A"; break; 238*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="2SCC_B"; break; 239*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="2SCC_C"; break; 240*0Sstevel@tonic-gate case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="2SCC_D"; break; 241*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_VERIFY_A: str="2GSV_A"; break; 242*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_VERIFY_B: str="2GSV_B"; break; 243*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_FINISHED_A: str="2GSF_A"; break; 244*0Sstevel@tonic-gate case SSL2_ST_GET_SERVER_FINISHED_B: str="2GSF_B"; break; 245*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_HELLO_A: str="2GCH_A"; break; 246*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_HELLO_B: str="2GCH_B"; break; 247*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_HELLO_C: str="2GCH_C"; break; 248*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_HELLO_A: str="2SSH_A"; break; 249*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_HELLO_B: str="2SSH_B"; break; 250*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="2GCMKA"; break; 251*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="2GCMKA"; break; 252*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_VERIFY_A: str="2SSV_A"; break; 253*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_VERIFY_B: str="2SSV_B"; break; 254*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_VERIFY_C: str="2SSV_C"; break; 255*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_FINISHED_A: str="2GCF_A"; break; 256*0Sstevel@tonic-gate case SSL2_ST_GET_CLIENT_FINISHED_B: str="2GCF_B"; break; 257*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_FINISHED_A: str="2SSF_A"; break; 258*0Sstevel@tonic-gate case SSL2_ST_SEND_SERVER_FINISHED_B: str="2SSF_B"; break; 259*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="2SRC_A"; break; 260*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="2SRC_B"; break; 261*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="2SRC_C"; break; 262*0Sstevel@tonic-gate case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="2SRC_D"; break; 263*0Sstevel@tonic-gate case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="2X9GSC"; break; 264*0Sstevel@tonic-gate case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="2X9GCC"; break; 265*0Sstevel@tonic-gate #endif 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate #ifndef OPENSSL_NO_SSL3 268*0Sstevel@tonic-gate /* SSLv3 additions */ 269*0Sstevel@tonic-gate case SSL3_ST_SW_FLUSH: 270*0Sstevel@tonic-gate case SSL3_ST_CW_FLUSH: str="3FLUSH"; break; 271*0Sstevel@tonic-gate case SSL3_ST_CW_CLNT_HELLO_A: str="3WCH_A"; break; 272*0Sstevel@tonic-gate case SSL3_ST_CW_CLNT_HELLO_B: str="3WCH_B"; break; 273*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_HELLO_A: str="3RSH_A"; break; 274*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_HELLO_B: str="3RSH_B"; break; 275*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_A: str="3RSC_A"; break; 276*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_B: str="3RSC_B"; break; 277*0Sstevel@tonic-gate case SSL3_ST_CR_KEY_EXCH_A: str="3RSKEA"; break; 278*0Sstevel@tonic-gate case SSL3_ST_CR_KEY_EXCH_B: str="3RSKEB"; break; 279*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_REQ_A: str="3RCR_A"; break; 280*0Sstevel@tonic-gate case SSL3_ST_CR_CERT_REQ_B: str="3RCR_B"; break; 281*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_DONE_A: str="3RSD_A"; break; 282*0Sstevel@tonic-gate case SSL3_ST_CR_SRVR_DONE_B: str="3RSD_B"; break; 283*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_A: str="3WCC_A"; break; 284*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_B: str="3WCC_B"; break; 285*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_C: str="3WCC_C"; break; 286*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_D: str="3WCC_D"; break; 287*0Sstevel@tonic-gate case SSL3_ST_CW_KEY_EXCH_A: str="3WCKEA"; break; 288*0Sstevel@tonic-gate case SSL3_ST_CW_KEY_EXCH_B: str="3WCKEB"; break; 289*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_VRFY_A: str="3WCV_A"; break; 290*0Sstevel@tonic-gate case SSL3_ST_CW_CERT_VRFY_B: str="3WCV_B"; break; 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate case SSL3_ST_SW_CHANGE_A: 293*0Sstevel@tonic-gate case SSL3_ST_CW_CHANGE_A: str="3WCCSA"; break; 294*0Sstevel@tonic-gate case SSL3_ST_SW_CHANGE_B: 295*0Sstevel@tonic-gate case SSL3_ST_CW_CHANGE_B: str="3WCCSB"; break; 296*0Sstevel@tonic-gate case SSL3_ST_SW_FINISHED_A: 297*0Sstevel@tonic-gate case SSL3_ST_CW_FINISHED_A: str="3WFINA"; break; 298*0Sstevel@tonic-gate case SSL3_ST_SW_FINISHED_B: 299*0Sstevel@tonic-gate case SSL3_ST_CW_FINISHED_B: str="3WFINB"; break; 300*0Sstevel@tonic-gate case SSL3_ST_SR_CHANGE_A: 301*0Sstevel@tonic-gate case SSL3_ST_CR_CHANGE_A: str="3RCCSA"; break; 302*0Sstevel@tonic-gate case SSL3_ST_SR_CHANGE_B: 303*0Sstevel@tonic-gate case SSL3_ST_CR_CHANGE_B: str="3RCCSB"; break; 304*0Sstevel@tonic-gate case SSL3_ST_SR_FINISHED_A: 305*0Sstevel@tonic-gate case SSL3_ST_CR_FINISHED_A: str="3RFINA"; break; 306*0Sstevel@tonic-gate case SSL3_ST_SR_FINISHED_B: 307*0Sstevel@tonic-gate case SSL3_ST_CR_FINISHED_B: str="3RFINB"; break; 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate case SSL3_ST_SW_HELLO_REQ_A: str="3WHR_A"; break; 310*0Sstevel@tonic-gate case SSL3_ST_SW_HELLO_REQ_B: str="3WHR_B"; break; 311*0Sstevel@tonic-gate case SSL3_ST_SW_HELLO_REQ_C: str="3WHR_C"; break; 312*0Sstevel@tonic-gate case SSL3_ST_SR_CLNT_HELLO_A: str="3RCH_A"; break; 313*0Sstevel@tonic-gate case SSL3_ST_SR_CLNT_HELLO_B: str="3RCH_B"; break; 314*0Sstevel@tonic-gate case SSL3_ST_SR_CLNT_HELLO_C: str="3RCH_C"; break; 315*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_HELLO_A: str="3WSH_A"; break; 316*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_HELLO_B: str="3WSH_B"; break; 317*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_A: str="3WSC_A"; break; 318*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_B: str="3WSC_B"; break; 319*0Sstevel@tonic-gate case SSL3_ST_SW_KEY_EXCH_A: str="3WSKEA"; break; 320*0Sstevel@tonic-gate case SSL3_ST_SW_KEY_EXCH_B: str="3WSKEB"; break; 321*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_REQ_A: str="3WCR_A"; break; 322*0Sstevel@tonic-gate case SSL3_ST_SW_CERT_REQ_B: str="3WCR_B"; break; 323*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_DONE_A: str="3WSD_A"; break; 324*0Sstevel@tonic-gate case SSL3_ST_SW_SRVR_DONE_B: str="3WSD_B"; break; 325*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_A: str="3RCC_A"; break; 326*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_B: str="3RCC_B"; break; 327*0Sstevel@tonic-gate case SSL3_ST_SR_KEY_EXCH_A: str="3RCKEA"; break; 328*0Sstevel@tonic-gate case SSL3_ST_SR_KEY_EXCH_B: str="3RCKEB"; break; 329*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_VRFY_A: str="3RCV_A"; break; 330*0Sstevel@tonic-gate case SSL3_ST_SR_CERT_VRFY_B: str="3RCV_B"; break; 331*0Sstevel@tonic-gate #endif 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate #if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3) 334*0Sstevel@tonic-gate /* SSLv2/v3 compatibility states */ 335*0Sstevel@tonic-gate /* client */ 336*0Sstevel@tonic-gate case SSL23_ST_CW_CLNT_HELLO_A: str="23WCHA"; break; 337*0Sstevel@tonic-gate case SSL23_ST_CW_CLNT_HELLO_B: str="23WCHB"; break; 338*0Sstevel@tonic-gate case SSL23_ST_CR_SRVR_HELLO_A: str="23RSHA"; break; 339*0Sstevel@tonic-gate case SSL23_ST_CR_SRVR_HELLO_B: str="23RSHA"; break; 340*0Sstevel@tonic-gate /* server */ 341*0Sstevel@tonic-gate case SSL23_ST_SR_CLNT_HELLO_A: str="23RCHA"; break; 342*0Sstevel@tonic-gate case SSL23_ST_SR_CLNT_HELLO_B: str="23RCHB"; break; 343*0Sstevel@tonic-gate #endif 344*0Sstevel@tonic-gate 345*0Sstevel@tonic-gate default: str="UNKWN "; break; 346*0Sstevel@tonic-gate } 347*0Sstevel@tonic-gate return(str); 348*0Sstevel@tonic-gate } 349*0Sstevel@tonic-gate 350*0Sstevel@tonic-gate const char *SSL_alert_type_string_long(int value) 351*0Sstevel@tonic-gate { 352*0Sstevel@tonic-gate value>>=8; 353*0Sstevel@tonic-gate if (value == SSL3_AL_WARNING) 354*0Sstevel@tonic-gate return("warning"); 355*0Sstevel@tonic-gate else if (value == SSL3_AL_FATAL) 356*0Sstevel@tonic-gate return("fatal"); 357*0Sstevel@tonic-gate else 358*0Sstevel@tonic-gate return("unknown"); 359*0Sstevel@tonic-gate } 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate const char *SSL_alert_type_string(int value) 362*0Sstevel@tonic-gate { 363*0Sstevel@tonic-gate value>>=8; 364*0Sstevel@tonic-gate if (value == SSL3_AL_WARNING) 365*0Sstevel@tonic-gate return("W"); 366*0Sstevel@tonic-gate else if (value == SSL3_AL_FATAL) 367*0Sstevel@tonic-gate return("F"); 368*0Sstevel@tonic-gate else 369*0Sstevel@tonic-gate return("U"); 370*0Sstevel@tonic-gate } 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate const char *SSL_alert_desc_string(int value) 373*0Sstevel@tonic-gate { 374*0Sstevel@tonic-gate const char *str; 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate switch (value & 0xff) 377*0Sstevel@tonic-gate { 378*0Sstevel@tonic-gate case SSL3_AD_CLOSE_NOTIFY: str="CN"; break; 379*0Sstevel@tonic-gate case SSL3_AD_UNEXPECTED_MESSAGE: str="UM"; break; 380*0Sstevel@tonic-gate case SSL3_AD_BAD_RECORD_MAC: str="BM"; break; 381*0Sstevel@tonic-gate case SSL3_AD_DECOMPRESSION_FAILURE: str="DF"; break; 382*0Sstevel@tonic-gate case SSL3_AD_HANDSHAKE_FAILURE: str="HF"; break; 383*0Sstevel@tonic-gate case SSL3_AD_NO_CERTIFICATE: str="NC"; break; 384*0Sstevel@tonic-gate case SSL3_AD_BAD_CERTIFICATE: str="BC"; break; 385*0Sstevel@tonic-gate case SSL3_AD_UNSUPPORTED_CERTIFICATE: str="UC"; break; 386*0Sstevel@tonic-gate case SSL3_AD_CERTIFICATE_REVOKED: str="CR"; break; 387*0Sstevel@tonic-gate case SSL3_AD_CERTIFICATE_EXPIRED: str="CE"; break; 388*0Sstevel@tonic-gate case SSL3_AD_CERTIFICATE_UNKNOWN: str="CU"; break; 389*0Sstevel@tonic-gate case SSL3_AD_ILLEGAL_PARAMETER: str="IP"; break; 390*0Sstevel@tonic-gate case TLS1_AD_DECRYPTION_FAILED: str="DC"; break; 391*0Sstevel@tonic-gate case TLS1_AD_RECORD_OVERFLOW: str="RO"; break; 392*0Sstevel@tonic-gate case TLS1_AD_UNKNOWN_CA: str="CA"; break; 393*0Sstevel@tonic-gate case TLS1_AD_ACCESS_DENIED: str="AD"; break; 394*0Sstevel@tonic-gate case TLS1_AD_DECODE_ERROR: str="DE"; break; 395*0Sstevel@tonic-gate case TLS1_AD_DECRYPT_ERROR: str="CY"; break; 396*0Sstevel@tonic-gate case TLS1_AD_EXPORT_RESTRICTION: str="ER"; break; 397*0Sstevel@tonic-gate case TLS1_AD_PROTOCOL_VERSION: str="PV"; break; 398*0Sstevel@tonic-gate case TLS1_AD_INSUFFICIENT_SECURITY: str="IS"; break; 399*0Sstevel@tonic-gate case TLS1_AD_INTERNAL_ERROR: str="IE"; break; 400*0Sstevel@tonic-gate case TLS1_AD_USER_CANCELLED: str="US"; break; 401*0Sstevel@tonic-gate case TLS1_AD_NO_RENEGOTIATION: str="NR"; break; 402*0Sstevel@tonic-gate default: str="UK"; break; 403*0Sstevel@tonic-gate } 404*0Sstevel@tonic-gate return(str); 405*0Sstevel@tonic-gate } 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate const char *SSL_alert_desc_string_long(int value) 408*0Sstevel@tonic-gate { 409*0Sstevel@tonic-gate const char *str; 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate switch (value & 0xff) 412*0Sstevel@tonic-gate { 413*0Sstevel@tonic-gate case SSL3_AD_CLOSE_NOTIFY: 414*0Sstevel@tonic-gate str="close notify"; 415*0Sstevel@tonic-gate break; 416*0Sstevel@tonic-gate case SSL3_AD_UNEXPECTED_MESSAGE: 417*0Sstevel@tonic-gate str="unexpected_message"; 418*0Sstevel@tonic-gate break; 419*0Sstevel@tonic-gate case SSL3_AD_BAD_RECORD_MAC: 420*0Sstevel@tonic-gate str="bad record mac"; 421*0Sstevel@tonic-gate break; 422*0Sstevel@tonic-gate case SSL3_AD_DECOMPRESSION_FAILURE: 423*0Sstevel@tonic-gate str="decompression failure"; 424*0Sstevel@tonic-gate break; 425*0Sstevel@tonic-gate case SSL3_AD_HANDSHAKE_FAILURE: 426*0Sstevel@tonic-gate str="handshake failure"; 427*0Sstevel@tonic-gate break; 428*0Sstevel@tonic-gate case SSL3_AD_NO_CERTIFICATE: 429*0Sstevel@tonic-gate str="no certificate"; 430*0Sstevel@tonic-gate break; 431*0Sstevel@tonic-gate case SSL3_AD_BAD_CERTIFICATE: 432*0Sstevel@tonic-gate str="bad certificate"; 433*0Sstevel@tonic-gate break; 434*0Sstevel@tonic-gate case SSL3_AD_UNSUPPORTED_CERTIFICATE: 435*0Sstevel@tonic-gate str="unsupported certificate"; 436*0Sstevel@tonic-gate break; 437*0Sstevel@tonic-gate case SSL3_AD_CERTIFICATE_REVOKED: 438*0Sstevel@tonic-gate str="certificate revoked"; 439*0Sstevel@tonic-gate break; 440*0Sstevel@tonic-gate case SSL3_AD_CERTIFICATE_EXPIRED: 441*0Sstevel@tonic-gate str="certificate expired"; 442*0Sstevel@tonic-gate break; 443*0Sstevel@tonic-gate case SSL3_AD_CERTIFICATE_UNKNOWN: 444*0Sstevel@tonic-gate str="certificate unknown"; 445*0Sstevel@tonic-gate break; 446*0Sstevel@tonic-gate case SSL3_AD_ILLEGAL_PARAMETER: 447*0Sstevel@tonic-gate str="illegal parameter"; 448*0Sstevel@tonic-gate break; 449*0Sstevel@tonic-gate case TLS1_AD_DECRYPTION_FAILED: 450*0Sstevel@tonic-gate str="decryption failed"; 451*0Sstevel@tonic-gate break; 452*0Sstevel@tonic-gate case TLS1_AD_RECORD_OVERFLOW: 453*0Sstevel@tonic-gate str="record overflow"; 454*0Sstevel@tonic-gate break; 455*0Sstevel@tonic-gate case TLS1_AD_UNKNOWN_CA: 456*0Sstevel@tonic-gate str="unknown CA"; 457*0Sstevel@tonic-gate break; 458*0Sstevel@tonic-gate case TLS1_AD_ACCESS_DENIED: 459*0Sstevel@tonic-gate str="access denied"; 460*0Sstevel@tonic-gate break; 461*0Sstevel@tonic-gate case TLS1_AD_DECODE_ERROR: 462*0Sstevel@tonic-gate str="decode error"; 463*0Sstevel@tonic-gate break; 464*0Sstevel@tonic-gate case TLS1_AD_DECRYPT_ERROR: 465*0Sstevel@tonic-gate str="decrypt error"; 466*0Sstevel@tonic-gate break; 467*0Sstevel@tonic-gate case TLS1_AD_EXPORT_RESTRICTION: 468*0Sstevel@tonic-gate str="export restriction"; 469*0Sstevel@tonic-gate break; 470*0Sstevel@tonic-gate case TLS1_AD_PROTOCOL_VERSION: 471*0Sstevel@tonic-gate str="protocol version"; 472*0Sstevel@tonic-gate break; 473*0Sstevel@tonic-gate case TLS1_AD_INSUFFICIENT_SECURITY: 474*0Sstevel@tonic-gate str="insufficient security"; 475*0Sstevel@tonic-gate break; 476*0Sstevel@tonic-gate case TLS1_AD_INTERNAL_ERROR: 477*0Sstevel@tonic-gate str="internal error"; 478*0Sstevel@tonic-gate break; 479*0Sstevel@tonic-gate case TLS1_AD_USER_CANCELLED: 480*0Sstevel@tonic-gate str="user canceled"; 481*0Sstevel@tonic-gate break; 482*0Sstevel@tonic-gate case TLS1_AD_NO_RENEGOTIATION: 483*0Sstevel@tonic-gate str="no renegotiation"; 484*0Sstevel@tonic-gate break; 485*0Sstevel@tonic-gate default: str="unknown"; break; 486*0Sstevel@tonic-gate } 487*0Sstevel@tonic-gate return(str); 488*0Sstevel@tonic-gate } 489*0Sstevel@tonic-gate 490*0Sstevel@tonic-gate const char *SSL_rstate_string(const SSL *s) 491*0Sstevel@tonic-gate { 492*0Sstevel@tonic-gate const char *str; 493*0Sstevel@tonic-gate 494*0Sstevel@tonic-gate switch (s->rstate) 495*0Sstevel@tonic-gate { 496*0Sstevel@tonic-gate case SSL_ST_READ_HEADER:str="RH"; break; 497*0Sstevel@tonic-gate case SSL_ST_READ_BODY: str="RB"; break; 498*0Sstevel@tonic-gate case SSL_ST_READ_DONE: str="RD"; break; 499*0Sstevel@tonic-gate default: str="unknown"; break; 500*0Sstevel@tonic-gate } 501*0Sstevel@tonic-gate return(str); 502*0Sstevel@tonic-gate } 503