diff options
| author | Sara Golemon <pollita@php.net> | 2019-04-05 17:33:10 -0400 |
|---|---|---|
| committer | Sara Golemon <pollita@php.net> | 2019-07-07 21:53:43 -0400 |
| commit | 0ba1db7a4ab035e00dcb3089ef45820054c5a1cf (patch) | |
| tree | 271352283fbe66712be9b660fb83c6ad84e4b8d9 /ext/sodium/libsodium.c | |
| parent | 57e7c3aac100f7ceb992a9a554b76235713f9a83 (diff) | |
| download | php-git-0ba1db7a4ab035e00dcb3089ef45820054c5a1cf.tar.gz | |
Provide argon2i(d) password hashing from sodium when needed
Diffstat (limited to 'ext/sodium/libsodium.c')
| -rw-r--r-- | ext/sodium/libsodium.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ext/sodium/libsodium.c b/ext/sodium/libsodium.c index 652663ff08..2159cb52b4 100644 --- a/ext/sodium/libsodium.c +++ b/ext/sodium/libsodium.c @@ -358,8 +358,18 @@ static const zend_function_entry sodium_functions[] = { PHP_FE_END }; +/* Load after the "standard" module in order to give it + * priority in registering argon2i/argon2id password hashers. + */ +static const zend_module_dep sodium_deps[] = { + ZEND_MOD_REQUIRED("standard") + ZEND_MOD_END +}; + zend_module_entry sodium_module_entry = { - STANDARD_MODULE_HEADER, + STANDARD_MODULE_HEADER_EX, + NULL, + sodium_deps, "sodium", sodium_functions, PHP_MINIT(sodium), @@ -632,6 +642,13 @@ PHP_MINIT_FUNCTION(sodium) REGISTER_LONG_CONSTANT("SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING", sodium_base64_VARIANT_URLSAFE_NO_PADDING, CONST_CS | CONST_PERSISTENT); #endif + +#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6) + if (FAILURE == PHP_MINIT(sodium_password_hash)(INIT_FUNC_ARGS_PASSTHRU)) { + return FAILURE; + } +#endif + return SUCCESS; } |
