summaryrefslogtreecommitdiff
path: root/ext/sodium
diff options
context:
space:
mode:
authorFrank Denis <github@pureftpd.org>2017-10-02 21:54:50 +0200
committerFrank Denis <github@pureftpd.org>2017-10-02 21:54:50 +0200
commit7d53e65125e63f522a5ad6dbbabeb7d5fc243dea (patch)
treee606904eddab2cf9547e4abb647da02cf3bb579a /ext/sodium
parente22094eb1390759ecfe28178cf67d8a80aebbfbb (diff)
downloadphp-git-7d53e65125e63f522a5ad6dbbabeb7d5fc243dea.tar.gz
ext/sodium: add crypto_pwhash_str_needs_rehash()
Also properly define xchacha20poly1305_ietf_keygen()
Diffstat (limited to 'ext/sodium')
-rw-r--r--ext/sodium/libsodium.c25
-rw-r--r--ext/sodium/php_libsodium.h1
2 files changed, 25 insertions, 1 deletions
diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c
index 07d2c5e038..6b192bc69d 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 d586a2b7dc..adfe40e8ae 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);