Deleted Added
full compact
s3_lib.c (68651) s3_lib.c (72613)
1/* ssl/s3_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *

--- 41 unchanged lines hidden (view full) ---

50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
1/* ssl/s3_lib.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *

--- 41 unchanged lines hidden (view full) ---

50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58/* ====================================================================
59 * Copyright (c) 1998-2000 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
59#include <stdio.h>
60#include <openssl/md5.h>
61#include <openssl/sha.h>
62#include <openssl/objects.h>
63#include "ssl_locl.h"
64
65const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;

--- 567 unchanged lines hidden (view full) ---

633SSL_CIPHER *ssl3_get_cipher(unsigned int u)
634 {
635 if (u < SSL3_NUM_CIPHERS)
636 return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
637 else
638 return(NULL);
639 }
640
111
112#include <stdio.h>
113#include <openssl/md5.h>
114#include <openssl/sha.h>
115#include <openssl/objects.h>
116#include "ssl_locl.h"
117
118const char *ssl3_version_str="SSLv3" OPENSSL_VERSION_PTEXT;

--- 567 unchanged lines hidden (view full) ---

686SSL_CIPHER *ssl3_get_cipher(unsigned int u)
687 {
688 if (u < SSL3_NUM_CIPHERS)
689 return(&(ssl3_ciphers[SSL3_NUM_CIPHERS-1-u]));
690 else
691 return(NULL);
692 }
693
641/* The problem is that it may not be the correct record type */
642int ssl3_pending(SSL *s)
643 {
694int ssl3_pending(SSL *s)
695 {
644 return(s->s3->rrec.length);
696 return (s->s3->rrec.type == SSL3_RT_APPLICATION_DATA) ? s->s3->rrec.length : 0;
645 }
646
647int ssl3_new(SSL *s)
648 {
649 SSL3_STATE *s3;
650
651 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
652 memset(s3,0,sizeof *s3);

--- 531 unchanged lines hidden (view full) ---

1184 /* resend it if not sent */
1185#if 1
1186 ssl3_dispatch_alert(s);
1187#endif
1188 }
1189 else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
1190 {
1191 /* If we are waiting for a close from our peer, we are closed */
697 }
698
699int ssl3_new(SSL *s)
700 {
701 SSL3_STATE *s3;
702
703 if ((s3=OPENSSL_malloc(sizeof *s3)) == NULL) goto err;
704 memset(s3,0,sizeof *s3);

--- 531 unchanged lines hidden (view full) ---

1236 /* resend it if not sent */
1237#if 1
1238 ssl3_dispatch_alert(s);
1239#endif
1240 }
1241 else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN))
1242 {
1243 /* If we are waiting for a close from our peer, we are closed */
1192 ssl3_read_bytes(s,0,NULL,0);
1244 ssl3_read_bytes(s,0,NULL,0,0);
1193 }
1194
1195 if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
1196 !s->s3->alert_dispatch)
1197 return(1);
1198 else
1199 return(0);
1200 }

--- 46 unchanged lines hidden (view full) ---

1247 ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
1248 buf,len);
1249 if (ret <= 0) return(ret);
1250 }
1251
1252 return(ret);
1253 }
1254
1245 }
1246
1247 if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) &&
1248 !s->s3->alert_dispatch)
1249 return(1);
1250 else
1251 return(0);
1252 }

--- 46 unchanged lines hidden (view full) ---

1299 ret=ssl3_write_bytes(s,SSL3_RT_APPLICATION_DATA,
1300 buf,len);
1301 if (ret <= 0) return(ret);
1302 }
1303
1304 return(ret);
1305 }
1306
1255int ssl3_read(SSL *s, void *buf, int len)
1307static int ssl3_read_internal(SSL *s, void *buf, int len, int peek)
1256 {
1257 int ret;
1258
1259 clear_sys_error();
1260 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
1261 s->s3->in_read_app_data=1;
1308 {
1309 int ret;
1310
1311 clear_sys_error();
1312 if (s->s3->renegotiate) ssl3_renegotiate_check(s);
1313 s->s3->in_read_app_data=1;
1262 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len);
1314 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
1263 if ((ret == -1) && (s->s3->in_read_app_data == 0))
1264 {
1265 /* ssl3_read_bytes decided to call s->handshake_func, which
1266 * called ssl3_read_bytes to read handshake data.
1267 * However, ssl3_read_bytes actually found application data
1268 * and thinks that application data makes sense here (signalled
1269 * by resetting 'in_read_app_data', strangely); so disable
1270 * handshake processing and try to read application data again. */
1271 s->in_handshake++;
1315 if ((ret == -1) && (s->s3->in_read_app_data == 0))
1316 {
1317 /* ssl3_read_bytes decided to call s->handshake_func, which
1318 * called ssl3_read_bytes to read handshake data.
1319 * However, ssl3_read_bytes actually found application data
1320 * and thinks that application data makes sense here (signalled
1321 * by resetting 'in_read_app_data', strangely); so disable
1322 * handshake processing and try to read application data again. */
1323 s->in_handshake++;
1272 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len);
1324 ret=ssl3_read_bytes(s,SSL3_RT_APPLICATION_DATA,buf,len,peek);
1273 s->in_handshake--;
1274 }
1275 else
1276 s->s3->in_read_app_data=0;
1277
1278 return(ret);
1279 }
1280
1325 s->in_handshake--;
1326 }
1327 else
1328 s->s3->in_read_app_data=0;
1329
1330 return(ret);
1331 }
1332
1281int ssl3_peek(SSL *s, char *buf, int len)
1333int ssl3_read(SSL *s, void *buf, int len)
1282 {
1334 {
1283 SSL3_RECORD *rr;
1284 int n;
1335 return ssl3_read_internal(s, buf, len, 0);
1336 }
1285
1337
1286 rr= &(s->s3->rrec);
1287 if ((rr->length == 0) || (rr->type != SSL3_RT_APPLICATION_DATA))
1288 {
1289 n=ssl3_read(s,buf,1);
1290 if (n <= 0) return(n);
1291 rr->length++;
1292 rr->off--;
1293 }
1294
1295 if ((unsigned int)len > rr->length)
1296 n=rr->length;
1297 else
1298 n=len;
1299 memcpy(buf,&(rr->data[rr->off]),(unsigned int)n);
1300 return(n);
1338int ssl3_peek(SSL *s, char *buf, int len)
1339 {
1340 return ssl3_read_internal(s, buf, len, 1);
1301 }
1302
1303int ssl3_renegotiate(SSL *s)
1304 {
1305 if (s->handshake_func == NULL)
1306 return(1);
1307
1308 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)

--- 31 unchanged lines hidden ---
1341 }
1342
1343int ssl3_renegotiate(SSL *s)
1344 {
1345 if (s->handshake_func == NULL)
1346 return(1);
1347
1348 if (s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS)

--- 31 unchanged lines hidden ---