Deleted Added
full compact
s3_enc.c (76866) s3_enc.c (79998)
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 *

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

351 enc=NULL;
352 else
353 enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx);
354 }
355
356 if ((s->session == NULL) || (ds == NULL) ||
357 (enc == NULL))
358 {
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 *

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

351 enc=NULL;
352 else
353 enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx);
354 }
355
356 if ((s->session == NULL) || (ds == NULL) ||
357 (enc == NULL))
358 {
359 memcpy(rec->data,rec->input,rec->length);
359 memmove(rec->data,rec->input,rec->length);
360 rec->input=rec->data;
361 }
362 else
363 {
364 l=rec->length;
365 bs=EVP_CIPHER_block_size(ds->cipher);
366
367 /* COMPRESS */
368
360 rec->input=rec->data;
361 }
362 else
363 {
364 l=rec->length;
365 bs=EVP_CIPHER_block_size(ds->cipher);
366
367 /* COMPRESS */
368
369 /* This should be using (bs-1) and bs instead of 7 and 8 */
370 if ((bs != 1) && send)
371 {
372 i=bs-((int)l%bs);
373
374 /* we need to add 'i-1' padding bytes */
375 l+=i;
376 rec->length+=i;
377 rec->input[l-1]=(i-1);
378 }
369 if ((bs != 1) && send)
370 {
371 i=bs-((int)l%bs);
372
373 /* we need to add 'i-1' padding bytes */
374 l+=i;
375 rec->length+=i;
376 rec->input[l-1]=(i-1);
377 }
379
378
379 if (!send)
380 {
381 if (l == 0 || l%bs != 0)
382 {
383 SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
384 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR);
385 return(0);
386 }
387 }
388
380 EVP_Cipher(ds,rec->data,rec->input,l);
381
382 if ((bs != 1) && !send)
383 {
384 i=rec->data[l-1]+1;
389 EVP_Cipher(ds,rec->data,rec->input,l);
390
391 if ((bs != 1) && !send)
392 {
393 i=rec->data[l-1]+1;
394 /* SSL 3.0 bounds the number of padding bytes by the block size;
395 * padding bytes (except that last) are arbitrary */
385 if (i > bs)
386 {
387 SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
388 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR);
389 return(0);
390 }
391 rec->length-=i;
392 }

--- 194 unchanged lines hidden ---
396 if (i > bs)
397 {
398 SSLerr(SSL_F_SSL3_ENC,SSL_R_BLOCK_CIPHER_PAD_IS_WRONG);
399 ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_DECRYPT_ERROR);
400 return(0);
401 }
402 rec->length-=i;
403 }

--- 194 unchanged lines hidden ---