Deleted Added
full compact
s3_enc.c (59191) s3_enc.c (68651)
1/* ssl/s3_enc.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 *

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

145 else
146 comp=s->s3->tmp.new_compression->method;
147 key_block=s->s3->tmp.key_block;
148
149 if (which & SSL3_CC_READ)
150 {
151 if ((s->enc_read_ctx == NULL) &&
152 ((s->enc_read_ctx=(EVP_CIPHER_CTX *)
1/* ssl/s3_enc.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 *

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

145 else
146 comp=s->s3->tmp.new_compression->method;
147 key_block=s->s3->tmp.key_block;
148
149 if (which & SSL3_CC_READ)
150 {
151 if ((s->enc_read_ctx == NULL) &&
152 ((s->enc_read_ctx=(EVP_CIPHER_CTX *)
153 Malloc(sizeof(EVP_CIPHER_CTX))) == NULL))
153 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL))
154 goto err;
155 dd= s->enc_read_ctx;
156 s->read_hash=m;
157 /* COMPRESS */
158 if (s->expand != NULL)
159 {
160 COMP_CTX_free(s->expand);
161 s->expand=NULL;
162 }
163 if (comp != NULL)
164 {
165 s->expand=COMP_CTX_new(comp);
166 if (s->expand == NULL)
167 {
168 SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,SSL_R_COMPRESSION_LIBRARY_ERROR);
169 goto err2;
170 }
171 if (s->s3->rrec.comp == NULL)
172 s->s3->rrec.comp=(unsigned char *)
154 goto err;
155 dd= s->enc_read_ctx;
156 s->read_hash=m;
157 /* COMPRESS */
158 if (s->expand != NULL)
159 {
160 COMP_CTX_free(s->expand);
161 s->expand=NULL;
162 }
163 if (comp != NULL)
164 {
165 s->expand=COMP_CTX_new(comp);
166 if (s->expand == NULL)
167 {
168 SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,SSL_R_COMPRESSION_LIBRARY_ERROR);
169 goto err2;
170 }
171 if (s->s3->rrec.comp == NULL)
172 s->s3->rrec.comp=(unsigned char *)
173 Malloc(SSL3_RT_MAX_PLAIN_LENGTH);
173 OPENSSL_malloc(SSL3_RT_MAX_PLAIN_LENGTH);
174 if (s->s3->rrec.comp == NULL)
175 goto err;
176 }
177 memset(&(s->s3->read_sequence[0]),0,8);
178 mac_secret= &(s->s3->read_mac_secret[0]);
179 }
180 else
181 {
182 if ((s->enc_write_ctx == NULL) &&
183 ((s->enc_write_ctx=(EVP_CIPHER_CTX *)
174 if (s->s3->rrec.comp == NULL)
175 goto err;
176 }
177 memset(&(s->s3->read_sequence[0]),0,8);
178 mac_secret= &(s->s3->read_mac_secret[0]);
179 }
180 else
181 {
182 if ((s->enc_write_ctx == NULL) &&
183 ((s->enc_write_ctx=(EVP_CIPHER_CTX *)
184 Malloc(sizeof(EVP_CIPHER_CTX))) == NULL))
184 OPENSSL_malloc(sizeof(EVP_CIPHER_CTX))) == NULL))
185 goto err;
186 dd= s->enc_write_ctx;
187 s->write_hash=m;
188 /* COMPRESS */
189 if (s->compress != NULL)
190 {
191 COMP_CTX_free(s->compress);
192 s->compress=NULL;

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

295 s->s3->tmp.new_hash=hash;
296 s->s3->tmp.new_compression=comp;
297
298 num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c);
299 num*=2;
300
301 ssl3_cleanup_key_block(s);
302
185 goto err;
186 dd= s->enc_write_ctx;
187 s->write_hash=m;
188 /* COMPRESS */
189 if (s->compress != NULL)
190 {
191 COMP_CTX_free(s->compress);
192 s->compress=NULL;

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

295 s->s3->tmp.new_hash=hash;
296 s->s3->tmp.new_compression=comp;
297
298 num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c);
299 num*=2;
300
301 ssl3_cleanup_key_block(s);
302
303 if ((p=Malloc(num)) == NULL)
303 if ((p=OPENSSL_malloc(num)) == NULL)
304 goto err;
305
306 s->s3->tmp.key_block_length=num;
307 s->s3->tmp.key_block=p;
308
309 ssl3_generate_key_block(s,p,num);
310
311 return(1);
312err:
313 SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE);
314 return(0);
315 }
316
317void ssl3_cleanup_key_block(SSL *s)
318 {
319 if (s->s3->tmp.key_block != NULL)
320 {
321 memset(s->s3->tmp.key_block,0,
322 s->s3->tmp.key_block_length);
304 goto err;
305
306 s->s3->tmp.key_block_length=num;
307 s->s3->tmp.key_block=p;
308
309 ssl3_generate_key_block(s,p,num);
310
311 return(1);
312err:
313 SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,ERR_R_MALLOC_FAILURE);
314 return(0);
315 }
316
317void ssl3_cleanup_key_block(SSL *s)
318 {
319 if (s->s3->tmp.key_block != NULL)
320 {
321 memset(s->s3->tmp.key_block,0,
322 s->s3->tmp.key_block_length);
323 Free(s->s3->tmp.key_block);
323 OPENSSL_free(s->s3->tmp.key_block);
324 s->s3->tmp.key_block=NULL;
325 }
326 s->s3->tmp.key_block_length=0;
327 }
328
329int ssl3_enc(SSL *s, int send)
330 {
331 SSL3_RECORD *rec;

--- 252 unchanged lines hidden ---
324 s->s3->tmp.key_block=NULL;
325 }
326 s->s3->tmp.key_block_length=0;
327 }
328
329int ssl3_enc(SSL *s, int send)
330 {
331 SSL3_RECORD *rec;

--- 252 unchanged lines hidden ---