com php-src: Use php_openssl_cipher_init in openssl _encrypt: ext/openssl/openssl.c

From: Date: Sun, 01 Nov 2015 13:30:42 +0000
Subject: com php-src: Use php_openssl_cipher_init in openssl _encrypt: ext/openssl/openssl.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92496@lists.php.net to get a copy of this message
Commit: 789ee143b2b499a4fce75f08bc298bb15b88531b Author: Jakub Zelenka <bukka@php.net> Sun, 1 Nov 2015 13:30:42 +0000 Parents: c09f3e399eab84ff9ae000110314de4b155bbea4 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=789ee143b2b499a4fce75f08bc298bb15b88531b Log: Use php_openssl_cipher_init in openssl_encrypt Changed paths: M ext/openssl/openssl.c Diff: diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 9a12941..c0a4773 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -5340,17 +5340,14 @@ PHP_FUNCTION(openssl_encrypt) } free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len); + if (php_openssl_cipher_init(cipher_type, cipher_ctx, password_len, keylen, key, iv, options, 1) == FAILURE) { + php_error_docref(NULL, E_WARNING, "Failed to initialize cipher encryption"); + RETVAL_FALSE; + goto openssl_encrypt_clean; + } + outlen = (int)data_len + EVP_CIPHER_block_size(cipher_type); outbuf = zend_string_alloc(outlen, 0); - - EVP_EncryptInit_ex(cipher_ctx, cipher_type, NULL, NULL, NULL); - if (password_len > keylen) { - EVP_CIPHER_CTX_set_key_length(cipher_ctx, (int)password_len); - } - EVP_EncryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv); - if (options & OPENSSL_ZERO_PADDING) { - EVP_CIPHER_CTX_set_padding(cipher_ctx, 0); - } if (data_len > 0) { EVP_EncryptUpdate(cipher_ctx, (unsigned char*)ZSTR_VAL(outbuf), &i, (unsigned char *)data, (int)data_len); } @@ -5372,6 +5369,8 @@ PHP_FUNCTION(openssl_encrypt) zend_string_release(outbuf); RETVAL_FALSE; } + +openssl_encrypt_clean: if (key != (unsigned char*)password) { efree(key); }

« previous php.cvs (#92496) next »