summaryrefslogtreecommitdiff
path: root/src/lib/libssl/ssl3.h
diff options
context:
space:
mode:
authormarkus <>2002-09-05 12:51:50 +0000
committermarkus <>2002-09-05 12:51:50 +0000
commit15b5d84f9da2ce4bfae8580e56e34a859f74ad71 (patch)
treebf939e82d7fd73cc8a01cf6959002209972091bc /src/lib/libssl/ssl3.h
parent027351f729b9e837200dae6e1520cda6577ab930 (diff)
downloadopenbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.gz
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.tar.bz2
openbsd-15b5d84f9da2ce4bfae8580e56e34a859f74ad71.zip
import openssl-0.9.7-beta1
Diffstat (limited to 'src/lib/libssl/ssl3.h')
-rw-r--r--src/lib/libssl/ssl3.h205
1 files changed, 127 insertions, 78 deletions
diff --git a/src/lib/libssl/ssl3.h b/src/lib/libssl/ssl3.h
index 95772eef60..8fd6951d77 100644
--- a/src/lib/libssl/ssl3.h
+++ b/src/lib/libssl/ssl3.h
@@ -55,11 +55,69 @@
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58/* ====================================================================
59 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
60 *
61 * Redistribution and use in source and binary forms, with or without
62 * modification, are permitted provided that the following conditions
63 * are met:
64 *
65 * 1. Redistributions of source code must retain the above copyright
66 * notice, this list of conditions and the following disclaimer.
67 *
68 * 2. Redistributions in binary form must reproduce the above copyright
69 * notice, this list of conditions and the following disclaimer in
70 * the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3. All advertising materials mentioning features or use of this
74 * software must display the following acknowledgment:
75 * "This product includes software developed by the OpenSSL Project
76 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
77 *
78 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
79 * endorse or promote products derived from this software without
80 * prior written permission. For written permission, please contact
81 * openssl-core@openssl.org.
82 *
83 * 5. Products derived from this software may not be called "OpenSSL"
84 * nor may "OpenSSL" appear in their names without prior written
85 * permission of the OpenSSL Project.
86 *
87 * 6. Redistributions of any form whatsoever must retain the following
88 * acknowledgment:
89 * "This product includes software developed by the OpenSSL Project
90 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
91 *
92 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
93 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
94 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
95 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
96 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
97 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
98 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
100 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
101 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
102 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
103 * OF THE POSSIBILITY OF SUCH DAMAGE.
104 * ====================================================================
105 *
106 * This product includes cryptographic software written by Eric Young
107 * (eay@cryptsoft.com). This product includes software written by Tim
108 * Hudson (tjh@cryptsoft.com).
109 *
110 */
58 111
59#ifndef HEADER_SSL3_H 112#ifndef HEADER_SSL3_H
60#define HEADER_SSL3_H 113#define HEADER_SSL3_H
61 114
62#include "buffer.h" 115#ifndef OPENSSL_NO_COMP
116#include <openssl/comp.h>
117#endif
118#include <openssl/buffer.h>
119#include <openssl/evp.h>
120#include <openssl/ssl.h>
63 121
64#ifdef __cplusplus 122#ifdef __cplusplus
65extern "C" { 123extern "C" {
@@ -100,6 +158,22 @@ extern "C" {
100#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D 158#define SSL3_CK_FZA_DMS_FZA_SHA 0x0300001D
101#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E 159#define SSL3_CK_FZA_DMS_RC4_SHA 0x0300001E
102 160
161/* VRS Additional Kerberos5 entries
162 */
163#define SSL3_CK_KRB5_DES_40_CBC_SHA 0x03000021
164#define SSL3_CK_KRB5_DES_40_CBC_MD5 0x03000022
165#define SSL3_CK_KRB5_DES_64_CBC_SHA 0x03000023
166#define SSL3_CK_KRB5_DES_64_CBC_MD5 0x03000024
167#define SSL3_CK_KRB5_DES_192_CBC3_SHA 0x03000025
168#define SSL3_CK_KRB5_DES_192_CBC3_MD5 0x03000026
169
170#define SSL3_TXT_KRB5_DES_40_CBC_SHA "EXP-KRB5-DES-CBC-SHA"
171#define SSL3_TXT_KRB5_DES_40_CBC_MD5 "EXP-KRB5-DES-CBC-MD5"
172#define SSL3_TXT_KRB5_DES_64_CBC_SHA "KRB5-DES-CBC-SHA"
173#define SSL3_TXT_KRB5_DES_64_CBC_MD5 "KRB5-DES-CBC-MD5"
174#define SSL3_TXT_KRB5_DES_192_CBC3_SHA "KRB5-DES-CBC3-SHA"
175#define SSL3_TXT_KRB5_DES_192_CBC3_MD5 "KRB5-DES-CBC3-MD5"
176
103#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" 177#define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5"
104#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" 178#define SSL3_TXT_RSA_NULL_SHA "NULL-SHA"
105#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" 179#define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5"
@@ -144,7 +218,8 @@ extern "C" {
144#define SSL3_RT_HEADER_LENGTH 5 218#define SSL3_RT_HEADER_LENGTH 5
145 219
146/* Due to MS stuffing up, this can change.... */ 220/* Due to MS stuffing up, this can change.... */
147#if defined(WIN16) || (defined(MSDOS) && !defined(WIN32)) 221#if defined(OPENSSL_SYS_WIN16) || \
222 (defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN32))
148#define SSL3_RT_MAX_EXTRA (14000) 223#define SSL3_RT_MAX_EXTRA (14000)
149#else 224#else
150#define SSL3_RT_MAX_EXTRA (16384) 225#define SSL3_RT_MAX_EXTRA (16384)
@@ -156,24 +231,8 @@ extern "C" {
156#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) 231#define SSL3_RT_MAX_PACKET_SIZE (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH)
157#define SSL3_RT_MAX_DATA_SIZE (1024*1024) 232#define SSL3_RT_MAX_DATA_SIZE (1024*1024)
158 233
159/* the states that a SSL3_RECORD can be in 234#define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54"
160 * For SSL_read it goes 235#define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52"
161 * rbuf->ENCODED -> read
162 * ENCODED -> we need to decode everything - call decode_record
163 */
164
165#define SSL3_RS_BLANK 1
166#define SSL3_RS_DATA
167
168#define SSL3_RS_ENCODED 2
169#define SSL3_RS_READ_MORE 3
170#define SSL3_RS_WRITE_MORE
171#define SSL3_RS_PLAIN 3
172#define SSL3_RS_PART_READ 4
173#define SSL3_RS_PART_WRITE 5
174
175#define SSL3_MD_CLIENT_FINISHED_CONST {0x43,0x4C,0x4E,0x54}
176#define SSL3_MD_SERVER_FINISHED_CONST {0x53,0x52,0x56,0x52}
177 236
178#define SSL3_VERSION 0x0300 237#define SSL3_VERSION 0x0300
179#define SSL3_VERSION_MAJOR 0x03 238#define SSL3_VERSION_MAJOR 0x03
@@ -202,28 +261,23 @@ extern "C" {
202 261
203typedef struct ssl3_record_st 262typedef struct ssl3_record_st
204 { 263 {
205/*r */ int type; /* type of record */ 264/*r */ int type; /* type of record */
206/* */ /*int state;*/ /* any data in it? */ 265/*rw*/ unsigned int length; /* How many bytes available */
207/*rw*/ unsigned int length; /* How many bytes available */ 266/*r */ unsigned int off; /* read/write offset into 'buf' */
208/*r */ unsigned int off; /* read/write offset into 'buf' */ 267/*rw*/ unsigned char *data; /* pointer to the record data */
209/*rw*/ unsigned char *data; /* pointer to the record data */ 268/*rw*/ unsigned char *input; /* where the decode bytes are */
210/*rw*/ unsigned char *input; /* where the decode bytes are */ 269/*r */ unsigned char *comp; /* only used with decompression - malloc()ed */
211/*rw*/ unsigned char *comp; /* only used with decompression */
212 } SSL3_RECORD; 270 } SSL3_RECORD;
213 271
214typedef struct ssl3_buffer_st 272typedef struct ssl3_buffer_st
215 { 273 {
216/*r */ int total; /* used in non-blocking writes */ 274 unsigned char *buf; /* at least SSL3_RT_MAX_PACKET_SIZE bytes,
217/*r */ int wanted; /* how many more bytes we need */ 275 * see ssl3_setup_buffers() */
218/*rw*/ int left; /* how many bytes left */ 276 size_t len; /* buffer size */
219/*rw*/ int offset; /* where to 'copy from' */ 277 int offset; /* where to 'copy from' */
220/*rw*/ unsigned char *buf; /* SSL3_RT_MAX_PACKET_SIZE bytes */ 278 int left; /* how many bytes left */
221 } SSL3_BUFFER; 279 } SSL3_BUFFER;
222 280
223typedef struct ssl3_compression_st {
224 int nothing;
225 } SSL3_COMPRESSION;
226
227#define SSL3_CT_RSA_SIGN 1 281#define SSL3_CT_RSA_SIGN 1
228#define SSL3_CT_DSS_SIGN 2 282#define SSL3_CT_DSS_SIGN 2
229#define SSL3_CT_RSA_FIXED_DH 3 283#define SSL3_CT_RSA_FIXED_DH 3
@@ -236,36 +290,9 @@ typedef struct ssl3_compression_st {
236#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 290#define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001
237#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002 291#define SSL3_FLAGS_DELAY_CLIENT_FINISHED 0x0002
238#define SSL3_FLAGS_POP_BUFFER 0x0004 292#define SSL3_FLAGS_POP_BUFFER 0x0004
239#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008 293#define TLS1_FLAGS_TLS_PADDING_BUG 0x0008
240
241#if 0
242#define AD_CLOSE_NOTIFY 0
243#define AD_UNEXPECTED_MESSAGE 1
244#define AD_BAD_RECORD_MAC 2
245#define AD_DECRYPTION_FAILED 3
246#define AD_RECORD_OVERFLOW 4
247#define AD_DECOMPRESSION_FAILURE 5 /* fatal */
248#define AD_HANDSHAKE_FAILURE 6 /* fatal */
249#define AD_NO_CERTIFICATE 7 /* Not under TLS */
250#define AD_BAD_CERTIFICATE 8
251#define AD_UNSUPPORTED_CERTIFICATE 9
252#define AD_CERTIFICATE_REVOKED 10
253#define AD_CERTIFICATE_EXPIRED 11
254#define AD_CERTIFICATE_UNKNOWN 12
255#define AD_ILLEGAL_PARAMETER 13 /* fatal */
256#define AD_UNKNOWN_CA 14 /* fatal */
257#define AD_ACCESS_DENIED 15 /* fatal */
258#define AD_DECODE_ERROR 16 /* fatal */
259#define AD_DECRYPT_ERROR 17
260#define AD_EXPORT_RESTRICION 18 /* fatal */
261#define AD_PROTOCOL_VERSION 19 /* fatal */
262#define AD_INSUFFICIENT_SECURITY 20 /* fatal */
263#define AD_INTERNAL_ERROR 21 /* fatal */
264#define AD_USER_CANCLED 22
265#define AD_NO_RENEGOTIATION 23
266#endif
267 294
268typedef struct ssl3_ctx_st 295typedef struct ssl3_state_st
269 { 296 {
270 long flags; 297 long flags;
271 int delay_buf_pop_ret; 298 int delay_buf_pop_ret;
@@ -278,19 +305,29 @@ typedef struct ssl3_ctx_st
278 unsigned char server_random[SSL3_RANDOM_SIZE]; 305 unsigned char server_random[SSL3_RANDOM_SIZE];
279 unsigned char client_random[SSL3_RANDOM_SIZE]; 306 unsigned char client_random[SSL3_RANDOM_SIZE];
280 307
308 /* flags for countermeasure against known-IV weakness */
309 int need_empty_fragments;
310 int empty_fragment_done;
311
281 SSL3_BUFFER rbuf; /* read IO goes into here */ 312 SSL3_BUFFER rbuf; /* read IO goes into here */
282 SSL3_BUFFER wbuf; /* write IO goes into here */ 313 SSL3_BUFFER wbuf; /* write IO goes into here */
314
283 SSL3_RECORD rrec; /* each decoded record goes in here */ 315 SSL3_RECORD rrec; /* each decoded record goes in here */
284 SSL3_RECORD wrec; /* goes out from here */ 316 SSL3_RECORD wrec; /* goes out from here */
285 /* Used by ssl3_read_n to point 317
286 * to input data packet */ 318 /* storage for Alert/Handshake protocol data received but not
319 * yet processed by ssl3_read_bytes: */
320 unsigned char alert_fragment[2];
321 unsigned int alert_fragment_len;
322 unsigned char handshake_fragment[4];
323 unsigned int handshake_fragment_len;
287 324
288 /* partial write - check the numbers match */ 325 /* partial write - check the numbers match */
289 unsigned int wnum; /* number of bytes sent so far */ 326 unsigned int wnum; /* number of bytes sent so far */
290 int wpend_tot; /* number bytes written */ 327 int wpend_tot; /* number bytes written */
291 int wpend_type; 328 int wpend_type;
292 int wpend_ret; /* number of bytes submitted */ 329 int wpend_ret; /* number of bytes submitted */
293 char *wpend_buf; 330 const unsigned char *wpend_buf;
294 331
295 /* used during startup, digest all incoming/outgoing packets */ 332 /* used during startup, digest all incoming/outgoing packets */
296 EVP_MD_CTX finish_dgst1; 333 EVP_MD_CTX finish_dgst1;
@@ -302,10 +339,10 @@ typedef struct ssl3_ctx_st
302 339
303 int warn_alert; 340 int warn_alert;
304 int fatal_alert; 341 int fatal_alert;
305 /* we alow one fatal and one warning alert to be outstanding, 342 /* we allow one fatal and one warning alert to be outstanding,
306 * send close alert via the warning alert */ 343 * send close alert via the warning alert */
307 int alert_dispatch; 344 int alert_dispatch;
308 char send_alert[2]; 345 unsigned char send_alert[2];
309 346
310 /* This flag is set when we should renegotiate ASAP, basically when 347 /* This flag is set when we should renegotiate ASAP, basically when
311 * there is no more data in the read or write buffers */ 348 * there is no more data in the read or write buffers */
@@ -316,16 +353,23 @@ typedef struct ssl3_ctx_st
316 int in_read_app_data; 353 int in_read_app_data;
317 354
318 struct { 355 struct {
319 /* Actually only needs to be 16+20 for SSLv3 and 12 for TLS */ 356 /* actually only needs to be 16+20 */
357 unsigned char cert_verify_md[EVP_MAX_MD_SIZE*2];
358
359 /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
320 unsigned char finish_md[EVP_MAX_MD_SIZE*2]; 360 unsigned char finish_md[EVP_MAX_MD_SIZE*2];
361 int finish_md_len;
362 unsigned char peer_finish_md[EVP_MAX_MD_SIZE*2];
363 int peer_finish_md_len;
321 364
322 unsigned long message_size; 365 unsigned long message_size;
323 int message_type; 366 int message_type;
324 367
325 /* used to hold the new cipher we are going to use */ 368 /* used to hold the new cipher we are going to use */
326 SSL_CIPHER *new_cipher; 369 SSL_CIPHER *new_cipher;
370#ifndef OPENSSL_NO_DH
327 DH *dh; 371 DH *dh;
328 372#endif
329 /* used when SSL_ST_FLUSH_DATA is entered */ 373 /* used when SSL_ST_FLUSH_DATA is entered */
330 int next_state; 374 int next_state;
331 375
@@ -335,19 +379,24 @@ typedef struct ssl3_ctx_st
335 int cert_req; 379 int cert_req;
336 int ctype_num; 380 int ctype_num;
337 char ctype[SSL3_CT_NUMBER]; 381 char ctype[SSL3_CT_NUMBER];
338 STACK *ca_names; 382 STACK_OF(X509_NAME) *ca_names;
339 383
340 int use_rsa_tmp; 384 int use_rsa_tmp;
341 385
342 int key_block_length; 386 int key_block_length;
343 unsigned char *key_block; 387 unsigned char *key_block;
344 388
345 EVP_CIPHER *new_sym_enc; 389 const EVP_CIPHER *new_sym_enc;
346 EVP_MD *new_hash; 390 const EVP_MD *new_hash;
347 SSL_COMPRESSION *new_compression; 391#ifndef OPENSSL_NO_COMP
392 const SSL_COMP *new_compression;
393#else
394 char *new_compression;
395#endif
348 int cert_request; 396 int cert_request;
349 } tmp; 397 } tmp;
350 } SSL3_CTX; 398
399 } SSL3_STATE;
351 400
352/* SSLv3 */ 401/* SSLv3 */
353/*client */ 402/*client */
@@ -425,7 +474,7 @@ typedef struct ssl3_ctx_st
425#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT) 474#define SSL3_ST_SW_FINISHED_A (0x1E0|SSL_ST_ACCEPT)
426#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT) 475#define SSL3_ST_SW_FINISHED_B (0x1E1|SSL_ST_ACCEPT)
427 476
428#define SSL3_MT_CLIENT_REQUEST 0 477#define SSL3_MT_HELLO_REQUEST 0
429#define SSL3_MT_CLIENT_HELLO 1 478#define SSL3_MT_CLIENT_HELLO 1
430#define SSL3_MT_SERVER_HELLO 2 479#define SSL3_MT_SERVER_HELLO 2
431#define SSL3_MT_CERTIFICATE 11 480#define SSL3_MT_CERTIFICATE 11