os/ossrv/ssl/libcrypto/inc/include/openssl/ssl2.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/* ssl/ssl2.h */
sl@0
     2
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
sl@0
     3
 * All rights reserved.
sl@0
     4
 *
sl@0
     5
 * This package is an SSL implementation written
sl@0
     6
 * by Eric Young (eay@cryptsoft.com).
sl@0
     7
 * The implementation was written so as to conform with Netscapes SSL.
sl@0
     8
 * 
sl@0
     9
 * This library is free for commercial and non-commercial use as long as
sl@0
    10
 * the following conditions are aheared to.  The following conditions
sl@0
    11
 * apply to all code found in this distribution, be it the RC4, RSA,
sl@0
    12
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
sl@0
    13
 * included with this distribution is covered by the same copyright terms
sl@0
    14
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
sl@0
    15
 * 
sl@0
    16
 * Copyright remains Eric Young's, and as such any Copyright notices in
sl@0
    17
 * the code are not to be removed.
sl@0
    18
 * If this package is used in a product, Eric Young should be given attribution
sl@0
    19
 * as the author of the parts of the library used.
sl@0
    20
 * This can be in the form of a textual message at program startup or
sl@0
    21
 * in documentation (online or textual) provided with the package.
sl@0
    22
 * 
sl@0
    23
 * Redistribution and use in source and binary forms, with or without
sl@0
    24
 * modification, are permitted provided that the following conditions
sl@0
    25
 * are met:
sl@0
    26
 * 1. Redistributions of source code must retain the copyright
sl@0
    27
 *    notice, this list of conditions and the following disclaimer.
sl@0
    28
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    29
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    30
 *    documentation and/or other materials provided with the distribution.
sl@0
    31
 * 3. All advertising materials mentioning features or use of this software
sl@0
    32
 *    must display the following acknowledgement:
sl@0
    33
 *    "This product includes cryptographic software written by
sl@0
    34
 *     Eric Young (eay@cryptsoft.com)"
sl@0
    35
 *    The word 'cryptographic' can be left out if the rouines from the library
sl@0
    36
 *    being used are not cryptographic related :-).
sl@0
    37
 * 4. If you include any Windows specific code (or a derivative thereof) from 
sl@0
    38
 *    the apps directory (application code) you must include an acknowledgement:
sl@0
    39
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
sl@0
    40
 * 
sl@0
    41
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
sl@0
    42
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    43
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    44
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
sl@0
    45
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    46
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    47
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    49
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    50
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    51
 * SUCH DAMAGE.
sl@0
    52
 * 
sl@0
    53
 * The licence and distribution terms for any publically available version or
sl@0
    54
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
sl@0
    55
 * copied and put under another distribution licence
sl@0
    56
 * [including the GNU Public Licence.]
sl@0
    57
 */
sl@0
    58
sl@0
    59
#ifndef HEADER_SSL2_H 
sl@0
    60
#define HEADER_SSL2_H 
sl@0
    61
sl@0
    62
#if (defined(__SYMBIAN32__) && !defined(SYMBIAN))
sl@0
    63
#define SYMBIAN
sl@0
    64
#endif
sl@0
    65
sl@0
    66
#ifdef  __cplusplus
sl@0
    67
extern "C" {
sl@0
    68
#endif
sl@0
    69
sl@0
    70
/* Protocol Version Codes */
sl@0
    71
#define SSL2_VERSION		0x0002
sl@0
    72
#define SSL2_VERSION_MAJOR	0x00
sl@0
    73
#define SSL2_VERSION_MINOR	0x02
sl@0
    74
/* #define SSL2_CLIENT_VERSION	0x0002 */
sl@0
    75
/* #define SSL2_SERVER_VERSION	0x0002 */
sl@0
    76
sl@0
    77
/* Protocol Message Codes */
sl@0
    78
#define SSL2_MT_ERROR			0
sl@0
    79
#define SSL2_MT_CLIENT_HELLO		1
sl@0
    80
#define SSL2_MT_CLIENT_MASTER_KEY	2
sl@0
    81
#define SSL2_MT_CLIENT_FINISHED		3
sl@0
    82
#define SSL2_MT_SERVER_HELLO		4
sl@0
    83
#define SSL2_MT_SERVER_VERIFY		5
sl@0
    84
#define SSL2_MT_SERVER_FINISHED		6
sl@0
    85
#define SSL2_MT_REQUEST_CERTIFICATE	7
sl@0
    86
#define SSL2_MT_CLIENT_CERTIFICATE	8
sl@0
    87
sl@0
    88
/* Error Message Codes */
sl@0
    89
#define SSL2_PE_UNDEFINED_ERROR		0x0000
sl@0
    90
#define SSL2_PE_NO_CIPHER		0x0001
sl@0
    91
#define SSL2_PE_NO_CERTIFICATE		0x0002
sl@0
    92
#define SSL2_PE_BAD_CERTIFICATE		0x0004
sl@0
    93
#define SSL2_PE_UNSUPPORTED_CERTIFICATE_TYPE 0x0006
sl@0
    94
sl@0
    95
/* Cipher Kind Values */
sl@0
    96
#define SSL2_CK_NULL_WITH_MD5			0x02000000 /* v3 */
sl@0
    97
#define SSL2_CK_RC4_128_WITH_MD5		0x02010080
sl@0
    98
#define SSL2_CK_RC4_128_EXPORT40_WITH_MD5	0x02020080
sl@0
    99
#define SSL2_CK_RC2_128_CBC_WITH_MD5		0x02030080
sl@0
   100
#define SSL2_CK_RC2_128_CBC_EXPORT40_WITH_MD5	0x02040080
sl@0
   101
#define SSL2_CK_IDEA_128_CBC_WITH_MD5		0x02050080
sl@0
   102
#define SSL2_CK_DES_64_CBC_WITH_MD5		0x02060040
sl@0
   103
#define SSL2_CK_DES_64_CBC_WITH_SHA		0x02060140 /* v3 */
sl@0
   104
#define SSL2_CK_DES_192_EDE3_CBC_WITH_MD5	0x020700c0
sl@0
   105
#define SSL2_CK_DES_192_EDE3_CBC_WITH_SHA	0x020701c0 /* v3 */
sl@0
   106
#define SSL2_CK_RC4_64_WITH_MD5			0x02080080 /* MS hack */
sl@0
   107
 
sl@0
   108
#define SSL2_CK_DES_64_CFB64_WITH_MD5_1		0x02ff0800 /* SSLeay */
sl@0
   109
#define SSL2_CK_NULL				0x02ff0810 /* SSLeay */
sl@0
   110
sl@0
   111
#define SSL2_TXT_DES_64_CFB64_WITH_MD5_1	"DES-CFB-M1"
sl@0
   112
#define SSL2_TXT_NULL_WITH_MD5			"NULL-MD5"
sl@0
   113
#define SSL2_TXT_RC4_128_WITH_MD5		"RC4-MD5"
sl@0
   114
#define SSL2_TXT_RC4_128_EXPORT40_WITH_MD5	"EXP-RC4-MD5"
sl@0
   115
#define SSL2_TXT_RC2_128_CBC_WITH_MD5		"RC2-CBC-MD5"
sl@0
   116
#define SSL2_TXT_RC2_128_CBC_EXPORT40_WITH_MD5	"EXP-RC2-CBC-MD5"
sl@0
   117
#define SSL2_TXT_IDEA_128_CBC_WITH_MD5		"IDEA-CBC-MD5"
sl@0
   118
#define SSL2_TXT_DES_64_CBC_WITH_MD5		"DES-CBC-MD5"
sl@0
   119
#define SSL2_TXT_DES_64_CBC_WITH_SHA		"DES-CBC-SHA"
sl@0
   120
#define SSL2_TXT_DES_192_EDE3_CBC_WITH_MD5	"DES-CBC3-MD5"
sl@0
   121
#define SSL2_TXT_DES_192_EDE3_CBC_WITH_SHA	"DES-CBC3-SHA"
sl@0
   122
#define SSL2_TXT_RC4_64_WITH_MD5		"RC4-64-MD5"
sl@0
   123
sl@0
   124
#define SSL2_TXT_NULL				"NULL"
sl@0
   125
sl@0
   126
/* Flags for the SSL_CIPHER.algorithm2 field */
sl@0
   127
#define SSL2_CF_5_BYTE_ENC			0x01
sl@0
   128
#define SSL2_CF_8_BYTE_ENC			0x02
sl@0
   129
sl@0
   130
/* Certificate Type Codes */
sl@0
   131
#define SSL2_CT_X509_CERTIFICATE		0x01
sl@0
   132
sl@0
   133
/* Authentication Type Code */
sl@0
   134
#define SSL2_AT_MD5_WITH_RSA_ENCRYPTION		0x01
sl@0
   135
sl@0
   136
#define SSL2_MAX_SSL_SESSION_ID_LENGTH		32
sl@0
   137
sl@0
   138
/* Upper/Lower Bounds */
sl@0
   139
#define SSL2_MAX_MASTER_KEY_LENGTH_IN_BITS	256
sl@0
   140
#ifdef OPENSSL_SYS_MPE
sl@0
   141
#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER	29998u
sl@0
   142
#else
sl@0
   143
#define SSL2_MAX_RECORD_LENGTH_2_BYTE_HEADER	32767u  /* 2^15-1 */
sl@0
   144
#endif
sl@0
   145
#define SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER	16383 /* 2^14-1 */
sl@0
   146
sl@0
   147
#define SSL2_CHALLENGE_LENGTH	16
sl@0
   148
/*#define SSL2_CHALLENGE_LENGTH	32 */
sl@0
   149
#define SSL2_MIN_CHALLENGE_LENGTH	16
sl@0
   150
#define SSL2_MAX_CHALLENGE_LENGTH	32
sl@0
   151
#define SSL2_CONNECTION_ID_LENGTH	16
sl@0
   152
#define SSL2_MAX_CONNECTION_ID_LENGTH	16
sl@0
   153
#define SSL2_SSL_SESSION_ID_LENGTH	16
sl@0
   154
#define SSL2_MAX_CERT_CHALLENGE_LENGTH	32
sl@0
   155
#define SSL2_MIN_CERT_CHALLENGE_LENGTH	16
sl@0
   156
#define SSL2_MAX_KEY_MATERIAL_LENGTH	24
sl@0
   157
sl@0
   158
#ifndef HEADER_SSL_LOCL_H
sl@0
   159
#define  CERT		char
sl@0
   160
#endif
sl@0
   161
sl@0
   162
typedef struct ssl2_state_st
sl@0
   163
	{
sl@0
   164
	int three_byte_header;
sl@0
   165
	int clear_text;		/* clear text */
sl@0
   166
	int escape;		/* not used in SSLv2 */
sl@0
   167
	int ssl2_rollback;	/* used if SSLv23 rolled back to SSLv2 */
sl@0
   168
sl@0
   169
	/* non-blocking io info, used to make sure the same
sl@0
   170
	 * args were passwd */
sl@0
   171
	unsigned int wnum;	/* number of bytes sent so far */
sl@0
   172
	int wpend_tot;
sl@0
   173
	const unsigned char *wpend_buf;
sl@0
   174
sl@0
   175
	int wpend_off;	/* offset to data to write */
sl@0
   176
	int wpend_len; 	/* number of bytes passwd to write */
sl@0
   177
	int wpend_ret; 	/* number of bytes to return to caller */
sl@0
   178
sl@0
   179
	/* buffer raw data */
sl@0
   180
	int rbuf_left;
sl@0
   181
	int rbuf_offs;
sl@0
   182
	unsigned char *rbuf;
sl@0
   183
	unsigned char *wbuf;
sl@0
   184
sl@0
   185
	unsigned char *write_ptr;/* used to point to the start due to
sl@0
   186
				  * 2/3 byte header. */
sl@0
   187
sl@0
   188
	unsigned int padding;
sl@0
   189
	unsigned int rlength; /* passed to ssl2_enc */
sl@0
   190
	int ract_data_length; /* Set when things are encrypted. */
sl@0
   191
	unsigned int wlength; /* passed to ssl2_enc */
sl@0
   192
	int wact_data_length; /* Set when things are decrypted. */
sl@0
   193
	unsigned char *ract_data;
sl@0
   194
	unsigned char *wact_data;
sl@0
   195
	unsigned char *mac_data;
sl@0
   196
sl@0
   197
	unsigned char *read_key;
sl@0
   198
	unsigned char *write_key;
sl@0
   199
sl@0
   200
		/* Stuff specifically to do with this SSL session */
sl@0
   201
	unsigned int challenge_length;
sl@0
   202
	unsigned char challenge[SSL2_MAX_CHALLENGE_LENGTH];
sl@0
   203
	unsigned int conn_id_length;
sl@0
   204
	unsigned char conn_id[SSL2_MAX_CONNECTION_ID_LENGTH];
sl@0
   205
	unsigned int key_material_length;
sl@0
   206
	unsigned char key_material[SSL2_MAX_KEY_MATERIAL_LENGTH*2];
sl@0
   207
sl@0
   208
	unsigned long read_sequence;
sl@0
   209
	unsigned long write_sequence;
sl@0
   210
sl@0
   211
	struct	{
sl@0
   212
		unsigned int conn_id_length;
sl@0
   213
		unsigned int cert_type;	
sl@0
   214
		unsigned int cert_length;
sl@0
   215
		unsigned int csl; 
sl@0
   216
		unsigned int clear;
sl@0
   217
		unsigned int enc; 
sl@0
   218
		unsigned char ccl[SSL2_MAX_CERT_CHALLENGE_LENGTH];
sl@0
   219
		unsigned int cipher_spec_length;
sl@0
   220
		unsigned int session_id_length;
sl@0
   221
		unsigned int clen;
sl@0
   222
		unsigned int rlen;
sl@0
   223
		} tmp;
sl@0
   224
	} SSL2_STATE;
sl@0
   225
sl@0
   226
/* SSLv2 */
sl@0
   227
/* client */
sl@0
   228
#define SSL2_ST_SEND_CLIENT_HELLO_A		(0x10|SSL_ST_CONNECT)
sl@0
   229
#define SSL2_ST_SEND_CLIENT_HELLO_B		(0x11|SSL_ST_CONNECT)
sl@0
   230
#define SSL2_ST_GET_SERVER_HELLO_A		(0x20|SSL_ST_CONNECT)
sl@0
   231
#define SSL2_ST_GET_SERVER_HELLO_B		(0x21|SSL_ST_CONNECT)
sl@0
   232
#define SSL2_ST_SEND_CLIENT_MASTER_KEY_A	(0x30|SSL_ST_CONNECT)
sl@0
   233
#define SSL2_ST_SEND_CLIENT_MASTER_KEY_B	(0x31|SSL_ST_CONNECT)
sl@0
   234
#define SSL2_ST_SEND_CLIENT_FINISHED_A		(0x40|SSL_ST_CONNECT)
sl@0
   235
#define SSL2_ST_SEND_CLIENT_FINISHED_B		(0x41|SSL_ST_CONNECT)
sl@0
   236
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_A	(0x50|SSL_ST_CONNECT)
sl@0
   237
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_B	(0x51|SSL_ST_CONNECT)
sl@0
   238
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_C	(0x52|SSL_ST_CONNECT)
sl@0
   239
#define SSL2_ST_SEND_CLIENT_CERTIFICATE_D	(0x53|SSL_ST_CONNECT)
sl@0
   240
#define SSL2_ST_GET_SERVER_VERIFY_A		(0x60|SSL_ST_CONNECT)
sl@0
   241
#define SSL2_ST_GET_SERVER_VERIFY_B		(0x61|SSL_ST_CONNECT)
sl@0
   242
#define SSL2_ST_GET_SERVER_FINISHED_A		(0x70|SSL_ST_CONNECT)
sl@0
   243
#define SSL2_ST_GET_SERVER_FINISHED_B		(0x71|SSL_ST_CONNECT)
sl@0
   244
#define SSL2_ST_CLIENT_START_ENCRYPTION		(0x80|SSL_ST_CONNECT)
sl@0
   245
#define SSL2_ST_X509_GET_CLIENT_CERTIFICATE	(0x90|SSL_ST_CONNECT)
sl@0
   246
/* server */
sl@0
   247
#define SSL2_ST_GET_CLIENT_HELLO_A		(0x10|SSL_ST_ACCEPT)
sl@0
   248
#define SSL2_ST_GET_CLIENT_HELLO_B		(0x11|SSL_ST_ACCEPT)
sl@0
   249
#define SSL2_ST_GET_CLIENT_HELLO_C		(0x12|SSL_ST_ACCEPT)
sl@0
   250
#define SSL2_ST_SEND_SERVER_HELLO_A		(0x20|SSL_ST_ACCEPT)
sl@0
   251
#define SSL2_ST_SEND_SERVER_HELLO_B		(0x21|SSL_ST_ACCEPT)
sl@0
   252
#define SSL2_ST_GET_CLIENT_MASTER_KEY_A		(0x30|SSL_ST_ACCEPT)
sl@0
   253
#define SSL2_ST_GET_CLIENT_MASTER_KEY_B		(0x31|SSL_ST_ACCEPT)
sl@0
   254
#define SSL2_ST_SEND_SERVER_VERIFY_A		(0x40|SSL_ST_ACCEPT)
sl@0
   255
#define SSL2_ST_SEND_SERVER_VERIFY_B		(0x41|SSL_ST_ACCEPT)
sl@0
   256
#define SSL2_ST_SEND_SERVER_VERIFY_C		(0x42|SSL_ST_ACCEPT)
sl@0
   257
#define SSL2_ST_GET_CLIENT_FINISHED_A		(0x50|SSL_ST_ACCEPT)
sl@0
   258
#define SSL2_ST_GET_CLIENT_FINISHED_B		(0x51|SSL_ST_ACCEPT)
sl@0
   259
#define SSL2_ST_SEND_SERVER_FINISHED_A		(0x60|SSL_ST_ACCEPT)
sl@0
   260
#define SSL2_ST_SEND_SERVER_FINISHED_B		(0x61|SSL_ST_ACCEPT)
sl@0
   261
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_A	(0x70|SSL_ST_ACCEPT)
sl@0
   262
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_B	(0x71|SSL_ST_ACCEPT)
sl@0
   263
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_C	(0x72|SSL_ST_ACCEPT)
sl@0
   264
#define SSL2_ST_SEND_REQUEST_CERTIFICATE_D	(0x73|SSL_ST_ACCEPT)
sl@0
   265
#define SSL2_ST_SERVER_START_ENCRYPTION		(0x80|SSL_ST_ACCEPT)
sl@0
   266
#define SSL2_ST_X509_GET_SERVER_CERTIFICATE	(0x90|SSL_ST_ACCEPT)
sl@0
   267
sl@0
   268
#ifdef  __cplusplus
sl@0
   269
}
sl@0
   270
#endif
sl@0
   271
#endif
sl@0
   272