cipher_hash_test.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
  2. /* SPDX-License-Identifier: Unlicense */
  3. /* test the ciphers and hashes using their built-in self-tests */
  4. #include <tomcrypt_test.h>
  5. int cipher_hash_test(void)
  6. {
  7. int x;
  8. /* test block ciphers */
  9. for (x = 0; cipher_descriptor[x].name != NULL; x++) {
  10. DOX(cipher_descriptor[x].test(), cipher_descriptor[x].name);
  11. }
  12. /* explicit AES-NI test */
  13. #if defined(LTC_HAS_AES_NI)
  14. if (aesni_is_supported()) {
  15. DO(aesni_test());
  16. }
  17. DO(rijndael_test());
  18. #endif
  19. /* test stream ciphers */
  20. #ifdef LTC_CHACHA
  21. DO(chacha_test());
  22. #endif
  23. #ifdef LTC_SALSA20
  24. DO(salsa20_test());
  25. #endif
  26. #ifdef LTC_XSALSA20
  27. DO(xsalsa20_test());
  28. #endif
  29. #ifdef LTC_SOSEMANUK
  30. DO(sosemanuk_test());
  31. #endif
  32. #ifdef LTC_RABBIT
  33. DO(rabbit_test());
  34. #endif
  35. #ifdef LTC_RC4_STREAM
  36. DO(rc4_stream_test());
  37. #endif
  38. #ifdef LTC_SOBER128_STREAM
  39. DO(sober128_stream_test());
  40. #endif
  41. /* test hashes */
  42. for (x = 0; hash_descriptor[x].name != NULL; x++) {
  43. DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
  44. }
  45. #ifdef LTC_SHA3
  46. /* SHAKE128 + SHAKE256 tests are a bit special */
  47. DOX(sha3_shake_test(), "sha3_shake");
  48. #endif
  49. return 0;
  50. }