@@ -1853,11 +1853,13 @@ PHP_FUNCTION(sodium_crypto_pwhash)
1853
1853
return ;
1854
1854
}
1855
1855
if (opslimit < crypto_pwhash_OPSLIMIT_MIN ) {
1856
- zend_error (E_ERROR ,
1857
- "number of operations for the password hashing function is too low" );
1856
+ zend_throw_exception (sodium_exception_ce ,
1857
+ "number of operations for the password hashing function is too low" , 0 );
1858
+ return ;
1858
1859
}
1859
1860
if (memlimit < crypto_pwhash_MEMLIMIT_MIN ) {
1860
- zend_error (E_ERROR , "maximum memory for the password hashing function is too low" );
1861
+ zend_throw_exception (sodium_exception_ce ,
1862
+ "maximum memory for the password hashing function is too low" , 0 );
1861
1863
}
1862
1864
hash = zend_string_alloc ((size_t ) hash_len , 0 );
1863
1865
ret = -1 ;
@@ -1916,12 +1918,12 @@ PHP_FUNCTION(sodium_crypto_pwhash_str)
1916
1918
zend_error (E_WARNING , "empty password" );
1917
1919
}
1918
1920
if (opslimit < crypto_pwhash_OPSLIMIT_MIN ) {
1919
- zend_error ( E_ERROR ,
1920
- "number of operations for the password hashing function is too low" );
1921
+ zend_throw_exception ( sodium_exception_ce ,
1922
+ "number of operations for the password hashing function is too low" , 0 );
1921
1923
}
1922
1924
if (memlimit < crypto_pwhash_MEMLIMIT_MIN ) {
1923
- zend_error ( E_ERROR ,
1924
- "maximum memory for the password hashing function is too low" );
1925
+ zend_throw_exception ( sodium_exception_ce ,
1926
+ "maximum memory for the password hashing function is too low" , 0 );
1925
1927
}
1926
1928
hash_str = zend_string_alloc (crypto_pwhash_STRBYTES - 1 , 0 );
1927
1929
if (crypto_pwhash_str
@@ -2030,12 +2032,12 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256)
2030
2032
return ;
2031
2033
}
2032
2034
if (opslimit < crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE ) {
2033
- zend_error ( E_ERROR ,
2034
- "number of operations for the scrypt function is too low" );
2035
+ zend_throw_exception ( sodium_exception_ce ,
2036
+ "number of operations for the scrypt function is too low" , 0 );
2035
2037
}
2036
2038
if (memlimit < crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE ) {
2037
- zend_error ( E_ERROR ,
2038
- "maximum memory for the scrypt function is too low" );
2039
+ zend_throw_exception ( sodium_exception_ce ,
2040
+ "maximum memory for the scrypt function is too low" , 0 );
2039
2041
}
2040
2042
hash = zend_string_alloc ((size_t ) hash_len , 0 );
2041
2043
if (crypto_pwhash_scryptsalsa208sha256
@@ -2077,12 +2079,12 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str)
2077
2079
zend_error (E_WARNING , "empty password" );
2078
2080
}
2079
2081
if (opslimit < crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE ) {
2080
- zend_error ( E_ERROR ,
2081
- "number of operations for the scrypt function is too low" );
2082
+ zend_throw_exception ( sodium_exception_ce ,
2083
+ "number of operations for the scrypt function is too low" , 0 );
2082
2084
}
2083
2085
if (memlimit < crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE ) {
2084
- zend_error ( E_ERROR ,
2085
- "maximum memory for the scrypt function is too low" );
2086
+ zend_throw_exception ( sodium_exception_ce ,
2087
+ "maximum memory for the scrypt function is too low" , 0 );
2086
2088
}
2087
2089
hash_str = zend_string_alloc
2088
2090
(crypto_pwhash_scryptsalsa208sha256_STRBYTES - 1 , 0 );
0 commit comments