Loading CHANGES +4 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,10 @@ *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7 +) applies to 0.9.7 only +) Modify the behaviour of EVP cipher functions in similar way to digests to retain compatibility with existing code. [Steve Henson] +) Modify the behaviour of EVP_DigestInit() and EVP_DigestFinal() to retain compatibility with existing code. In particular the 'ctx' parameter is not assumed to be valid before the call to EVP_DigestInit() and it is tidied Loading apps/speed.c +4 −4 Original line number Diff line number Diff line Loading @@ -1216,9 +1216,9 @@ int MAIN(int argc, char **argv) print_message(names[D_EVP],save_count, lengths[j]); if(decrypt) EVP_DecryptInit(&ctx,evp,key16,iv); EVP_DecryptInit_ex(&ctx,evp,NULL,key16,iv); else EVP_EncryptInit(&ctx,evp,key16,iv); EVP_EncryptInit_ex(&ctx,evp,NULL,key16,iv); Time_F(START,usertime); if(decrypt) Loading @@ -1228,9 +1228,9 @@ int MAIN(int argc, char **argv) for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++) EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]); if(decrypt) EVP_DecryptFinal(&ctx,buf,&outl); EVP_DecryptFinal_ex(&ctx,buf,&outl); else EVP_EncryptFinal(&ctx,buf,&outl); EVP_EncryptFinal_ex(&ctx,buf,&outl); d=Time_F(STOP,usertime); BIO_printf(bio_err,"%ld %s's in %.2fs\n", count,names[D_EVP],d); Loading crypto/asn1/n_pkey.c +4 −4 Original line number Diff line number Diff line Loading @@ -207,9 +207,9 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey) /* Encrypt private key in place */ zz = enckey->enckey->digest->data; EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit(&ctx,EVP_rc4(),key,NULL); EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL); EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen); EVP_EncryptFinal(&ctx,zz + i,&j); EVP_EncryptFinal_ex(&ctx,zz + i,&j); EVP_CIPHER_CTX_cleanup(&ctx); ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp); Loading Loading @@ -293,9 +293,9 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, memset(buf,0,256); EVP_CIPHER_CTX_init(&ctx); EVP_DecryptInit(&ctx,EVP_rc4(),key,NULL); EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL); EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length); EVP_DecryptFinal(&ctx,&(os->data[i]),&j); EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j); EVP_CIPHER_CTX_cleanup(&ctx); os->length=i+j; Loading crypto/asn1/p5_pbev2.c +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, goto err; /* Dummy cipherinit to just setup the IV */ EVP_CipherInit(&ctx, cipher, NULL, iv, 0); EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0); if(EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) { ASN1err(ASN1_F_PKCS5_PBE2_SET, ASN1_R_ERROR_SETTING_CIPHER_PARAMS); Loading crypto/evp/bio_enc.c +4 −4 Original line number Diff line number Diff line Loading @@ -184,7 +184,7 @@ static int enc_read(BIO *b, char *out, int outl) if (!BIO_should_retry(b->next_bio)) { ctx->cont=i; i=EVP_CipherFinal(&(ctx->cipher), i=EVP_CipherFinal_ex(&(ctx->cipher), (unsigned char *)ctx->buf, &(ctx->buf_len)); ctx->ok=i; Loading Loading @@ -298,7 +298,7 @@ static long enc_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_RESET: ctx->ok=1; ctx->finished=0; EVP_CipherInit(&(ctx->cipher),NULL,NULL,NULL, EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL, ctx->cipher.encrypt); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); break; Loading Loading @@ -335,7 +335,7 @@ again: { ctx->finished=1; ctx->buf_off=0; ret=EVP_CipherFinal(&(ctx->cipher), ret=EVP_CipherFinal_ex(&(ctx->cipher), (unsigned char *)ctx->buf, &(ctx->buf_len)); ctx->ok=(int)ret; Loading Loading @@ -421,7 +421,7 @@ void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k, b->init=1; ctx=(BIO_ENC_CTX *)b->ptr; EVP_CipherInit(&(ctx->cipher),c,k,i,e); EVP_CipherInit_ex(&(ctx->cipher),c,NULL, k,i,e); if (b->callback != NULL) b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L); Loading Loading
CHANGES +4 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,10 @@ *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7 +) applies to 0.9.7 only +) Modify the behaviour of EVP cipher functions in similar way to digests to retain compatibility with existing code. [Steve Henson] +) Modify the behaviour of EVP_DigestInit() and EVP_DigestFinal() to retain compatibility with existing code. In particular the 'ctx' parameter is not assumed to be valid before the call to EVP_DigestInit() and it is tidied Loading
apps/speed.c +4 −4 Original line number Diff line number Diff line Loading @@ -1216,9 +1216,9 @@ int MAIN(int argc, char **argv) print_message(names[D_EVP],save_count, lengths[j]); if(decrypt) EVP_DecryptInit(&ctx,evp,key16,iv); EVP_DecryptInit_ex(&ctx,evp,NULL,key16,iv); else EVP_EncryptInit(&ctx,evp,key16,iv); EVP_EncryptInit_ex(&ctx,evp,NULL,key16,iv); Time_F(START,usertime); if(decrypt) Loading @@ -1228,9 +1228,9 @@ int MAIN(int argc, char **argv) for (count=0,run=1; COND(save_count*4*lengths[0]/lengths[j]); count++) EVP_EncryptUpdate(&ctx,buf,&outl,buf,lengths[j]); if(decrypt) EVP_DecryptFinal(&ctx,buf,&outl); EVP_DecryptFinal_ex(&ctx,buf,&outl); else EVP_EncryptFinal(&ctx,buf,&outl); EVP_EncryptFinal_ex(&ctx,buf,&outl); d=Time_F(STOP,usertime); BIO_printf(bio_err,"%ld %s's in %.2fs\n", count,names[D_EVP],d); Loading
crypto/asn1/n_pkey.c +4 −4 Original line number Diff line number Diff line Loading @@ -207,9 +207,9 @@ int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey) /* Encrypt private key in place */ zz = enckey->enckey->digest->data; EVP_CIPHER_CTX_init(&ctx); EVP_EncryptInit(&ctx,EVP_rc4(),key,NULL); EVP_EncryptInit_ex(&ctx,EVP_rc4(),NULL,key,NULL); EVP_EncryptUpdate(&ctx,zz,&i,zz,pkeylen); EVP_EncryptFinal(&ctx,zz + i,&j); EVP_EncryptFinal_ex(&ctx,zz + i,&j); EVP_CIPHER_CTX_cleanup(&ctx); ret = i2d_NETSCAPE_ENCRYPTED_PKEY(enckey, pp); Loading Loading @@ -293,9 +293,9 @@ static RSA *d2i_RSA_NET_2(RSA **a, ASN1_OCTET_STRING *os, memset(buf,0,256); EVP_CIPHER_CTX_init(&ctx); EVP_DecryptInit(&ctx,EVP_rc4(),key,NULL); EVP_DecryptInit_ex(&ctx,EVP_rc4(),NULL, key,NULL); EVP_DecryptUpdate(&ctx,os->data,&i,os->data,os->length); EVP_DecryptFinal(&ctx,&(os->data[i]),&j); EVP_DecryptFinal_ex(&ctx,&(os->data[i]),&j); EVP_CIPHER_CTX_cleanup(&ctx); os->length=i+j; Loading
crypto/asn1/p5_pbev2.c +1 −1 Original line number Diff line number Diff line Loading @@ -117,7 +117,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, goto err; /* Dummy cipherinit to just setup the IV */ EVP_CipherInit(&ctx, cipher, NULL, iv, 0); EVP_CipherInit_ex(&ctx, cipher, NULL, NULL, iv, 0); if(EVP_CIPHER_param_to_asn1(&ctx, scheme->parameter) < 0) { ASN1err(ASN1_F_PKCS5_PBE2_SET, ASN1_R_ERROR_SETTING_CIPHER_PARAMS); Loading
crypto/evp/bio_enc.c +4 −4 Original line number Diff line number Diff line Loading @@ -184,7 +184,7 @@ static int enc_read(BIO *b, char *out, int outl) if (!BIO_should_retry(b->next_bio)) { ctx->cont=i; i=EVP_CipherFinal(&(ctx->cipher), i=EVP_CipherFinal_ex(&(ctx->cipher), (unsigned char *)ctx->buf, &(ctx->buf_len)); ctx->ok=i; Loading Loading @@ -298,7 +298,7 @@ static long enc_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_RESET: ctx->ok=1; ctx->finished=0; EVP_CipherInit(&(ctx->cipher),NULL,NULL,NULL, EVP_CipherInit_ex(&(ctx->cipher),NULL,NULL,NULL,NULL, ctx->cipher.encrypt); ret=BIO_ctrl(b->next_bio,cmd,num,ptr); break; Loading Loading @@ -335,7 +335,7 @@ again: { ctx->finished=1; ctx->buf_off=0; ret=EVP_CipherFinal(&(ctx->cipher), ret=EVP_CipherFinal_ex(&(ctx->cipher), (unsigned char *)ctx->buf, &(ctx->buf_len)); ctx->ok=(int)ret; Loading Loading @@ -421,7 +421,7 @@ void BIO_set_cipher(BIO *b, const EVP_CIPHER *c, unsigned char *k, b->init=1; ctx=(BIO_ENC_CTX *)b->ptr; EVP_CipherInit(&(ctx->cipher),c,k,i,e); EVP_CipherInit_ex(&(ctx->cipher),c,NULL, k,i,e); if (b->callback != NULL) b->callback(b,BIO_CB_CTRL,(const char *)c,BIO_CTRL_SET,e,1L); Loading