os/ossrv/ssl/libcrypto/inc/include/openssl/ssl2.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ssl/libcrypto/inc/include/openssl/ssl2.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,272 @@
     1.4 +/* ssl/ssl2.h */
     1.5 +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
     1.6 + * All rights reserved.
     1.7 + *
     1.8 + * This package is an SSL implementation written
     1.9 + * by Eric Young (eay@cryptsoft.com).
    1.10 + * The implementation was written so as to conform with Netscapes SSL.
    1.11 + * 
    1.12 + * This library is free for commercial and non-commercial use as long as
    1.13 + * the following conditions are aheared to.  The following conditions
    1.14 + * apply to all code found in this distribution, be it the RC4, RSA,
    1.15 + * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
    1.16 + * included with this distribution is covered by the same copyright terms
    1.17 + * except that the holder is Tim Hudson (tjh@cryptsoft.com).
    1.18 + * 
    1.19 + * Copyright remains Eric Young's, and as such any Copyright notices in
    1.20 + * the code are not to be removed.
    1.21 + * If this package is used in a product, Eric Young should be given attribution
    1.22 + * as the author of the parts of the library used.
    1.23 + * This can be in the form of a textual message at program startup or
    1.24 + * in documentation (online or textual) provided with the package.
    1.25 + * 
    1.26 + * Redistribution and use in source and binary forms, with or without
    1.27 + * modification, are permitted provided that the following conditions
    1.28 + * are met:
    1.29 + * 1. Redistributions of source code must retain the copyright
    1.30 + *    notice, this list of conditions and the following disclaimer.
    1.31 + * 2. Redistributions in binary form must reproduce the above copyright
    1.32 + *    notice, this list of conditions and the following disclaimer in the
    1.33 + *    documentation and/or other materials provided with the distribution.
    1.34 + * 3. All advertising materials mentioning features or use of this software
    1.35 + *    must display the following acknowledgement:
    1.36 + *    "This product includes cryptographic software written by
    1.37 + *     Eric Young (eay@cryptsoft.com)"
    1.38 + *    The word 'cryptographic' can be left out if the rouines from the library
    1.39 + *    being used are not cryptographic related :-).
    1.40 + * 4. If you include any Windows specific code (or a derivative thereof) from 
    1.41 + *    the apps directory (application code) you must include an acknowledgement:
    1.42 + *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
    1.43 + * 
    1.44 + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
    1.45 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.46 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.47 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    1.48 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.49 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.50 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.51 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.52 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.53 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.54 + * SUCH DAMAGE.
    1.55 + * 
    1.56 + * The licence and distribution terms for any publically available version or
    1.57 + * derivative of this code cannot be changed.  i.e. this code cannot simply be
    1.58 + * copied and put under another distribution licence
    1.59 + * [including the GNU Public Licence.]
    1.60 + */
    1.61 +
    1.62 +#ifndef HEADER_SSL2_H 
    1.63 +#define HEADER_SSL2_H 
    1.64 +
    1.65 +#if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
    1.66 +#define SYMBIAN
    1.67 +#endif
    1.68 +
    1.69 +#ifdef  __cplusplus
    1.70 +extern "C" {
    1.71 +#endif
    1.72 +
    1.73 +/* Protocol Version Codes */
    1.74 +#define SSL2_VERSION		0x0002
    1.75 +#define SSL2_VERSION_MAJOR	0x00
    1.76 +#define SSL2_VERSION_MINOR	0x02
    1.77 +/* #define SSL2_CLIENT_VERSION	0x0002 */
    1.78 +/* #define SSL2_SERVER_VERSION	0x0002 */
    1.79 +
    1.80 +/* Protocol Message Codes */
    1.81 +#define SSL2_MT_ERROR			0
    1.82 +#define SSL2_MT_CLIENT_HELLO		1
    1.83 +#define SSL2_MT_CLIENT_MASTER_KEY	2
    1.84 +#define SSL2_MT_CLIENT_FINISHED		3
    1.85 +#define SSL2_MT_SERVER_HELLO		4
    1.86 +#define SSL2_MT_SERVER_VERIFY		5
    1.87 +#define SSL2_MT_SERVER_FINISHED		6
    1.88 +#define SSL2_MT_REQUEST_CERTIFICATE	7
    1.89 +#define SSL2_MT_CLIENT_CERTIFICATE	8
    1.90 +
    1.91 +/* Error Message Codes */
    1.92 +#define SSL2_PE_UNDEFINED_ERROR		0x0000
    1.93 +#define SSL2_PE_NO_CIPHER		0x0001
    1.94 +#define SSL2_PE_NO_CERTIFICATE		0x0002
    1.95 +#define SSL2_PE_BAD_CERTIFICATE		0x0004
    1.96 +#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006
    1.97 +
    1.98 +/* Cipher Kind Values */
    1.99 +#define SSL2_CK_NULL_WITH_MD5			0x02000000 /* v3 */
   1.100 +#define SSL2_CK_RC4_128_WITH_MD5		0x02010080
   1.101 +#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5	0x02020080
   1.102 +#define SSL2_CK_RC2_128_CBC_WITH_MD5		0x02030080
   1.103 +#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5	0x02040080
   1.104 +#define SSL2_CK_IDEA_128_CBC_WITH_MD5		0x02050080
   1.105 +#define SSL2_CK_DES_64_CBC_WITH_MD5		0x02060040
   1.106 +#define SSL2_CK_DES_64_CBC_WITH_SHA		0x02060140 /* v3 */
   1.107 +#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5	0x020700c0
   1.108 +#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA	0x020701c0 /* v3 */
   1.109 +#define SSL2_CK_RC4_64_WITH_MD5			0x02080080 /* MS hack */
   1.110 + 
   1.111 +#define SSL2_CK_DES_64_CFB64_WITH_MD5_1		0x02ff0800 /* SSLeay */
   1.112 +#define SSL2_CK_NULL				0x02ff0810 /* SSLeay */
   1.113 +
   1.114 +#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1	"DES-CFB-M1"
   1.115 +#define SSL2_TXT_NULL_WITH_MD5			"NULL-MD5"
   1.116 +#define SSL2_TXT_RC4_128_WITH_MD5		"RC4-MD5"
   1.117 +#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5	"EXP-RC4-MD5"
   1.118 +#define SSL2_TXT_RC2_128_CBC_WITH_MD5		"RC2-CBC-MD5"
   1.119 +#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5	"EXP-RC2-CBC-MD5"
   1.120 +#define SSL2_TXT_IDEA_128_CBC_WITH_MD5		"IDEA-CBC-MD5"
   1.121 +#define SSL2_TXT_DES_64_CBC_WITH_MD5		"DES-CBC-MD5"
   1.122 +#define SSL2_TXT_DES_64_CBC_WITH_SHA		"DES-CBC-SHA"
   1.123 +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5	"DES-CBC3-MD5"
   1.124 +#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA	"DES-CBC3-SHA"
   1.125 +#define SSL2_TXT_RC4_64_WITH_MD5		"RC4-64-MD5"
   1.126 +
   1.127 +#define SSL2_TXT_NULL				"NULL"
   1.128 +
   1.129 +/* Flags for the SSL_CIPHER.algorithm2 field */
   1.130 +#define SSL2_CF_5_BYTE_ENC			0x01
   1.131 +#define SSL2_CF_8_BYTE_ENC			0x02
   1.132 +
   1.133 +/* Certificate Type Codes */
   1.134 +#define SSL2_CT_X509_CERTIFICATE		0x01
   1.135 +
   1.136 +/* Authentication Type Code */
   1.137 +#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION		0x01
   1.138 +
   1.139 +#define SSL2_MAX_SSL_SESSION_ID_LENGTH		32
   1.140 +
   1.141 +/* Upper/Lower Bounds */
   1.142 +#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS	256
   1.143 +#ifdef OPENSSL_SYS_MPE
   1.144 +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER	29998u
   1.145 +#else
   1.146 +#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER	32767u  /* 2^15-1 */
   1.147 +#endif
   1.148 +#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER	16383 /* 2^14-1 */
   1.149 +
   1.150 +#define SSL2_CHALLENGE_LENGTH	16
   1.151 +/*#define SSL2_CHALLENGE_LENGTH	32 */
   1.152 +#define SSL2_MIN_CHALLENGE_LENGTH	16
   1.153 +#define SSL2_MAX_CHALLENGE_LENGTH	32
   1.154 +#define SSL2_CONNECTION_ID_LENGTH	16
   1.155 +#define SSL2_MAX_CONNECTION_ID_LENGTH	16
   1.156 +#define SSL2_SSL_SESSION_ID_LENGTH	16
   1.157 +#define SSL2_MAX_CERT_CHALLENGE_LENGTH	32
   1.158 +#define SSL2_MIN_CERT_CHALLENGE_LENGTH	16
   1.159 +#define SSL2_MAX_KEY_MATERIAL_LENGTH	24
   1.160 +
   1.161 +#ifndef HEADER_SSL_LOCL_H
   1.162 +#define  CERT		char
   1.163 +#endif
   1.164 +
   1.165 +typedef struct ssl2_state_st
   1.166 +	{
   1.167 +	int three_byte_header;
   1.168 +	int clear_text;		/* clear text */
   1.169 +	int escape;		/* not used in SSLv2 */
   1.170 +	int ssl2_rollback;	/* used if SSLv23 rolled back to SSLv2 */
   1.171 +
   1.172 +	/* non-blocking io info, used to make sure the same
   1.173 +	 * args were passwd */
   1.174 +	unsigned int wnum;	/* number of bytes sent so far */
   1.175 +	int wpend_tot;
   1.176 +	const unsigned char *wpend_buf;
   1.177 +
   1.178 +	int wpend_off;	/* offset to data to write */
   1.179 +	int wpend_len; 	/* number of bytes passwd to write */
   1.180 +	int wpend_ret; 	/* number of bytes to return to caller */
   1.181 +
   1.182 +	/* buffer raw data */
   1.183 +	int rbuf_left;
   1.184 +	int rbuf_offs;
   1.185 +	unsigned char *rbuf;
   1.186 +	unsigned char *wbuf;
   1.187 +
   1.188 +	unsigned char *write_ptr;/* used to point to the start due to
   1.189 +				  * 2/3 byte header. */
   1.190 +
   1.191 +	unsigned int padding;
   1.192 +	unsigned int rlength; /* passed to ssl2_enc */
   1.193 +	int ract_data_length; /* Set when things are encrypted. */
   1.194 +	unsigned int wlength; /* passed to ssl2_enc */
   1.195 +	int wact_data_length; /* Set when things are decrypted. */
   1.196 +	unsigned char *ract_data;
   1.197 +	unsigned char *wact_data;
   1.198 +	unsigned char *mac_data;
   1.199 +
   1.200 +	unsigned char *read_key;
   1.201 +	unsigned char *write_key;
   1.202 +
   1.203 +		/* Stuff specifically to do with this SSL session */
   1.204 +	unsigned int challenge_length;
   1.205 +	unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];
   1.206 +	unsigned int conn_id_length;
   1.207 +	unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];
   1.208 +	unsigned int key_material_length;
   1.209 +	unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2];
   1.210 +
   1.211 +	unsigned long read_sequence;
   1.212 +	unsigned long write_sequence;
   1.213 +
   1.214 +	struct	{
   1.215 +		unsigned int conn_id_length;
   1.216 +		unsigned int cert_type;	
   1.217 +		unsigned int cert_length;
   1.218 +		unsigned int csl; 
   1.219 +		unsigned int clear;
   1.220 +		unsigned int enc; 
   1.221 +		unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];
   1.222 +		unsigned int cipher_spec_length;
   1.223 +		unsigned int session_id_length;
   1.224 +		unsigned int clen;
   1.225 +		unsigned int rlen;
   1.226 +		} tmp;
   1.227 +	} SSL2_STATE;
   1.228 +
   1.229 +/* SSLv2 */
   1.230 +/* client */
   1.231 +#define SSL2_ST_SEND_CLIENT_HELLO_A		(0x10|SSL_ST_CONNECT)
   1.232 +#define SSL2_ST_SEND_CLIENT_HELLO_B		(0x11|SSL_ST_CONNECT)
   1.233 +#define SSL2_ST_GET_SERVER_HELLO_A		(0x20|SSL_ST_CONNECT)
   1.234 +#define SSL2_ST_GET_SERVER_HELLO_B		(0x21|SSL_ST_CONNECT)
   1.235 +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A	(0x30|SSL_ST_CONNECT)
   1.236 +#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B	(0x31|SSL_ST_CONNECT)
   1.237 +#define SSL2_ST_SEND_CLIENT_FINISHED_A		(0x40|SSL_ST_CONNECT)
   1.238 +#define SSL2_ST_SEND_CLIENT_FINISHED_B		(0x41|SSL_ST_CONNECT)
   1.239 +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A	(0x50|SSL_ST_CONNECT)
   1.240 +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B	(0x51|SSL_ST_CONNECT)
   1.241 +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C	(0x52|SSL_ST_CONNECT)
   1.242 +#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D	(0x53|SSL_ST_CONNECT)
   1.243 +#define SSL2_ST_GET_SERVER_VERIFY_A		(0x60|SSL_ST_CONNECT)
   1.244 +#define SSL2_ST_GET_SERVER_VERIFY_B		(0x61|SSL_ST_CONNECT)
   1.245 +#define SSL2_ST_GET_SERVER_FINISHED_A		(0x70|SSL_ST_CONNECT)
   1.246 +#define SSL2_ST_GET_SERVER_FINISHED_B		(0x71|SSL_ST_CONNECT)
   1.247 +#define SSL2_ST_CLIENT_START_ENCRYPTION		(0x80|SSL_ST_CONNECT)
   1.248 +#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE	(0x90|SSL_ST_CONNECT)
   1.249 +/* server */
   1.250 +#define SSL2_ST_GET_CLIENT_HELLO_A		(0x10|SSL_ST_ACCEPT)
   1.251 +#define SSL2_ST_GET_CLIENT_HELLO_B		(0x11|SSL_ST_ACCEPT)
   1.252 +#define SSL2_ST_GET_CLIENT_HELLO_C		(0x12|SSL_ST_ACCEPT)
   1.253 +#define SSL2_ST_SEND_SERVER_HELLO_A		(0x20|SSL_ST_ACCEPT)
   1.254 +#define SSL2_ST_SEND_SERVER_HELLO_B		(0x21|SSL_ST_ACCEPT)
   1.255 +#define SSL2_ST_GET_CLIENT_MASTER_KEY_A		(0x30|SSL_ST_ACCEPT)
   1.256 +#define SSL2_ST_GET_CLIENT_MASTER_KEY_B		(0x31|SSL_ST_ACCEPT)
   1.257 +#define SSL2_ST_SEND_SERVER_VERIFY_A		(0x40|SSL_ST_ACCEPT)
   1.258 +#define SSL2_ST_SEND_SERVER_VERIFY_B		(0x41|SSL_ST_ACCEPT)
   1.259 +#define SSL2_ST_SEND_SERVER_VERIFY_C		(0x42|SSL_ST_ACCEPT)
   1.260 +#define SSL2_ST_GET_CLIENT_FINISHED_A		(0x50|SSL_ST_ACCEPT)
   1.261 +#define SSL2_ST_GET_CLIENT_FINISHED_B		(0x51|SSL_ST_ACCEPT)
   1.262 +#define SSL2_ST_SEND_SERVER_FINISHED_A		(0x60|SSL_ST_ACCEPT)
   1.263 +#define SSL2_ST_SEND_SERVER_FINISHED_B		(0x61|SSL_ST_ACCEPT)
   1.264 +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A	(0x70|SSL_ST_ACCEPT)
   1.265 +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B	(0x71|SSL_ST_ACCEPT)
   1.266 +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C	(0x72|SSL_ST_ACCEPT)
   1.267 +#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D	(0x73|SSL_ST_ACCEPT)
   1.268 +#define SSL2_ST_SERVER_START_ENCRYPTION		(0x80|SSL_ST_ACCEPT)
   1.269 +#define SSL2_ST_X509_GET_SERVER_CERTIFICATE	(0x90|SSL_ST_ACCEPT)
   1.270 +
   1.271 +#ifdef  __cplusplus
   1.272 +}
   1.273 +#endif
   1.274 +#endif
   1.275 +