xref: /freebsd/crypto/openssl/ssl/ssl_stat.c (revision a21b1b381ecca3813b44ac652d05a5133d3f4e2b)
174664626SKris Kennaway /* ssl/ssl_stat.c */
274664626SKris Kennaway /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
374664626SKris Kennaway  * All rights reserved.
474664626SKris Kennaway  *
574664626SKris Kennaway  * This package is an SSL implementation written
674664626SKris Kennaway  * by Eric Young (eay@cryptsoft.com).
774664626SKris Kennaway  * The implementation was written so as to conform with Netscapes SSL.
874664626SKris Kennaway  *
974664626SKris Kennaway  * This library is free for commercial and non-commercial use as long as
1074664626SKris Kennaway  * the following conditions are aheared to.  The following conditions
1174664626SKris Kennaway  * apply to all code found in this distribution, be it the RC4, RSA,
1274664626SKris Kennaway  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
1374664626SKris Kennaway  * included with this distribution is covered by the same copyright terms
1474664626SKris Kennaway  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1574664626SKris Kennaway  *
1674664626SKris Kennaway  * Copyright remains Eric Young's, and as such any Copyright notices in
1774664626SKris Kennaway  * the code are not to be removed.
1874664626SKris Kennaway  * If this package is used in a product, Eric Young should be given attribution
1974664626SKris Kennaway  * as the author of the parts of the library used.
2074664626SKris Kennaway  * This can be in the form of a textual message at program startup or
2174664626SKris Kennaway  * in documentation (online or textual) provided with the package.
2274664626SKris Kennaway  *
2374664626SKris Kennaway  * Redistribution and use in source and binary forms, with or without
2474664626SKris Kennaway  * modification, are permitted provided that the following conditions
2574664626SKris Kennaway  * are met:
2674664626SKris Kennaway  * 1. Redistributions of source code must retain the copyright
2774664626SKris Kennaway  *    notice, this list of conditions and the following disclaimer.
2874664626SKris Kennaway  * 2. Redistributions in binary form must reproduce the above copyright
2974664626SKris Kennaway  *    notice, this list of conditions and the following disclaimer in the
3074664626SKris Kennaway  *    documentation and/or other materials provided with the distribution.
3174664626SKris Kennaway  * 3. All advertising materials mentioning features or use of this software
3274664626SKris Kennaway  *    must display the following acknowledgement:
3374664626SKris Kennaway  *    "This product includes cryptographic software written by
3474664626SKris Kennaway  *     Eric Young (eay@cryptsoft.com)"
3574664626SKris Kennaway  *    The word 'cryptographic' can be left out if the rouines from the library
3674664626SKris Kennaway  *    being used are not cryptographic related :-).
3774664626SKris Kennaway  * 4. If you include any Windows specific code (or a derivative thereof) from
3874664626SKris Kennaway  *    the apps directory (application code) you must include an acknowledgement:
3974664626SKris Kennaway  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
4074664626SKris Kennaway  *
4174664626SKris Kennaway  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
4274664626SKris Kennaway  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4374664626SKris Kennaway  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4474664626SKris Kennaway  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
4574664626SKris Kennaway  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4674664626SKris Kennaway  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4774664626SKris Kennaway  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4874664626SKris Kennaway  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4974664626SKris Kennaway  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5074664626SKris Kennaway  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
5174664626SKris Kennaway  * SUCH DAMAGE.
5274664626SKris Kennaway  *
5374664626SKris Kennaway  * The licence and distribution terms for any publically available version or
5474664626SKris Kennaway  * derivative of this code cannot be changed.  i.e. this code cannot simply be
5574664626SKris Kennaway  * copied and put under another distribution licence
5674664626SKris Kennaway  * [including the GNU Public Licence.]
5774664626SKris Kennaway  */
5874664626SKris Kennaway 
5974664626SKris Kennaway #include <stdio.h>
6074664626SKris Kennaway #include "ssl_locl.h"
6174664626SKris Kennaway 
6274664626SKris Kennaway char *SSL_state_string_long(SSL *s)
6374664626SKris Kennaway 	{
6474664626SKris Kennaway 	char *str;
6574664626SKris Kennaway 
6674664626SKris Kennaway 	switch (s->state)
6774664626SKris Kennaway 		{
6874664626SKris Kennaway case SSL_ST_BEFORE: str="before SSL initialization"; break;
6974664626SKris Kennaway case SSL_ST_ACCEPT: str="before accept initialization"; break;
7074664626SKris Kennaway case SSL_ST_CONNECT: str="before connect initialization"; break;
7174664626SKris Kennaway case SSL_ST_OK: str="SSL negotiation finished successfully"; break;
7274664626SKris Kennaway case SSL_ST_RENEGOTIATE:	str="SSL renegotiate ciphers"; break;
7374664626SKris Kennaway case SSL_ST_BEFORE|SSL_ST_CONNECT: str="before/connect initialization"; break;
7474664626SKris Kennaway case SSL_ST_OK|SSL_ST_CONNECT: str="ok/connect SSL initialization"; break;
7574664626SKris Kennaway case SSL_ST_BEFORE|SSL_ST_ACCEPT: str="before/accept initialization"; break;
7674664626SKris Kennaway case SSL_ST_OK|SSL_ST_ACCEPT: str="ok/accept SSL initialization"; break;
7774664626SKris Kennaway #ifndef NO_SSL2
7874664626SKris Kennaway case SSL2_ST_CLIENT_START_ENCRYPTION: str="SSLv2 client start encryption"; break;
7974664626SKris Kennaway case SSL2_ST_SERVER_START_ENCRYPTION: str="SSLv2 server start encryption"; break;
8074664626SKris Kennaway case SSL2_ST_SEND_CLIENT_HELLO_A: str="SSLv2 write client hello A"; break;
8174664626SKris Kennaway case SSL2_ST_SEND_CLIENT_HELLO_B: str="SSLv2 write client hello B"; break;
8274664626SKris Kennaway case SSL2_ST_GET_SERVER_HELLO_A: str="SSLv2 read server hello A"; break;
8374664626SKris Kennaway case SSL2_ST_GET_SERVER_HELLO_B: str="SSLv2 read server hello B"; break;
8474664626SKris Kennaway case SSL2_ST_SEND_CLIENT_MASTER_KEY_A: str="SSLv2 write client master key A"; break;
8574664626SKris Kennaway case SSL2_ST_SEND_CLIENT_MASTER_KEY_B: str="SSLv2 write client master key B"; break;
8674664626SKris Kennaway case SSL2_ST_SEND_CLIENT_FINISHED_A: str="SSLv2 write client finished A"; break;
8774664626SKris Kennaway case SSL2_ST_SEND_CLIENT_FINISHED_B: str="SSLv2 write client finished B"; break;
8874664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_A: str="SSLv2 write client certificate A"; break;
8974664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_B: str="SSLv2 write client certificate B"; break;
9074664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_C: str="SSLv2 write client certificate C"; break;
9174664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_D: str="SSLv2 write client certificate D"; break;
9274664626SKris Kennaway case SSL2_ST_GET_SERVER_VERIFY_A: str="SSLv2 read server verify A"; break;
9374664626SKris Kennaway case SSL2_ST_GET_SERVER_VERIFY_B: str="SSLv2 read server verify B"; break;
9474664626SKris Kennaway case SSL2_ST_GET_SERVER_FINISHED_A: str="SSLv2 read server finished A"; break;
9574664626SKris Kennaway case SSL2_ST_GET_SERVER_FINISHED_B: str="SSLv2 read server finished B"; break;
9674664626SKris Kennaway case SSL2_ST_GET_CLIENT_HELLO_A: str="SSLv2 read client hello A"; break;
9774664626SKris Kennaway case SSL2_ST_GET_CLIENT_HELLO_B: str="SSLv2 read client hello B"; break;
9874664626SKris Kennaway case SSL2_ST_GET_CLIENT_HELLO_C: str="SSLv2 read client hello C"; break;
9974664626SKris Kennaway case SSL2_ST_SEND_SERVER_HELLO_A: str="SSLv2 write server hello A"; break;
10074664626SKris Kennaway case SSL2_ST_SEND_SERVER_HELLO_B: str="SSLv2 write server hello B"; break;
10174664626SKris Kennaway case SSL2_ST_GET_CLIENT_MASTER_KEY_A: str="SSLv2 read client master key A"; break;
10274664626SKris Kennaway case SSL2_ST_GET_CLIENT_MASTER_KEY_B: str="SSLv2 read client master key B"; break;
10374664626SKris Kennaway case SSL2_ST_SEND_SERVER_VERIFY_A: str="SSLv2 write server verify A"; break;
10474664626SKris Kennaway case SSL2_ST_SEND_SERVER_VERIFY_B: str="SSLv2 write server verify B"; break;
10574664626SKris Kennaway case SSL2_ST_SEND_SERVER_VERIFY_C: str="SSLv2 write server verify C"; break;
10674664626SKris Kennaway case SSL2_ST_GET_CLIENT_FINISHED_A: str="SSLv2 read client finished A"; break;
10774664626SKris Kennaway case SSL2_ST_GET_CLIENT_FINISHED_B: str="SSLv2 read client finished B"; break;
10874664626SKris Kennaway case SSL2_ST_SEND_SERVER_FINISHED_A: str="SSLv2 write server finished A"; break;
10974664626SKris Kennaway case SSL2_ST_SEND_SERVER_FINISHED_B: str="SSLv2 write server finished B"; break;
11074664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_A: str="SSLv2 write request certificate A"; break;
11174664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_B: str="SSLv2 write request certificate B"; break;
11274664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_C: str="SSLv2 write request certificate C"; break;
11374664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_D: str="SSLv2 write request certificate D"; break;
11474664626SKris Kennaway case SSL2_ST_X509_GET_SERVER_CERTIFICATE: str="SSLv2 X509 read server certificate"; break;
11574664626SKris Kennaway case SSL2_ST_X509_GET_CLIENT_CERTIFICATE: str="SSLv2 X509 read client certificate"; break;
11674664626SKris Kennaway #endif
11774664626SKris Kennaway 
11874664626SKris Kennaway #ifndef NO_SSL3
11974664626SKris Kennaway /* SSLv3 additions */
12074664626SKris Kennaway case SSL3_ST_CW_CLNT_HELLO_A:	str="SSLv3 write client hello A"; break;
12174664626SKris Kennaway case SSL3_ST_CW_CLNT_HELLO_B:	str="SSLv3 write client hello B"; break;
12274664626SKris Kennaway case SSL3_ST_CR_SRVR_HELLO_A:	str="SSLv3 read server hello A"; break;
12374664626SKris Kennaway case SSL3_ST_CR_SRVR_HELLO_B:	str="SSLv3 read server hello B"; break;
12474664626SKris Kennaway case SSL3_ST_CR_CERT_A:		str="SSLv3 read server certificate A"; break;
12574664626SKris Kennaway case SSL3_ST_CR_CERT_B:		str="SSLv3 read server certificate B"; break;
12674664626SKris Kennaway case SSL3_ST_CR_KEY_EXCH_A:	str="SSLv3 read server key exchange A"; break;
12774664626SKris Kennaway case SSL3_ST_CR_KEY_EXCH_B:	str="SSLv3 read server key exchange B"; break;
12874664626SKris Kennaway case SSL3_ST_CR_CERT_REQ_A:	str="SSLv3 read server certificate request A"; break;
12974664626SKris Kennaway case SSL3_ST_CR_CERT_REQ_B:	str="SSLv3 read server certificate request B"; break;
13074664626SKris Kennaway case SSL3_ST_CR_SRVR_DONE_A:	str="SSLv3 read server done A"; break;
13174664626SKris Kennaway case SSL3_ST_CR_SRVR_DONE_B:	str="SSLv3 read server done B"; break;
13274664626SKris Kennaway case SSL3_ST_CW_CERT_A:		str="SSLv3 write client certificate A"; break;
13374664626SKris Kennaway case SSL3_ST_CW_CERT_B:		str="SSLv3 write client certificate B"; break;
13474664626SKris Kennaway case SSL3_ST_CW_CERT_C:		str="SSLv3 write client certificate C"; break;
13574664626SKris Kennaway case SSL3_ST_CW_CERT_D:		str="SSLv3 write client certificate D"; break;
13674664626SKris Kennaway case SSL3_ST_CW_KEY_EXCH_A:	str="SSLv3 write client key exchange A"; break;
13774664626SKris Kennaway case SSL3_ST_CW_KEY_EXCH_B:	str="SSLv3 write client key exchange B"; break;
13874664626SKris Kennaway case SSL3_ST_CW_CERT_VRFY_A:	str="SSLv3 write certificate verify A"; break;
139a21b1b38SKris Kennaway case SSL3_ST_CW_CERT_VRFY_B:	str="SSLv3 write certificate verify B"; break;
14074664626SKris Kennaway 
14174664626SKris Kennaway case SSL3_ST_CW_CHANGE_A:
14274664626SKris Kennaway case SSL3_ST_SW_CHANGE_A:	str="SSLv3 write change cipher spec A"; break;
14374664626SKris Kennaway case SSL3_ST_CW_CHANGE_B:
14474664626SKris Kennaway case SSL3_ST_SW_CHANGE_B:	str="SSLv3 write change cipher spec B"; break;
14574664626SKris Kennaway case SSL3_ST_CW_FINISHED_A:
14674664626SKris Kennaway case SSL3_ST_SW_FINISHED_A:	str="SSLv3 write finished A"; break;
14774664626SKris Kennaway case SSL3_ST_CW_FINISHED_B:
148a21b1b38SKris Kennaway case SSL3_ST_SW_FINISHED_B:	str="SSLv3 write finished B"; break;
14974664626SKris Kennaway case SSL3_ST_CR_CHANGE_A:
15074664626SKris Kennaway case SSL3_ST_SR_CHANGE_A:	str="SSLv3 read change cipher spec A"; break;
15174664626SKris Kennaway case SSL3_ST_CR_CHANGE_B:
15274664626SKris Kennaway case SSL3_ST_SR_CHANGE_B:	str="SSLv3 read change cipher spec B"; break;
15374664626SKris Kennaway case SSL3_ST_CR_FINISHED_A:
15474664626SKris Kennaway case SSL3_ST_SR_FINISHED_A:	str="SSLv3 read finished A"; break;
15574664626SKris Kennaway case SSL3_ST_CR_FINISHED_B:
15674664626SKris Kennaway case SSL3_ST_SR_FINISHED_B:	str="SSLv3 read finished B"; break;
15774664626SKris Kennaway 
15874664626SKris Kennaway case SSL3_ST_CW_FLUSH:
15974664626SKris Kennaway case SSL3_ST_SW_FLUSH:		str="SSLv3 flush data"; break;
16074664626SKris Kennaway 
16174664626SKris Kennaway case SSL3_ST_SR_CLNT_HELLO_A:	str="SSLv3 read client hello A"; break;
16274664626SKris Kennaway case SSL3_ST_SR_CLNT_HELLO_B:	str="SSLv3 read client hello B"; break;
16374664626SKris Kennaway case SSL3_ST_SR_CLNT_HELLO_C:	str="SSLv3 read client hello C"; break;
16474664626SKris Kennaway case SSL3_ST_SW_HELLO_REQ_A:	str="SSLv3 write hello request A"; break;
16574664626SKris Kennaway case SSL3_ST_SW_HELLO_REQ_B:	str="SSLv3 write hello request B"; break;
16674664626SKris Kennaway case SSL3_ST_SW_HELLO_REQ_C:	str="SSLv3 write hello request C"; break;
16774664626SKris Kennaway case SSL3_ST_SW_SRVR_HELLO_A:	str="SSLv3 write server hello A"; break;
16874664626SKris Kennaway case SSL3_ST_SW_SRVR_HELLO_B:	str="SSLv3 write server hello B"; break;
16974664626SKris Kennaway case SSL3_ST_SW_CERT_A:		str="SSLv3 write certificate A"; break;
17074664626SKris Kennaway case SSL3_ST_SW_CERT_B:		str="SSLv3 write certificate B"; break;
17174664626SKris Kennaway case SSL3_ST_SW_KEY_EXCH_A:	str="SSLv3 write key exchange A"; break;
17274664626SKris Kennaway case SSL3_ST_SW_KEY_EXCH_B:	str="SSLv3 write key exchange B"; break;
17374664626SKris Kennaway case SSL3_ST_SW_CERT_REQ_A:	str="SSLv3 write certificate request A"; break;
17474664626SKris Kennaway case SSL3_ST_SW_CERT_REQ_B:	str="SSLv3 write certificate request B"; break;
17574664626SKris Kennaway case SSL3_ST_SW_SRVR_DONE_A:	str="SSLv3 write server done A"; break;
17674664626SKris Kennaway case SSL3_ST_SW_SRVR_DONE_B:	str="SSLv3 write server done B"; break;
17774664626SKris Kennaway case SSL3_ST_SR_CERT_A:		str="SSLv3 read client certificate A"; break;
17874664626SKris Kennaway case SSL3_ST_SR_CERT_B:		str="SSLv3 read client certificate B"; break;
17974664626SKris Kennaway case SSL3_ST_SR_KEY_EXCH_A:	str="SSLv3 read client key exchange A"; break;
18074664626SKris Kennaway case SSL3_ST_SR_KEY_EXCH_B:	str="SSLv3 read client key exchange B"; break;
18174664626SKris Kennaway case SSL3_ST_SR_CERT_VRFY_A:	str="SSLv3 read certificate verify A"; break;
18274664626SKris Kennaway case SSL3_ST_SR_CERT_VRFY_B:	str="SSLv3 read certificate verify B"; break;
18374664626SKris Kennaway #endif
18474664626SKris Kennaway 
18574664626SKris Kennaway #if !defined(NO_SSL2) && !defined(NO_SSL3)
186f579bf8eSKris Kennaway /* SSLv2/v3 compatibility states */
18774664626SKris Kennaway /* client */
18874664626SKris Kennaway case SSL23_ST_CW_CLNT_HELLO_A:	str="SSLv2/v3 write client hello A"; break;
18974664626SKris Kennaway case SSL23_ST_CW_CLNT_HELLO_B:	str="SSLv2/v3 write client hello B"; break;
19074664626SKris Kennaway case SSL23_ST_CR_SRVR_HELLO_A:	str="SSLv2/v3 read server hello A"; break;
19174664626SKris Kennaway case SSL23_ST_CR_SRVR_HELLO_B:	str="SSLv2/v3 read server hello B"; break;
19274664626SKris Kennaway /* server */
19374664626SKris Kennaway case SSL23_ST_SR_CLNT_HELLO_A:	str="SSLv2/v3 read client hello A"; break;
19474664626SKris Kennaway case SSL23_ST_SR_CLNT_HELLO_B:	str="SSLv2/v3 read client hello B"; break;
19574664626SKris Kennaway #endif
19674664626SKris Kennaway 
19774664626SKris Kennaway default:	str="unknown state"; break;
19874664626SKris Kennaway 		}
19974664626SKris Kennaway 	return(str);
20074664626SKris Kennaway 	}
20174664626SKris Kennaway 
20274664626SKris Kennaway char *SSL_rstate_string_long(SSL *s)
20374664626SKris Kennaway 	{
20474664626SKris Kennaway 	char *str;
20574664626SKris Kennaway 
20674664626SKris Kennaway 	switch (s->rstate)
20774664626SKris Kennaway 		{
20874664626SKris Kennaway 	case SSL_ST_READ_HEADER: str="read header"; break;
20974664626SKris Kennaway 	case SSL_ST_READ_BODY: str="read body"; break;
21074664626SKris Kennaway 	case SSL_ST_READ_DONE: str="read done"; break;
21174664626SKris Kennaway 	default: str="unknown"; break;
21274664626SKris Kennaway 		}
21374664626SKris Kennaway 	return(str);
21474664626SKris Kennaway 	}
21574664626SKris Kennaway 
21674664626SKris Kennaway char *SSL_state_string(SSL *s)
21774664626SKris Kennaway 	{
21874664626SKris Kennaway 	char *str;
21974664626SKris Kennaway 
22074664626SKris Kennaway 	switch (s->state)
22174664626SKris Kennaway 		{
22274664626SKris Kennaway case SSL_ST_BEFORE:				str="PINIT "; break;
22374664626SKris Kennaway case SSL_ST_ACCEPT:				str="AINIT "; break;
22474664626SKris Kennaway case SSL_ST_CONNECT:				str="CINIT "; break;
22574664626SKris Kennaway case SSL_ST_OK:			 		str="SSLOK "; break;
22674664626SKris Kennaway #ifndef NO_SSL2
22774664626SKris Kennaway case SSL2_ST_CLIENT_START_ENCRYPTION:		str="2CSENC"; break;
22874664626SKris Kennaway case SSL2_ST_SERVER_START_ENCRYPTION:		str="2SSENC"; break;
22974664626SKris Kennaway case SSL2_ST_SEND_CLIENT_HELLO_A:		str="2SCH_A"; break;
23074664626SKris Kennaway case SSL2_ST_SEND_CLIENT_HELLO_B:		str="2SCH_B"; break;
23174664626SKris Kennaway case SSL2_ST_GET_SERVER_HELLO_A:		str="2GSH_A"; break;
23274664626SKris Kennaway case SSL2_ST_GET_SERVER_HELLO_B:		str="2GSH_B"; break;
23374664626SKris Kennaway case SSL2_ST_SEND_CLIENT_MASTER_KEY_A:		str="2SCMKA"; break;
23474664626SKris Kennaway case SSL2_ST_SEND_CLIENT_MASTER_KEY_B:		str="2SCMKB"; break;
23574664626SKris Kennaway case SSL2_ST_SEND_CLIENT_FINISHED_A:		str="2SCF_A"; break;
23674664626SKris Kennaway case SSL2_ST_SEND_CLIENT_FINISHED_B:		str="2SCF_B"; break;
23774664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_A:		str="2SCC_A"; break;
23874664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_B:		str="2SCC_B"; break;
23974664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_C:		str="2SCC_C"; break;
24074664626SKris Kennaway case SSL2_ST_SEND_CLIENT_CERTIFICATE_D:		str="2SCC_D"; break;
24174664626SKris Kennaway case SSL2_ST_GET_SERVER_VERIFY_A:		str="2GSV_A"; break;
24274664626SKris Kennaway case SSL2_ST_GET_SERVER_VERIFY_B:		str="2GSV_B"; break;
24374664626SKris Kennaway case SSL2_ST_GET_SERVER_FINISHED_A:		str="2GSF_A"; break;
24474664626SKris Kennaway case SSL2_ST_GET_SERVER_FINISHED_B:		str="2GSF_B"; break;
24574664626SKris Kennaway case SSL2_ST_GET_CLIENT_HELLO_A:		str="2GCH_A"; break;
24674664626SKris Kennaway case SSL2_ST_GET_CLIENT_HELLO_B:		str="2GCH_B"; break;
24774664626SKris Kennaway case SSL2_ST_GET_CLIENT_HELLO_C:		str="2GCH_C"; break;
24874664626SKris Kennaway case SSL2_ST_SEND_SERVER_HELLO_A:		str="2SSH_A"; break;
24974664626SKris Kennaway case SSL2_ST_SEND_SERVER_HELLO_B:		str="2SSH_B"; break;
25074664626SKris Kennaway case SSL2_ST_GET_CLIENT_MASTER_KEY_A:		str="2GCMKA"; break;
25174664626SKris Kennaway case SSL2_ST_GET_CLIENT_MASTER_KEY_B:		str="2GCMKA"; break;
25274664626SKris Kennaway case SSL2_ST_SEND_SERVER_VERIFY_A:		str="2SSV_A"; break;
25374664626SKris Kennaway case SSL2_ST_SEND_SERVER_VERIFY_B:		str="2SSV_B"; break;
25474664626SKris Kennaway case SSL2_ST_SEND_SERVER_VERIFY_C:		str="2SSV_C"; break;
25574664626SKris Kennaway case SSL2_ST_GET_CLIENT_FINISHED_A:		str="2GCF_A"; break;
25674664626SKris Kennaway case SSL2_ST_GET_CLIENT_FINISHED_B:		str="2GCF_B"; break;
25774664626SKris Kennaway case SSL2_ST_SEND_SERVER_FINISHED_A:		str="2SSF_A"; break;
25874664626SKris Kennaway case SSL2_ST_SEND_SERVER_FINISHED_B:		str="2SSF_B"; break;
25974664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_A:	str="2SRC_A"; break;
26074664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_B:	str="2SRC_B"; break;
26174664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_C:	str="2SRC_C"; break;
26274664626SKris Kennaway case SSL2_ST_SEND_REQUEST_CERTIFICATE_D:	str="2SRC_D"; break;
26374664626SKris Kennaway case SSL2_ST_X509_GET_SERVER_CERTIFICATE:	str="2X9GSC"; break;
26474664626SKris Kennaway case SSL2_ST_X509_GET_CLIENT_CERTIFICATE:	str="2X9GCC"; break;
26574664626SKris Kennaway #endif
26674664626SKris Kennaway 
26774664626SKris Kennaway #ifndef NO_SSL3
26874664626SKris Kennaway /* SSLv3 additions */
26974664626SKris Kennaway case SSL3_ST_SW_FLUSH:
27074664626SKris Kennaway case SSL3_ST_CW_FLUSH:				str="3FLUSH"; break;
27174664626SKris Kennaway case SSL3_ST_CW_CLNT_HELLO_A:			str="3WCH_A"; break;
27274664626SKris Kennaway case SSL3_ST_CW_CLNT_HELLO_B:			str="3WCH_B"; break;
27374664626SKris Kennaway case SSL3_ST_CR_SRVR_HELLO_A:			str="3RSH_A"; break;
27474664626SKris Kennaway case SSL3_ST_CR_SRVR_HELLO_B:			str="3RSH_B"; break;
27574664626SKris Kennaway case SSL3_ST_CR_CERT_A:				str="3RSC_A"; break;
27674664626SKris Kennaway case SSL3_ST_CR_CERT_B:				str="3RSC_B"; break;
27774664626SKris Kennaway case SSL3_ST_CR_KEY_EXCH_A:			str="3RSKEA"; break;
27874664626SKris Kennaway case SSL3_ST_CR_KEY_EXCH_B:			str="3RSKEB"; break;
27974664626SKris Kennaway case SSL3_ST_CR_CERT_REQ_A:			str="3RCR_A"; break;
28074664626SKris Kennaway case SSL3_ST_CR_CERT_REQ_B:			str="3RCR_B"; break;
28174664626SKris Kennaway case SSL3_ST_CR_SRVR_DONE_A:			str="3RSD_A"; break;
28274664626SKris Kennaway case SSL3_ST_CR_SRVR_DONE_B:			str="3RSD_B"; break;
28374664626SKris Kennaway case SSL3_ST_CW_CERT_A:				str="3WCC_A"; break;
28474664626SKris Kennaway case SSL3_ST_CW_CERT_B:				str="3WCC_B"; break;
28574664626SKris Kennaway case SSL3_ST_CW_CERT_C:				str="3WCC_C"; break;
28674664626SKris Kennaway case SSL3_ST_CW_CERT_D:				str="3WCC_D"; break;
28774664626SKris Kennaway case SSL3_ST_CW_KEY_EXCH_A:			str="3WCKEA"; break;
28874664626SKris Kennaway case SSL3_ST_CW_KEY_EXCH_B:			str="3WCKEB"; break;
28974664626SKris Kennaway case SSL3_ST_CW_CERT_VRFY_A:			str="3WCV_A"; break;
29074664626SKris Kennaway case SSL3_ST_CW_CERT_VRFY_B:			str="3WCV_B"; break;
29174664626SKris Kennaway 
29274664626SKris Kennaway case SSL3_ST_SW_CHANGE_A:
29374664626SKris Kennaway case SSL3_ST_CW_CHANGE_A:			str="3WCCSA"; break;
29474664626SKris Kennaway case SSL3_ST_SW_CHANGE_B:
29574664626SKris Kennaway case SSL3_ST_CW_CHANGE_B:			str="3WCCSB"; break;
29674664626SKris Kennaway case SSL3_ST_SW_FINISHED_A:
29774664626SKris Kennaway case SSL3_ST_CW_FINISHED_A:			str="3WFINA"; break;
29874664626SKris Kennaway case SSL3_ST_SW_FINISHED_B:
29974664626SKris Kennaway case SSL3_ST_CW_FINISHED_B:			str="3WFINB"; break;
30074664626SKris Kennaway case SSL3_ST_SR_CHANGE_A:
30174664626SKris Kennaway case SSL3_ST_CR_CHANGE_A:			str="3RCCSA"; break;
30274664626SKris Kennaway case SSL3_ST_SR_CHANGE_B:
30374664626SKris Kennaway case SSL3_ST_CR_CHANGE_B:			str="3RCCSB"; break;
30474664626SKris Kennaway case SSL3_ST_SR_FINISHED_A:
30574664626SKris Kennaway case SSL3_ST_CR_FINISHED_A:			str="3RFINA"; break;
30674664626SKris Kennaway case SSL3_ST_SR_FINISHED_B:
30774664626SKris Kennaway case SSL3_ST_CR_FINISHED_B:			str="3RFINB"; break;
30874664626SKris Kennaway 
30974664626SKris Kennaway case SSL3_ST_SW_HELLO_REQ_A:			str="3WHR_A"; break;
31074664626SKris Kennaway case SSL3_ST_SW_HELLO_REQ_B:			str="3WHR_B"; break;
31174664626SKris Kennaway case SSL3_ST_SW_HELLO_REQ_C:			str="3WHR_C"; break;
31274664626SKris Kennaway case SSL3_ST_SR_CLNT_HELLO_A:			str="3RCH_A"; break;
31374664626SKris Kennaway case SSL3_ST_SR_CLNT_HELLO_B:			str="3RCH_B"; break;
31474664626SKris Kennaway case SSL3_ST_SR_CLNT_HELLO_C:			str="3RCH_C"; break;
31574664626SKris Kennaway case SSL3_ST_SW_SRVR_HELLO_A:			str="3WSH_A"; break;
31674664626SKris Kennaway case SSL3_ST_SW_SRVR_HELLO_B:			str="3WSH_B"; break;
31774664626SKris Kennaway case SSL3_ST_SW_CERT_A:				str="3WSC_A"; break;
31874664626SKris Kennaway case SSL3_ST_SW_CERT_B:				str="3WSC_B"; break;
31974664626SKris Kennaway case SSL3_ST_SW_KEY_EXCH_A:			str="3WSKEA"; break;
32074664626SKris Kennaway case SSL3_ST_SW_KEY_EXCH_B:			str="3WSKEB"; break;
32174664626SKris Kennaway case SSL3_ST_SW_CERT_REQ_A:			str="3WCR_A"; break;
32274664626SKris Kennaway case SSL3_ST_SW_CERT_REQ_B:			str="3WCR_B"; break;
32374664626SKris Kennaway case SSL3_ST_SW_SRVR_DONE_A:			str="3WSD_A"; break;
32474664626SKris Kennaway case SSL3_ST_SW_SRVR_DONE_B:			str="3WSD_B"; break;
32574664626SKris Kennaway case SSL3_ST_SR_CERT_A:				str="3RCC_A"; break;
32674664626SKris Kennaway case SSL3_ST_SR_CERT_B:				str="3RCC_B"; break;
32774664626SKris Kennaway case SSL3_ST_SR_KEY_EXCH_A:			str="3RCKEA"; break;
32874664626SKris Kennaway case SSL3_ST_SR_KEY_EXCH_B:			str="3RCKEB"; break;
32974664626SKris Kennaway case SSL3_ST_SR_CERT_VRFY_A:			str="3RCV_A"; break;
33074664626SKris Kennaway case SSL3_ST_SR_CERT_VRFY_B:			str="3RCV_B"; break;
33174664626SKris Kennaway #endif
33274664626SKris Kennaway 
33374664626SKris Kennaway #if !defined(NO_SSL2) && !defined(NO_SSL3)
334f579bf8eSKris Kennaway /* SSLv2/v3 compatibility states */
33574664626SKris Kennaway /* client */
33674664626SKris Kennaway case SSL23_ST_CW_CLNT_HELLO_A:			str="23WCHA"; break;
33774664626SKris Kennaway case SSL23_ST_CW_CLNT_HELLO_B:			str="23WCHB"; break;
33874664626SKris Kennaway case SSL23_ST_CR_SRVR_HELLO_A:			str="23RSHA"; break;
33974664626SKris Kennaway case SSL23_ST_CR_SRVR_HELLO_B:			str="23RSHA"; break;
34074664626SKris Kennaway /* server */
34174664626SKris Kennaway case SSL23_ST_SR_CLNT_HELLO_A:			str="23RCHA"; break;
34274664626SKris Kennaway case SSL23_ST_SR_CLNT_HELLO_B:			str="23RCHB"; break;
34374664626SKris Kennaway #endif
34474664626SKris Kennaway 
34574664626SKris Kennaway default:					str="UNKWN "; break;
34674664626SKris Kennaway 		}
34774664626SKris Kennaway 	return(str);
34874664626SKris Kennaway 	}
34974664626SKris Kennaway 
35074664626SKris Kennaway char *SSL_alert_type_string_long(int value)
35174664626SKris Kennaway 	{
35274664626SKris Kennaway 	value>>=8;
35374664626SKris Kennaway 	if (value == SSL3_AL_WARNING)
35474664626SKris Kennaway 		return("warning");
35574664626SKris Kennaway 	else if (value == SSL3_AL_FATAL)
35674664626SKris Kennaway 		return("fatal");
35774664626SKris Kennaway 	else
35874664626SKris Kennaway 		return("unknown");
35974664626SKris Kennaway 	}
36074664626SKris Kennaway 
36174664626SKris Kennaway char *SSL_alert_type_string(int value)
36274664626SKris Kennaway 	{
36374664626SKris Kennaway 	value>>=8;
36474664626SKris Kennaway 	if (value == SSL3_AL_WARNING)
36574664626SKris Kennaway 		return("W");
36674664626SKris Kennaway 	else if (value == SSL3_AL_FATAL)
36774664626SKris Kennaway 		return("F");
36874664626SKris Kennaway 	else
36974664626SKris Kennaway 		return("U");
37074664626SKris Kennaway 	}
37174664626SKris Kennaway 
37274664626SKris Kennaway char *SSL_alert_desc_string(int value)
37374664626SKris Kennaway 	{
37474664626SKris Kennaway 	char *str;
37574664626SKris Kennaway 
37674664626SKris Kennaway 	switch (value & 0xff)
37774664626SKris Kennaway 		{
37874664626SKris Kennaway 	case SSL3_AD_CLOSE_NOTIFY:		str="CN"; break;
37974664626SKris Kennaway 	case SSL3_AD_UNEXPECTED_MESSAGE:	str="UM"; break;
38074664626SKris Kennaway 	case SSL3_AD_BAD_RECORD_MAC:		str="BM"; break;
38174664626SKris Kennaway 	case SSL3_AD_DECOMPRESSION_FAILURE:	str="DF"; break;
38274664626SKris Kennaway 	case SSL3_AD_HANDSHAKE_FAILURE:		str="HF"; break;
38374664626SKris Kennaway 	case SSL3_AD_NO_CERTIFICATE:		str="NC"; break;
38474664626SKris Kennaway 	case SSL3_AD_BAD_CERTIFICATE:		str="BC"; break;
38574664626SKris Kennaway 	case SSL3_AD_UNSUPPORTED_CERTIFICATE:	str="UC"; break;
38674664626SKris Kennaway 	case SSL3_AD_CERTIFICATE_REVOKED:	str="CR"; break;
38774664626SKris Kennaway 	case SSL3_AD_CERTIFICATE_EXPIRED:	str="CE"; break;
38874664626SKris Kennaway 	case SSL3_AD_CERTIFICATE_UNKNOWN:	str="CU"; break;
38974664626SKris Kennaway 	case SSL3_AD_ILLEGAL_PARAMETER:		str="IP"; break;
390a21b1b38SKris Kennaway 	case TLS1_AD_DECRYPTION_FAILED:		str="DC"; break;
391a21b1b38SKris Kennaway 	case TLS1_AD_RECORD_OVERFLOW:		str="RO"; break;
392a21b1b38SKris Kennaway 	case TLS1_AD_UNKNOWN_CA:		str="CA"; break;
393a21b1b38SKris Kennaway 	case TLS1_AD_ACCESS_DENIED:		str="AD"; break;
394a21b1b38SKris Kennaway 	case TLS1_AD_DECODE_ERROR:		str="DE"; break;
395a21b1b38SKris Kennaway 	case TLS1_AD_DECRYPT_ERROR:		str="CY"; break;
396a21b1b38SKris Kennaway 	case TLS1_AD_EXPORT_RESTRICTION:	str="ER"; break;
397a21b1b38SKris Kennaway 	case TLS1_AD_PROTOCOL_VERSION:		str="PV"; break;
398a21b1b38SKris Kennaway 	case TLS1_AD_INSUFFICIENT_SECURITY:	str="IS"; break;
399a21b1b38SKris Kennaway 	case TLS1_AD_INTERNAL_ERROR:		str="IE"; break;
400a21b1b38SKris Kennaway 	case TLS1_AD_USER_CANCELLED:		str="US"; break;
401a21b1b38SKris Kennaway 	case TLS1_AD_NO_RENEGOTIATION:		str="NR"; break;
40274664626SKris Kennaway 	default:				str="UK"; break;
40374664626SKris Kennaway 		}
40474664626SKris Kennaway 	return(str);
40574664626SKris Kennaway 	}
40674664626SKris Kennaway 
40774664626SKris Kennaway char *SSL_alert_desc_string_long(int value)
40874664626SKris Kennaway 	{
40974664626SKris Kennaway 	char *str;
41074664626SKris Kennaway 
41174664626SKris Kennaway 	switch (value & 0xff)
41274664626SKris Kennaway 		{
41374664626SKris Kennaway 	case SSL3_AD_CLOSE_NOTIFY:
41474664626SKris Kennaway 		str="close notify";
41574664626SKris Kennaway 		break;
41674664626SKris Kennaway 	case SSL3_AD_UNEXPECTED_MESSAGE:
417f579bf8eSKris Kennaway 		str="unexpected_message";
41874664626SKris Kennaway 		break;
41974664626SKris Kennaway 	case SSL3_AD_BAD_RECORD_MAC:
42074664626SKris Kennaway 		str="bad record mac";
42174664626SKris Kennaway 		break;
42274664626SKris Kennaway 	case SSL3_AD_DECOMPRESSION_FAILURE:
42374664626SKris Kennaway 		str="decompression failure";
42474664626SKris Kennaway 		break;
42574664626SKris Kennaway 	case SSL3_AD_HANDSHAKE_FAILURE:
42674664626SKris Kennaway 		str="handshake failure";
42774664626SKris Kennaway 		break;
42874664626SKris Kennaway 	case SSL3_AD_NO_CERTIFICATE:
42974664626SKris Kennaway 		str="no certificate";
43074664626SKris Kennaway 		break;
43174664626SKris Kennaway 	case SSL3_AD_BAD_CERTIFICATE:
43274664626SKris Kennaway 		str="bad certificate";
43374664626SKris Kennaway 		break;
43474664626SKris Kennaway 	case SSL3_AD_UNSUPPORTED_CERTIFICATE:
43574664626SKris Kennaway 		str="unsupported certificate";
43674664626SKris Kennaway 		break;
43774664626SKris Kennaway 	case SSL3_AD_CERTIFICATE_REVOKED:
43874664626SKris Kennaway 		str="certificate revoked";
43974664626SKris Kennaway 		break;
44074664626SKris Kennaway 	case SSL3_AD_CERTIFICATE_EXPIRED:
44174664626SKris Kennaway 		str="certificate expired";
44274664626SKris Kennaway 		break;
44374664626SKris Kennaway 	case SSL3_AD_CERTIFICATE_UNKNOWN:
444f579bf8eSKris Kennaway 		str="certificate unknown";
44574664626SKris Kennaway 		break;
44674664626SKris Kennaway 	case SSL3_AD_ILLEGAL_PARAMETER:
44774664626SKris Kennaway 		str="illegal parameter";
44874664626SKris Kennaway 		break;
449a21b1b38SKris Kennaway 	case TLS1_AD_DECRYPTION_FAILED:
450a21b1b38SKris Kennaway 		str="decryption failed";
451a21b1b38SKris Kennaway 		break;
452a21b1b38SKris Kennaway 	case TLS1_AD_RECORD_OVERFLOW:
453a21b1b38SKris Kennaway 		str="record overflow";
454a21b1b38SKris Kennaway 		break;
455a21b1b38SKris Kennaway 	case TLS1_AD_UNKNOWN_CA:
456a21b1b38SKris Kennaway 		str="unknown CA";
457a21b1b38SKris Kennaway 		break;
458a21b1b38SKris Kennaway 	case TLS1_AD_ACCESS_DENIED:
459a21b1b38SKris Kennaway 		str="access denied";
460a21b1b38SKris Kennaway 		break;
461a21b1b38SKris Kennaway 	case TLS1_AD_DECODE_ERROR:
462a21b1b38SKris Kennaway 		str="decode error";
463a21b1b38SKris Kennaway 		break;
464a21b1b38SKris Kennaway 	case TLS1_AD_DECRYPT_ERROR:
465a21b1b38SKris Kennaway 		str="decrypt error";
466a21b1b38SKris Kennaway 		break;
467a21b1b38SKris Kennaway 	case TLS1_AD_EXPORT_RESTRICTION:
468a21b1b38SKris Kennaway 		str="export restriction";
469a21b1b38SKris Kennaway 		break;
470a21b1b38SKris Kennaway 	case TLS1_AD_PROTOCOL_VERSION:
471a21b1b38SKris Kennaway 		str="protocol version";
472a21b1b38SKris Kennaway 		break;
473a21b1b38SKris Kennaway 	case TLS1_AD_INSUFFICIENT_SECURITY:
474a21b1b38SKris Kennaway 		str="insufficient security";
475a21b1b38SKris Kennaway 		break;
476a21b1b38SKris Kennaway 	case TLS1_AD_INTERNAL_ERROR:
477a21b1b38SKris Kennaway 		str="internal error";
478a21b1b38SKris Kennaway 		break;
479a21b1b38SKris Kennaway 	case TLS1_AD_USER_CANCELLED:
480a21b1b38SKris Kennaway 		str="user canceled";
481a21b1b38SKris Kennaway 		break;
482a21b1b38SKris Kennaway 	case TLS1_AD_NO_RENEGOTIATION:
483a21b1b38SKris Kennaway 		str="no renegotiation";
484a21b1b38SKris Kennaway 		break;
48574664626SKris Kennaway 	default: str="unknown"; break;
48674664626SKris Kennaway 		}
48774664626SKris Kennaway 	return(str);
48874664626SKris Kennaway 	}
48974664626SKris Kennaway 
49074664626SKris Kennaway char *SSL_rstate_string(SSL *s)
49174664626SKris Kennaway 	{
49274664626SKris Kennaway 	char *str;
49374664626SKris Kennaway 
49474664626SKris Kennaway 	switch (s->rstate)
49574664626SKris Kennaway 		{
49674664626SKris Kennaway 	case SSL_ST_READ_HEADER:str="RH"; break;
49774664626SKris Kennaway 	case SSL_ST_READ_BODY:	str="RB"; break;
49874664626SKris Kennaway 	case SSL_ST_READ_DONE:	str="RD"; break;
49974664626SKris Kennaway 	default: str="unknown"; break;
50074664626SKris Kennaway 		}
50174664626SKris Kennaway 	return(str);
50274664626SKris Kennaway 	}
503