cipher_hash_test.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. DO(aes_enc_test());
  20. /* test stream ciphers */
  21. #ifdef LTC_CHACHA
  22. DO(chacha_test());
  23. #endif
  24. #ifdef LTC_SALSA20
  25. DO(salsa20_test());
  26. #endif
  27. #ifdef LTC_XSALSA20
  28. DO(xsalsa20_test());
  29. #endif
  30. #ifdef LTC_SOSEMANUK
  31. DO(sosemanuk_test());
  32. #endif
  33. #ifdef LTC_RABBIT
  34. DO(rabbit_test());
  35. #endif
  36. #ifdef LTC_RC4_STREAM
  37. DO(rc4_stream_test());
  38. #endif
  39. #ifdef LTC_SOBER128_STREAM
  40. DO(sober128_stream_test());
  41. #endif
  42. /* test hashes */
  43. for (x = 0; hash_descriptor[x].name != NULL; x++) {
  44. DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
  45. }
  46. #ifdef LTC_SHA3
  47. /* SHAKE128 + SHAKE256 tests are a bit special */
  48. DOX(sha3_shake_test(), "sha3_shake");
  49. #endif
  50. return 0;
  51. }