Skip to content

Conversation

@armcc
Copy link
Contributor

@armcc armcc commented Oct 8, 2019

  • Drop unused 'num' field from struct des_test_case.
  • Fix the order of arguments passed to compare_testvector() for the
    "DES" tests (actual -vs- expected buffers were swapped, leading to
    misleading error messages for failing tests).
  • Move the 3des test vectors which were previously included in
    des_test() into des3_test(). Note that these 3des test vectors
    were previously guarded by LTC_TEST_EXT, so even though they
    always failed when run as des tests, the failure was not seen by
    default.
  • Minor indent fixes.

Signed-off-by: Andre McCurdy armccurdy@gmail.com

Checklist

  • tests are added or updated

@sjaeckel
Copy link
Member

sjaeckel commented Oct 8, 2019

Thanks for the PR!

  • Drop unused 'num' field from struct des_test_case.
  • Fix the order of arguments passed to compare_testvector() for the
    "DES" tests (actual -vs- expected buffers were swapped, leading to
    misleading error messages for failing tests).
  • Minor indent fixes.

Those 3 points are fine IMO

  • Move the 3des test vectors which were previously included in
    des_test() into des3_test(). Note that these 3des test vectors
    were previously guarded by LTC_TEST_EXT, so even though they
    always failed when run as des tests, the failure was not seen by
    default.

This part is misleading as they were never explicitly 3DES TV's but just "more" DES TV's and now you're (ab)using the fact that the same key used thrice results in the same result as a single DES round...

I think this part should be reverted. @karel-m your thoughts?

@sjaeckel
Copy link
Member

sjaeckel commented Oct 8, 2019

btw if you're already at it, feel free to re-factor the TV's in des_test() and de-duplicate them :)

@armcc
Copy link
Contributor Author

armcc commented Oct 8, 2019

Thanks for the feedback! I started looking at the extra test vectors because they failed when I enabled them. Googling the test vector values found a golang test suite that uses them for 3DES, so I just copied that approach. However, I see now that the real bug in the current LTC code is that these vectors are marked as DES decryption tests when they should be DES encryption tests... just fixing that makes the tests pass. I'll send an updated PR.

@armcc armcc force-pushed the improve-des-tests branch from aed1a1a to 8646c0c Compare October 9, 2019 01:58
Copy link
Member

@sjaeckel sjaeckel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@armcc armcc force-pushed the improve-des-tests branch from 8646c0c to d3f4398 Compare October 10, 2019 02:01
@sjaeckel
Copy link
Member

Thanks! Looks very good now and thx for the TDES TV's!

Now you only need to fix this travis error and we're good to go :-)

https://travis-ci.org/libtom/libtomcrypt/jobs/595904038

btw. you can install the pre-commit hooks via make install_hooks which will then run the same basic tests which failed in said build job.

 - Drop unused 'num' field from struct des_test_case.
 - Fix the order of arguments passed to compare_testvector() (actual
   and expected buffers were swapped, leading to misleading error
   messages for failing tests).
 - Enable all DES test vectors by default and use them for both
   encrypt and decrypt. That allows the struct des_test_case 'mode'
   field (which was previously incorrect for the LTC_TEST_EXT tests)
   to be dropped.
 - Run the "encrypt / decrypt all zero's" tests once, instead of
   running repeatedly from within the test vectors loop.
 - Add minimal set of 128bit key 3DES test vectors.
 - Try to more closely align the des_test() and des3_test() functions
   (common flow, common variable names, etc).
 - Minor indent fixes.

Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
@armcc armcc force-pushed the improve-des-tests branch from d3f4398 to d85045e Compare October 10, 2019 08:00
@armcc
Copy link
Contributor Author

armcc commented Oct 10, 2019

The indent issue should now be fixed but it looks like the Travis build then failed for some other reason? Should I force push the latest version again to try to re-trigger Travis?

@sjaeckel
Copy link
Member

The indent issue should now be fixed

yes, that's fixed

it looks like the Travis build then failed for some other reason

yeah, there's an issue with their infrastructure, c.f. [1] resp. [2]

Should I force push the latest version again to try to re-trigger Travis?

no need, I've just restarted the failed builds

[1] https://travis-ci.community/t/sometimes-build-fails-when-apt-is-updating-postgresql-apt-repository/4872
[2] travis-ci/travis-build#1771

@sjaeckel sjaeckel merged commit 8e044b8 into libtom:develop Oct 11, 2019
@armcc armcc deleted the improve-des-tests branch October 14, 2019 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants