@@ -1671,7 +1671,7 @@ zend_result php_openssl_validate_iv(const char **piv, size_t *piv_len, size_t iv
1671
1671
char * iv_new ;
1672
1672
1673
1673
if (mode -> is_aead ) {
1674
- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) != 1 ) {
1674
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_ivlen_flag , * piv_len , NULL ) <= 0 ) {
1675
1675
php_error_docref (NULL , E_WARNING , "Setting of IV length for AEAD mode failed" );
1676
1676
return FAILURE ;
1677
1677
}
@@ -1742,15 +1742,15 @@ zend_result php_openssl_cipher_init(const EVP_CIPHER *cipher_type,
1742
1742
return FAILURE ;
1743
1743
}
1744
1744
if (mode -> set_tag_length_always || (enc && mode -> set_tag_length_when_encrypting )) {
1745
- if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL )) {
1745
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , NULL ) <= 0 ) {
1746
1746
php_error_docref (NULL , E_WARNING , "Setting tag length for AEAD cipher failed" );
1747
1747
return FAILURE ;
1748
1748
}
1749
1749
}
1750
1750
if (!enc && tag && tag_len > 0 ) {
1751
1751
if (!mode -> is_aead ) {
1752
1752
php_error_docref (NULL , E_WARNING , "The tag cannot be used because the cipher algorithm does not support AEAD" );
1753
- } else if (! EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag )) {
1753
+ } else if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode -> aead_set_tag_flag , tag_len , (unsigned char * ) tag ) <= 0 ) {
1754
1754
php_error_docref (NULL , E_WARNING , "Setting tag for AEAD cipher decryption failed" );
1755
1755
return FAILURE ;
1756
1756
}
@@ -1886,7 +1886,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
1886
1886
if (mode .is_aead && tag ) {
1887
1887
zend_string * tag_str = zend_string_alloc (tag_len , 0 );
1888
1888
1889
- if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) == 1 ) {
1889
+ if (EVP_CIPHER_CTX_ctrl (cipher_ctx , mode .aead_get_tag_flag , tag_len , ZSTR_VAL (tag_str )) <= 0 ) {
1890
1890
ZSTR_VAL (tag_str )[tag_len ] = '\0' ;
1891
1891
ZSTR_LEN (tag_str ) = tag_len ;
1892
1892
ZEND_TRY_ASSIGN_REF_NEW_STR (tag , tag_str );
0 commit comments