Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

52 Zeilen
1.7 KiB

  1. """
  2. Checks that (hash of the) KATs (in NIST format) produced on this platform matches
  3. the one provided in the META file for every scheme/implementation.
  4. Note that this only uses the first test case from the NIST-format KAT files.
  5. The appropriate hash can be generated from the original submission's KAT file
  6. using the command:
  7. cat PQCkemKAT_whatever.rsp | head -n 8 | tail -n 6 | sha256sum
  8. """
  9. import hashlib
  10. import os
  11. import pqclean
  12. import helpers
  13. import unittest
  14. def test_nistkat():
  15. for scheme in pqclean.Scheme.all_schemes():
  16. if scheme.type != 'kem': continue
  17. for implementation in scheme.implementations:
  18. if helpers.permit_test('nistkat', implementation):
  19. yield check_nistkat, implementation
  20. def check_nistkat(implementation):
  21. if implementation.scheme.name == "kyber768":
  22. raise unittest.SkipTest("Temporarily skip NIST KAT check for kyber768 since it's an outdated implementation")
  23. helpers.make('nistkat',
  24. TYPE=implementation.scheme.type,
  25. SCHEME=implementation.scheme.name,
  26. IMPLEMENTATION=implementation.name,
  27. working_dir=os.path.join('..', 'test'))
  28. out = helpers.run_subprocess(
  29. [os.path.join('..', 'bin', 'nistkat_{}_{}{}'.format(
  30. implementation.scheme.name,
  31. implementation.name,
  32. '.exe' if os.name == 'nt' else ''
  33. ))],
  34. os.path.join('..', 'bin'),
  35. ).replace('\r', '')
  36. assert(implementation.scheme.metadata()['nistkat-sha256'].lower()
  37. == hashlib.sha256(out.encode('utf-8')).hexdigest().lower())
  38. if __name__ == '__main__':
  39. try:
  40. import nose2
  41. nose2.main()
  42. except ImportError:
  43. import nose
  44. nose.runmodule()