libtom / libtomcrypt

LibTomCrypt is a fairly comprehensive, modular and portable cryptographic toolkit that provides developers with a vast array of well known published block ciphers, one-way hash functions, chaining modes, pseudo-random number generators, public key cryptography and a plethora of other routines.
https://www.libtom.net
Other
1.56k stars 458 forks source link

Test failure on x86_64 (file_test failed) #394

Closed KevLing closed 6 years ago

KevLing commented 6 years ago

Prerequisites

Description

This issue is the same as #258 but on a different platform. Running the libtomcrypt unit tests produces a failure (file_test) and a nop (katja_test). I am building this using GCC (6.4.0) on Windows 7 64-bit.

store_test..........passed      0.000ms
rotate_test.........passed      1.000ms
misc_test...........passed      0.000ms
mpi_test............passed      1.000ms
cipher_hash_test....passed     23.002ms
mac_test............passed      3.000ms
modes_test..........passed      0.000ms
der_test............passed   1844.105ms
pkcs_1_test.........passed      2.001ms
pkcs_1_pss_test.....passed     10.000ms
pkcs_1_oaep_test....passed     11.001ms
pkcs_1_emsa_test....passed     14.001ms
pkcs_1_eme_test.....passed     14.000ms
rsa_test............passed   1653.095ms
dh_test.............passed   7382.422ms
ecc_tests...........passed  13468.771ms
dsa_test............passed    258.014ms
katja_test..........nop
file_test...........failed (CRYPT_ERROR)      1.000ms
multi_test..........passed      0.000ms
prng_test...........passed      1.000ms

FAILURE: passed=19 failed=1 nop=1 duration=24.7sec real=24.7sec

Steps to Reproduce

  1. Build tomsfastmath make CFLAGS="-DTFM_X86_64 -Isrc/headers" test

  2. Build libtomcrypt with tomsfastmath make CFLAGS="-DUSE_TFM -DTFM_DESC -I../tomsfastmath/src/headers" EXTRALIBS="../tomsfastmath/libtfm.a" test

  3. Run `test.exe.

  4. I also tested with libtommath and saw the same test failure. Build command for libtommath was make. Then libtomcrypt was built with make CFLAGS="-DUSE_LTM -DLTM_DESC -I../libtommath" EXTRALIBS="../libtommath/libtommath.a" test

Version

libtomcrypt = v1.18.1 tomsfastmath = v0.13.1 libtommath = v1.0.1

Cygwin, GCC (6.4.0), Windows 7 64-bit

Additional Information

The test program's output with tomsfastmath and LTC_DEBUG=2 is attached.

ltc_debug2_output.txt

karel-m commented 6 years ago

Could you please run from cygwin's command prompt the following:

$ sha256sum tests/test.key
76ec7faebdc42a4de35ca70024c2d273e9f7856ca61612e89f5f66350ba8cf5f *tests/test.key

The tests/test.key is a text file and there might be some git related issue with CR+LF / LF newline autoconversion.

sjaeckel commented 6 years ago

very good catch!

$ unix2dos tests/test.key 
unix2dos: converting file tests/test.key to DOS format ...
$ sha256sum tests/test.key 
d3052a1401ae74febbfd96084346f2f4877a7cdd8e8ca0d2197d8fcfeaf3378d  tests/test.key
sjaeckel commented 6 years ago

a nop (katja_test)

and that nop is intentional as katja is disabled by default (and I guess could even be removed in the next release)

karel-m commented 6 years ago

katja [...] removed in the next release

👍