Skip to content

Commit 498716c

Browse files
charlesportwoodiisgolemon
authored andcommitted
Compatibility with libargon2 versions 20161029 and 20160821
libargon2 20161029 introduces the `type` parameter to the argon2_encodedlen function that is not present in 20160821. This change ensures the Argon2 functionality introduced in RFC `argon2_password_hash` is compatible with both versions, as the library version that package maintainers package may differ.
1 parent d3c593a commit 498716c

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

ext/standard/config.m4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,13 @@ if test "$PHP_PASSWORD_ARGON2" != "no"; then
439439
], [
440440
AC_MSG_ERROR([Problem with libargon2.(a|so). Please verify that Argon2 header and libaries are installed])
441441
])
442+
443+
AC_CHECK_LIB(argon2, argon2id_hash_raw, [
444+
LIBS="$LIBS -largon2"
445+
AC_DEFINE(HAVE_ARGON2ID, 1, [ Define to 1 if Argon2 library has support for Argon2ID])
446+
], [
447+
AC_MSG_RESULT([not found])
448+
])
442449
fi
443450

444451
dnl

ext/standard/config.w32

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ if (PHP_PASSWORD_ARGON2 != "no") {
77
if (CHECK_LIB("argon2_a.lib;argon2.lib", null, PHP_PASSWORD_ARGON2)
88
&& CHECK_HEADER_ADD_INCLUDE("argon2.h", "CFLAGS")) {
99
AC_DEFINE('HAVE_ARGON2LIB', 1);
10+
if (CHECK_FUNC_IN_HEADER("argon2.h", "argon2id_hash_raw", PHP_PHP_BUILD + "\\include", "CFLAGS")) {
11+
AC_DEFINE('HAVE_ARGON2ID', 1);
12+
}
1013
} else {
1114
WARNING("Argon2 not enabled; libaries and headers not found");
1215
}

ext/standard/password.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ PHP_FUNCTION(password_hash)
545545
threads,
546546
(uint32_t)salt_len,
547547
out_len
548+
#if HAVE_ARGON2ID
549+
, type
550+
#endif
548551
);
549552

550553
out = emalloc(out_len + 1);

0 commit comments

Comments
 (0)