-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wycheproof failing ECC tests #446
base: develop
Are you sure you want to change the base?
Conversation
I have added one more wycheproof failing test labeled "Edge case for Shamir multiplication" - in this case we reject a signature that is valid (which is less dangerous). |
Added to more cases (both ASN.1 length encoding) when we accept signature that wycheproof guys consider invalid. |
0b85b86
to
5b7d22f
Compare
d9c0bc4
to
74da361
Compare
74da361
to
fe85bcd
Compare
fe85bcd
to
e8c61cc
Compare
e8c61cc
to
822ecef
Compare
I tried to look into these failing cases, but haven't been able to find any documentation on what these test cases exactly do. Does anyone else have a hint? |
Gods, this has been ages, hasn't it? I can try to have a look in the coming days... |
822ecef
to
06d03f6
Compare
Absolutely!
Absolutely 2 :) |
I had a look... and first of all, when I ran the tests of this PR, they all succeed, so not sure what's supposedly failing. As for the INVALID test vectors that are added in this PR, they seem to be correct (i.e. they are, in fact, invalid, and the test does detect that they fail as they should). So er, what was the question? BTW, for anyone that needs a link to wycheproof data, here it is: https://github.com/C2SP/wycheproof/tree/master/testvectors |
As far as I'm concerned, this PR can be merged as is. For the future, it might be a good thing to consider generating a separate C source file with just data, using the wycheproof JSON files as input. That's gonna be a biiiig source file, though. |
Signed-off-by: Steffen Jaeckel <[email protected]>
06d03f6
to
ad0193a
Compare
@karel-m please correct me if I'm wrong FTR I've just force-pushed again, because I accidentally wiped my last changes by pushing an old version from my second machine ...
If I run the tests they pass, that's true, but I get this:
So these tests should succeed, but we don't accept those signatures because something's wrong in
IIRC perl-CryptX already does all those tests. I'm not sure whether it'd really make sense to add all those tests here, or whether it'd be better to contribute to perl-CryptX and use it as kind of "test harness". |
Argh! I build with CMake, and I just discovered that I have to set So here I go again, with better build setup. Let's see what I get to see this time around |
I built against GMP, and I only get these:
So it could be that at least some of the issues are bound to the math library. I'll dive into that this evening. |
FYI if you want to you can also build against all 3 MPI's 1 and run the tests. For me it looks as follows: $ cmake -DWITH_LTM=On -DWITH_TFM=On -DWITH_GMP=On -DBUILD_TESTING=On ..
[...]
$ make -j$(($(nproc)*2+1))
[...]
$ for mpi in ltm gmp tfm; do ./tests/test-ltc ecc $mpi | tail -n7; done
XXX-TODO should be valid - wycheproof / Edge case for Shamir multiplication
XXX-TODO should be valid - wycheproof / extreme value for k and edgecase s
XXX-TODO should be valid - wycheproof / extreme value for k
XXX-TODO should be valid - wycheproof / extreme value for k and s^-1
MP_PROVIDER = LibTomMath
MP_DIGIT_BIT = 60
sizeof(ltc_mp_digit) = 8
ecc_test............passed 3171.687ms
SUCCESS: passed=1 failed=0 nop=0 duration=3.2sec real=3.2sec
XXX-TODO should be valid - wycheproof / extreme value for k and edgecase s
XXX-TODO should be valid - wycheproof / extreme value for k
MP_PROVIDER = GNU MP
MP_DIGIT_BIT = 64
sizeof(ltc_mp_digit) = 8
ecc_test............passed 2633.805ms
SUCCESS: passed=1 failed=0 nop=0 duration=2.6sec real=2.6sec
Non-fatal 'no-operation' requested. (2)
/path/to/libtomcrypt/tests/ecc_test.c:1792:s_ecc_import_export()
XXX-TODO should be valid - wycheproof / Edge case for Shamir multiplication
XXX-TODO should be valid - wycheproof / extreme value for k and edgecase s
XXX-TODO should be valid - wycheproof / extreme value for k
XXX-TODO should be valid - wycheproof / extreme value for k and s^-1
Non-fatal 'no-operation' requested. (2)
/path/to/libtomcrypt/tests/ecc_test.c:1800:s_ecc_test_recovery()
MP_PROVIDER = TomsFastMath
MP_DIGIT_BIT = 64
sizeof(ltc_mp_digit) = 8
ecc_test............passed 1795.282ms
SUCCESS: passed=1 failed=0 nop=0 duration=1.8sec real=1.8sec So this indeed looks like the first and last failing tests are caused by something inside ltm (CC @czurnieden) resp. tfm, and the two other failing tests are universal ... Footnotes
|
Let's have a valid signature like:
Now let's patch the first
0x30
to0x31
like:We still verify the patched signature whereas wycheproof says that the patched signature should be considered invalid.
This PR contains just a failing test not the fix.