@@ -1952,10 +1952,12 @@ PHP_FUNCTION(sodium_crypto_aead_aes256gcm_encrypt)
1952
1952
zend_throw_exception (sodium_exception_ce , "arithmetic overflow" , 0 );
1953
1953
RETURN_THROWS ();
1954
1954
}
1955
+ #if SIZEOF_SIZE_T != 4
1955
1956
if ((unsigned long long ) msg_len > (16ULL * ((1ULL << 32 ) - 2ULL )) - crypto_aead_aes256gcm_ABYTES ) {
1956
1957
zend_throw_exception (sodium_exception_ce , "message too long for a single key" , 0 );
1957
1958
RETURN_THROWS ();
1958
1959
}
1960
+ #endif
1959
1961
ciphertext_len = msg_len + crypto_aead_aes256gcm_ABYTES ;
1960
1962
ciphertext = zend_string_alloc ((size_t ) ciphertext_len , 0 );
1961
1963
if (crypto_aead_aes256gcm_encrypt
@@ -2011,10 +2013,12 @@ PHP_FUNCTION(sodium_crypto_aead_aes256gcm_decrypt)
2011
2013
if (ciphertext_len < crypto_aead_aes256gcm_ABYTES ) {
2012
2014
RETURN_FALSE ;
2013
2015
}
2016
+ #if SIZEOF_SIZE_T != 4
2014
2017
if (ciphertext_len - crypto_aead_aes256gcm_ABYTES > 16ULL * ((1ULL << 32 ) - 2ULL )) {
2015
2018
zend_argument_error (sodium_exception_ce , 1 , "is too long" );
2016
2019
RETURN_THROWS ();
2017
2020
}
2021
+ #endif
2018
2022
msg_len = ciphertext_len ;
2019
2023
if (msg_len >= SIZE_MAX ) {
2020
2024
zend_throw_exception (sodium_exception_ce , "arithmetic overflow" , 0 );
@@ -2187,10 +2191,12 @@ PHP_FUNCTION(sodium_crypto_aead_chacha20poly1305_ietf_encrypt)
2187
2191
zend_throw_exception (sodium_exception_ce , "arithmetic overflow" , 0 );
2188
2192
RETURN_THROWS ();
2189
2193
}
2194
+ #if SIZEOF_SIZE_T != 4
2190
2195
if ((unsigned long long ) msg_len > 64ULL * (1ULL << 32 ) - 64ULL ) {
2191
2196
zend_throw_exception (sodium_exception_ce , "message too long for a single key" , 0 );
2192
2197
RETURN_THROWS ();
2193
2198
}
2199
+ #endif
2194
2200
ciphertext_len = msg_len + crypto_aead_chacha20poly1305_IETF_ABYTES ;
2195
2201
ciphertext = zend_string_alloc ((size_t ) ciphertext_len , 0 );
2196
2202
if (crypto_aead_chacha20poly1305_ietf_encrypt
0 commit comments