unsigned char *ms,*key,*iv,*er1,*er2;
EVP_CIPHER_CTX *dd;
EVP_CIPHER *c;
- SSL_COMPRESSION *comp;
+ COMP_METHOD *comp;
EVP_MD *m;
MD5_CTX md;
- int exp,n,i,j,k;
+ int exp,n,i,j,k,cl;
- exp=(s->s3->tmp.new_cipher->algorithms & SSL_EXPORT)?1:0;
+ exp=SSL_C_IS_EXPORT(s->s3->tmp.new_cipher);
c=s->s3->tmp.new_sym_enc;
m=s->s3->tmp.new_hash;
- comp=s->s3->tmp.new_compression;
+ if (s->s3->tmp.new_compression == NULL)
+ comp=NULL;
+ else
+ comp=s->s3->tmp.new_compression->method;
key_block=s->s3->tmp.key_block;
if (which & SSL3_CC_READ)
goto err;
dd= s->enc_read_ctx;
s->read_hash=m;
- s->read_compression=comp;
+ /* COMPRESS */
+ if (s->expand != NULL)
+ {
+ COMP_CTX_free(s->expand);
+ s->expand=NULL;
+ }
+ if (comp != NULL)
+ {
+ s->expand=COMP_CTX_new(comp);
+ if (s->expand == NULL)
+ {
+ SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,SSL_R_COMPRESSION_LIBRARY_ERROR);
+ goto err2;
+ }
+ if (s->s3->rrec.comp == NULL)
+ s->s3->rrec.comp=(unsigned char *)
+ Malloc(SSL3_RT_MAX_PLAIN_LENGTH);
+ if (s->s3->rrec.comp == NULL)
+ goto err;
+ }
memset(&(s->s3->read_sequence[0]),0,8);
mac_secret= &(s->s3->read_mac_secret[0]);
}
goto err;
dd= s->enc_write_ctx;
s->write_hash=m;
- s->write_compression=comp;
+ /* COMPRESS */
+ if (s->compress != NULL)
+ {
+ COMP_CTX_free(s->compress);
+ s->compress=NULL;
+ }
+ if (comp != NULL)
+ {
+ s->compress=COMP_CTX_new(comp);
+ if (s->compress == NULL)
+ {
+ SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE,SSL_R_COMPRESSION_LIBRARY_ERROR);
+ goto err2;
+ }
+ }
memset(&(s->s3->write_sequence[0]),0,8);
mac_secret= &(s->s3->write_mac_secret[0]);
}
p=s->s3->tmp.key_block;
i=EVP_MD_size(m);
- j=(exp)?5:EVP_CIPHER_key_length(c);
+ cl=EVP_CIPHER_key_length(c);
+ j=exp ? (cl < SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher) ?
+ cl : SSL_C_EXPORT_KEYLENGTH(s->s3->tmp.new_cipher)) : cl;
+ /* Was j=(exp)?5:EVP_CIPHER_key_length(c); */
k=EVP_CIPHER_iv_length(c);
if ( (which == SSL3_CHANGE_CIPHER_CLIENT_WRITE) ||
(which == SSL3_CHANGE_CIPHER_SERVER_READ))
unsigned char *p;
EVP_CIPHER *c;
EVP_MD *hash;
- int num,exp;
+ int num;
+ SSL_COMP *comp;
if (s->s3->tmp.key_block_length != 0)
return(1);
- if (!ssl_cipher_get_evp(s->session->cipher,&c,&hash))
+ if (!ssl_cipher_get_evp(s->session,&c,&hash,&comp))
{
SSLerr(SSL_F_SSL3_SETUP_KEY_BLOCK,SSL_R_CIPHER_OR_HASH_UNAVAILABLE);
return(0);
s->s3->tmp.new_sym_enc=c;
s->s3->tmp.new_hash=hash;
-
- exp=(s->session->cipher->algorithms & SSL_EXPORT)?1:0;
+ s->s3->tmp.new_compression=comp;
num=EVP_CIPHER_key_length(c)+EVP_MD_size(hash)+EVP_CIPHER_iv_length(c);
num*=2;
unsigned long l;
int bs,i;
EVP_CIPHER *enc;
- SSL_COMPRESSION *comp;
if (send)
{
ds=s->enc_write_ctx;
rec= &(s->s3->wrec);
if (s->enc_write_ctx == NULL)
- { enc=NULL; comp=NULL; }
+ enc=NULL;
else
- {
enc=EVP_CIPHER_CTX_cipher(s->enc_write_ctx);
- comp=s->write_compression;
- }
}
else
{
ds=s->enc_read_ctx;
rec= &(s->s3->rrec);
if (s->enc_read_ctx == NULL)
- { enc=NULL; comp=NULL; }
+ enc=NULL;
else
- {
enc=EVP_CIPHER_CTX_cipher(s->enc_read_ctx);
- comp=s->read_compression;
- }
}
if ((s->session == NULL) || (ds == NULL) ||
- ((enc == NULL) && (comp == NULL)))
+ (enc == NULL))
{
memcpy(rec->data,rec->input,rec->length);
rec->input=rec->data;
l=rec->length;
bs=EVP_CIPHER_block_size(ds->cipher);
+ /* COMPRESS */
+
/* This should be using (bs-1) and bs instead of 7 and 8 */
if ((bs != 1) && send)
{
unsigned char md_buf[EVP_MAX_MD_SIZE];
EVP_MD_CTX ctx;
- memcpy(&ctx,in_ctx,sizeof(EVP_MD_CTX));
+ EVP_MD_CTX_copy(&ctx,in_ctx);
n=EVP_MD_CTX_size(&ctx);
npad=(48/n)*n;