@@ -7692,7 +7692,7 @@ static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_
7692
7692
char * iv_new ;
7693
7693
7694
7694
if (mode -> is_aead ) {
7695
- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) != 1 ) {
7695
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) <= 0 ) {
7696
7696
php_error_docref (NULL , E_WARNING , "Setting of IV length for AEAD mode failed" );
7697
7697
return FAILURE ;
7698
7698
}
@@ -7764,15 +7764,15 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
7764
7764
return FAILURE ;
7765
7765
}
7766
7766
if (mode -> set_tag_length_always || (enc && mode -> set_tag_length_when_encrypting )) {
7767
- if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL )) {
7767
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL ) <= 0 ) {
7768
7768
php_error_docref (NULL , E_WARNING , "Setting tag length for AEAD cipher failed" );
7769
7769
return FAILURE ;
7770
7770
}
7771
7771
}
7772
7772
if (!enc && tag && tag_len > 0 ) {
7773
7773
if (!mode -> is_aead ) {
7774
7774
php_error_docref (NULL , E_WARNING , "The tag cannot be used because the cipher algorithm does not support AEAD" );
7775
- } else if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag )) {
7775
+ } else if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag ) <= 0 ) {
7776
7776
php_error_docref (NULL , E_WARNING , "Setting tag for AEAD cipher decryption failed" );
7777
7777
return FAILURE ;
7778
7778
}
@@ -7910,7 +7910,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
7910
7910
if (mode .is_aead && tag ) {
7911
7911
zend_string * tag_str = zend_string_alloc (tag_len , 0 );
7912
7912
7913
- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) == 1 ) {
7913
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) > 0 ) {
7914
7914
ZSTR_VAL (tag_str )[tag_len ] = '\0' ;
7915
7915
ZSTR_LEN (tag_str ) = tag_len ;
7916
7916
ZEND_TRY_ASSIGN_REF_NEW_STR (tag , tag_str );
0 commit comments