@@ -7475,7 +7475,7 @@ static int php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv_
7475
7475
char * iv_new ;
7476
7476
7477
7477
if (mode -> is_aead ) {
7478
- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) != 1 ) {
7478
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) <= 0 ) {
7479
7479
php_error_docref (NULL , E_WARNING , "Setting of IV length for AEAD mode failed" );
7480
7480
return FAILURE ;
7481
7481
}
@@ -7547,15 +7547,15 @@ static int php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
7547
7547
return FAILURE ;
7548
7548
}
7549
7549
if (mode -> set_tag_length_always || (enc && mode -> set_tag_length_when_encrypting )) {
7550
- if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL )) {
7550
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL ) <= 0 ) {
7551
7551
php_error_docref (NULL , E_WARNING , "Setting tag length for AEAD cipher failed" );
7552
7552
return FAILURE ;
7553
7553
}
7554
7554
}
7555
7555
if (!enc && tag && tag_len > 0 ) {
7556
7556
if (!mode -> is_aead ) {
7557
7557
php_error_docref (NULL , E_WARNING , "The tag cannot be used because the cipher algorithm does not support AEAD" );
7558
- } else if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag )) {
7558
+ } else if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag ) <= 0 ) {
7559
7559
php_error_docref (NULL , E_WARNING , "Setting tag for AEAD cipher decryption failed" );
7560
7560
return FAILURE ;
7561
7561
}
@@ -7693,7 +7693,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
7693
7693
if (mode .is_aead && tag ) {
7694
7694
zend_string * tag_str = zend_string_alloc (tag_len , 0 );
7695
7695
7696
- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) == 1 ) {
7696
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) > 0 ) {
7697
7697
ZSTR_VAL (tag_str )[tag_len ] = '\0' ;
7698
7698
ZSTR_LEN (tag_str ) = tag_len ;
7699
7699
ZEND_TRY_ASSIGN_REF_NEW_STR (tag , tag_str );
0 commit comments