technion/libscrypt

test NINE failing on big endian platforms

Closed this issue · 8 comments

We get the 9th test to fail on big endian platforms like ppc and s390, both 32-bit and 64-bit fail. Not sure about the following tests as the test app exits after first failure.

gcc -Wall -o reference main.o -Wl,-rpath=. -L. -lscrypt
./reference
TEST ONE: Direct call to reference function with password 'password' and salt 'NaCL'
TEST ONE: SUCCESSFUL
TEST TWO: Convert binary output to hex
TEST TWO: SUCCESSFUL, Hex output is:
fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
TEST THREE: Compare hex output to reference hash output
TEST THREE: SUCCESSUL, Test vector matched!
TEST FOUR: Direct call to reference function with pleaseletmein password and SodiumChloride as salt
TEST FOUR: SUCCESSFUL
TEST FIVE: Convert binary output to hex
TEST FIVE: SUCCESSFUL, Hex output is:
7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
TEST SIX: Compare hex output to reference hash output
TEST SIX: SUCCESSUL, Test vector matched!
TEST SEVEN: BASE64 encoding the salt and hash output
TEST SEVEN: SUCCESSFUL
TEST EIGHT: Create an MCF format output
TEST EIGHT: SUCCESSFUL, calculated mcf
$s1$0e0801$U29kaXVtQ2hsb3JpZGU=$cCO9yzr9c0hGHAbNgf046/2o+7qQT44+qbVD9lRdofLVQylVYT8Pz2LUlwUkKpr55h6F3A1lHkDfzwF7RVdYhw==
TEST NINE: Password verify on given MCF
TEST NINE: FAILED, hash failed to calculate
make: *** [check] Error 1

and with debug output enabled in libscrypt_check()

./reference
TEST ONE: Direct call to reference function with password 'password' and salt 'NaCL'
TEST ONE: SUCCESSFUL
TEST TWO: Convert binary output to hex
TEST TWO: SUCCESSFUL, Hex output is:
fdbabe1c9d3472007856e7190d01e9fe7c6ad7cbc8237830e77376634b3731622eaf30d92e22a3886ff109279d9830dac727afb94a83ee6d8360cbdfa2cc0640
TEST THREE: Compare hex output to reference hash output
TEST THREE: SUCCESSUL, Test vector matched!
TEST FOUR: Direct call to reference function with pleaseletmein password and SodiumChloride as salt
TEST FOUR: SUCCESSFUL
TEST FIVE: Convert binary output to hex
TEST FIVE: SUCCESSFUL, Hex output is:
7023bdcb3afd7348461c06cd81fd38ebfda8fbba904f8e3ea9b543f6545da1f2d5432955613f0fcf62d49705242a9af9e61e85dc0d651e40dfcf017b45575887
TEST SIX: Compare hex output to reference hash output
TEST SIX: SUCCESSUL, Test vector matched!
TEST SEVEN: BASE64 encoding the salt and hash output
TEST SEVEN: SUCCESSFUL
TEST EIGHT: Create an MCF format output
TEST EIGHT: SUCCESSFUL, calculated mcf
$s1$0e0801$U29kaXVtQ2hsb3JpZGU=$cCO9yzr9c0hGHAbNgf046/2o+7qQT44+qbVD9lRdofLVQylVYT8Pz2LUlwUkKpr55h6F3A1lHkDfzwF7RVdYhw==
TEST NINE: Password verify on given MCF
We've obtained salt 'N' r p of 'U29kaXVtQ2hsb3JpZGU=' 16384 8 1
TEST NINE: FAILED, hash failed to calculate

Many thanks for this report and patch. I don't have access to any such hardware so I'm happy to take your patch.

Within minutes of accepting this patch - it was confirmed as breaking compilation under FreeBSD. Whilst this patch manages to "fix" more obscure platforms, I'm more concerned about portability to *BSD and are working on a better solution.

I've committed a more portable fix - but as stated I don't have the ability to test it on any of the problematic platforms. It does however, now run on every supported platform.
I'm very interested in seeing this library be as portable as possible - as stated above however, common operating systems take a precedence over obscure architectures. Can anyone verify the new version on a big endian?

As I've had no further reports I'll close this case here.

sorry for late answer, but yes, your fix also works for big endian arches, new problem appeared from the previous commit though, I'll open a new issue with more information