com php-src: ext/sodium: add crypto_pwhash_str_needs_re hash(): ext/sodium/libsodium.c ext/sodium/php_lib sodium.h

From: Date: Mon, 02 Oct 2017 19:54:50 +0000
Subject: com php-src: ext/sodium: add crypto_pwhash_str_needs_re hash(): ext/sodium/libsodium.c ext/sodium/php_lib sodium.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-99603@lists.php.net to get a copy of this message
Commit: 7d53e65125e63f522a5ad6dbbabeb7d5fc243dea Author: Frank Denis <github@pureftpd.org> Mon, 2 Oct 2017 21:54:50 +0200 Parents: e22094eb1390759ecfe28178cf67d8a80aebbfbb Branches: PHP-7.2 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7d53e65125e63f522a5ad6dbbabeb7d5fc243dea Log: ext/sodium: add crypto_pwhash_str_needs_rehash() Also properly define xchacha20poly1305_ietf_keygen() Changed paths: M ext/sodium/libsodium.c M ext/sodium/php_libsodium.h Diff: diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index 07d2c5e..6b192bc 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -240,9 +240,10 @@ const zend_function_entry sodium_functions[] = { PHP_FE(sodium_crypto_aead_chacha20poly1305_keygen, AI_None) PHP_FE(sodium_crypto_aead_chacha20poly1305_ietf_decrypt, AI_StringAndADAndNonceAndKey) PHP_FE(sodium_crypto_aead_chacha20poly1305_ietf_encrypt, AI_StringAndADAndNonceAndKey) + PHP_FE(sodium_crypto_aead_chacha20poly1305_ietf_keygen, AI_None) #ifdef crypto_aead_xchacha20poly1305_IETF_NPUBBYTES PHP_FE(sodium_crypto_aead_xchacha20poly1305_ietf_decrypt, AI_StringAndADAndNonceAndKey) - PHP_FE(sodium_crypto_aead_chacha20poly1305_ietf_keygen, AI_None) + PHP_FE(sodium_crypto_aead_xchacha20poly1305_ietf_keygen, AI_None) PHP_FE(sodium_crypto_aead_xchacha20poly1305_ietf_encrypt, AI_StringAndADAndNonceAndKey) #endif PHP_FE(sodium_crypto_auth, AI_StringAndKey) @@ -276,6 +277,9 @@ const zend_function_entry sodium_functions[] = { PHP_FE(sodium_crypto_pwhash_str, AI_PasswordAndOpsLimitAndMemLimit) PHP_FE(sodium_crypto_pwhash_str_verify, AI_HashAndPassword) #endif +#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) + PHP_FE(sodium_crypto_pwhash_str_needs_rehash, AI_PasswordAndOpsLimitAndMemLimit) +#endif #ifdef crypto_pwhash_scryptsalsa208sha256_SALTBYTES PHP_FE(sodium_crypto_pwhash_scryptsalsa208sha256, AI_LengthAndPasswordAndSaltAndOpsLimitAndMemLimit) PHP_FE(sodium_crypto_pwhash_scryptsalsa208sha256_str, AI_PasswordAndOpsLimitAndMemLimit) @@ -2025,6 +2029,25 @@ PHP_FUNCTION(sodium_crypto_pwhash_str) RETURN_STR(hash_str); } +#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) +PHP_FUNCTION(sodium_crypto_pwhash_str_needs_rehash) +{ + char *hash_str; + zend_long memlimit; + zend_long opslimit; + size_t hash_str_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sll", + &hash_str, &hash_str_len) == FAILURE) { + return; + } + if (crypto_pwhash_str_needs_rehash(hash_str, opslimit, memlimit) == 0) { + RETURN_FALSE; + } + RETURN_TRUE; +} +#endif + PHP_FUNCTION(sodium_crypto_pwhash_str_verify) { char *hash_str; diff --git a/ext/sodium/php_libsodium.h b/ext/sodium/php_libsodium.h index d586a2b..adfe40e 100644 --- a/ext/sodium/php_libsodium.h +++ b/ext/sodium/php_libsodium.h @@ -83,6 +83,7 @@ PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256); PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str); PHP_FUNCTION(sodium_crypto_pwhash_scryptsalsa208sha256_str_verify); PHP_FUNCTION(sodium_crypto_pwhash_str); +PHP_FUNCTION(sodium_crypto_pwhash_str_needs_rehash); PHP_FUNCTION(sodium_crypto_pwhash_str_verify); PHP_FUNCTION(sodium_crypto_scalarmult); PHP_FUNCTION(sodium_crypto_scalarmult_base);

« previous php.cvs (#99603) next »