Closed 0xACE closed 9 years ago
git clone https://github.com/DomBlack/php-scrypt && cd php-scrypt
phpize && ./configure --enable-scrypt && make && make test
This results with make test
failing:
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test that the scrypt_pickparams() functions works. [tests/params.phpt]
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 28
---------------------------------------------------------------------
Number of tests : 2 2
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 2 (100.0%) (100.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 0 ( 0.0%) ( 0.0%)
---------------------------------------------------------------------
Time taken : 119 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test that the scrypt_pickparams() functions works. [tests/params.phpt]
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================
================================================================================
/home/ace/dev/git/php-scrypt/tests/params.phpt
================================================================================
** ERROR: process timed out **
================================================================================
001+ ** ERROR: process timed out **
001- array
================================================================================
================================================================================
/home/ace/dev/git/php-scrypt/tests/vectors.phpt
================================================================================
dad42d1a684e3f74fcb01111cac6e91e00e336b522ac3ff69edae73b1220ec151fea46b35b17302419bc6ea0761ea88f90c72d6505615248e32d0c3187246705
359b43b7d848ee3981ca62aaa49463d109ec587d33ef5e91f26372121ae08c9175715c019d22159a0ae55a36fcdc8683d5b5513d9db50363244d093e499e53c6
e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
================================================================================
001+ dad42d1a684e3f74fcb01111cac6e91e00e336b522ac3ff69edae73b1220ec151fea46b35b17302419bc6ea0761ea88f90c72d6505615248e32d0c3187246705
002+ 359b43b7d848ee3981ca62aaa49463d109ec587d33ef5e91f26372121ae08c9175715c019d22159a0ae55a36fcdc8683d5b5513d9db50363244d093e499e53c6
003+ e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
004+ e364703c38c0bd423faeb1519af561e0453a67f67b1d2214836a3329d50b2e0a616f8785f8aa92c3bb17621df395d54331ba4ebd655bc2dd27fc863d29c72c8a
001- 77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
002- fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
003- 7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
004- 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4
================================================================================
config.m4
with the following patch:diff --git a/config.m4 b/config.m4
index 8901703..de15379 100644
--- a/config.m4
+++ b/config.m4
@@ -22,10 +22,6 @@ if test $PHP_SCRYPT != "no"; then
AC_CHECK_MEMBER([struct sysinfo.totalram], [AC_DEFINE(HAVE_STRUCT_SYSINFO_TOTALRAM)])
version=nosse
- AC_CHECK_HEADER([emmintrin.h], [version=sse], [version=nosse])
- if test "$version" = "sse"; then
- CFLAGS="$CFLAGS -msse -msse2"
- fi
AC_DEFINE(HAVE_SCRYPT, 1, [Whether you have scrypt])
PHP_NEW_EXTENSION(scrypt, php_scrypt.c php_scrypt_utils.c crypto/sha256.c crypto/crypto_scrypt-$version.c crypto/params.c, $ext_shared)
and then running:
git XXean -dxf # (XX=cl) WARNING this will delete all files not being tracked
phpize && ./configure --enable-scrypt && make && make test
results with make test
failing:
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 28
---------------------------------------------------------------------
Number of tests : 2 2
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 1 ( 50.0%) ( 50.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 1 ( 50.0%) ( 50.0%)
---------------------------------------------------------------------
Time taken : 66 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================
================================================================================
/home/ace/dev/git/php-scrypt/tests/vectors.phpt
================================================================================
77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
** ERROR: process timed out **
================================================================================
004+
004- 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4
005+ ** ERROR: process timed out **
================================================================================
git XXean -dxf # (XX=cl) WARNING this will delete all files not being tracked
git checkout v1.2
Note that I checked out v1.2 and applied this patch:
diff --git a/config.m4 b/config.m4
index fef744d..de15379 100644
--- a/config.m4
+++ b/config.m4
@@ -22,7 +22,6 @@ if test $PHP_SCRYPT != "no"; then
AC_CHECK_MEMBER([struct sysinfo.totalram], [AC_DEFINE(HAVE_STRUCT_SYSINFO_TOTALRAM)])
version=nosse
- AC_CHECK_HEADER([emmintrin.h], [version=sse], [version=nosse])
AC_DEFINE(HAVE_SCRYPT, 1, [Whether you have scrypt])
PHP_NEW_EXTENSION(scrypt, php_scrypt.c php_scrypt_utils.c crypto/sha256.c crypto/crypto_scrypt-$version.c crypto/params.c, $ext_shared)
and then ran:
phpize && ./configure --enable-scrypt && make && make test
And it resulted with make test
failing:
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================
=====================================================================
TEST RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped : 0
Exts tested : 28
---------------------------------------------------------------------
Number of tests : 2 2
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 1 ( 50.0%) ( 50.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 1 ( 50.0%) ( 50.0%)
---------------------------------------------------------------------
Time taken : 6 seconds
=====================================================================
=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test scrypt KDF using test vectors. [tests/vectors.phpt]
=====================================================================
================================================================================
/home/ace/dev/git/php-scrypt/tests/vectors.phpt
================================================================================
77d6576238657b203b19ca42c18a0497f16b4844e3074ae8dfdffa3fede21442fcd0069ded0948f8326a753a0fc81f17e8d3e0fb2e0d3628cf35e20c38d18906
fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1073741824 bytes) in /home/ace/dev/git/php-scrypt/tests/vectors.php on line 5
================================================================================
004+
004- 2101cb9b6a511aaeaddbbe09cf70f881ec568d574a2ffd4dabe5ee9820adaa478e56fd8f4ba5d09ffa1c6d927c40f4c337304049e8a952fbcbf45c6fa77a41a4
005+ Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1073741824 bytes) in /home/ace/dev/git/php-scrypt/tests/vectors.php on line 5
================================================================================
However this time, the second test fails because of the lack of RAM available. The machine has 1.5G and it seems like the max limit for the test is 2G.
cd /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include
mv emmintrin.h emmintrin.h.DISABLED
pecl install scrypt
mv emmintrin.h.DISABLED emmintrin.h
Basically this ensures that it compiles with version=nosse
.
I've also tried removing the -msse2
from $CFLAGS
but that also fails to compile.
If you need me to try other combinations, let me know. If you're on any irc network, we could talk there for a faster exchange. I'm usually online when European people are online.
P.S. I'm using gcc (GCC) 5.2.0
From my understanding emmintrin.h
should not be present on a system with no SSE2 support. Hence the check for it.
We could always just add an "--disable-sse2" option to the build process, instead of trying to pick it up automatically.
I'm on EFNET in the php.pecl channel a lot of the time
From my understanding emmintrin.h should not be present on a system with no SSE2 support. Hence the check for it.
Afaik, that only has to do with what the compiler supports. For example these are other headerfiles which most likely will reside in your computer, wether you've got CPU support for them or not.
<mmintrin.h> //MMX
<xmmintrin.h> //SSE
<emmintrin.h> //SSE2
<pmmintrin.h> //SSE3
<tmmintrin.h> //SSSE3
<smmintrin.h> //SSE4.1
<nmmintrin.h> //SSE4.2
<ammintrin.h> //SSE4A
<wmmintrin.h> //AES
<immintrin.h> //AVX
For example, currently I'm using a relatively new machine and it doesn't seem to have AES or AVX instructions but it has <wmmintrin.h>
and <immintrin.h>
We could always just add an "--disable-sse2" option to the build process, instead of trying to pick it up automatically.
Not sure how this would help someone using pecl install scrypt
. I would suggest:
grep -ic "^flags.\+sse2" /proc/cpuinfo
grep will return a integer >0
or errorlevel ($? == 0
) if sse2 is supported. I believe this is a safer way to make sure SSE2 support exists. I've submitted a pull request for my proposed change. See PR #38.
I'm on EFNET in the php.pecl channel a lot of the time
I'm having trouble finding out if EFNET supports SASL, I'll have to look it up some time.
I like the idea of that change but /proc/cpuinfo
isn't available on OSX.
This should work though:
if [ "$(uname)" = 'Darwin' ]; then; sysctl -a | grep -ic "^machdep.cpu.features.\+sse2"; else; grep -ic "^flags.\+sse2" /proc/cpuinfo; fi
I'll look at publishing scrypt 1.2.1 this weekend with that fix inplace
I like the idea of that change but /proc/cpuinfo isn't available on OSX.
Sorry about that. I adjusted PR #38 and tested it on a MAC machine and it works fine.
I've tried to report the bug here:
https://bugs.php.net/bug.php?id=70204
They directed me to here instead.
Here is a paste of my bug report there:
Here is the output of running
pecl install scrypt
: