cipher_hash_test.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_AES_NI)
  14. if (aesni_is_supported()) {
  15. DO(aesni_test());
  16. }
  17. DO(rijndael_test());
  18. #endif
  19. #if defined(LTC_RIJNDAEL)
  20. #ifndef ENCRYPT_ONLY
  21. DO(aes_test());
  22. #else
  23. DO(aes_enc_test());
  24. #endif
  25. #endif
  26. /* test stream ciphers */
  27. #ifdef LTC_CHACHA
  28. DO(chacha_test());
  29. #endif
  30. #ifdef LTC_SALSA20
  31. DO(salsa20_test());
  32. #endif
  33. #ifdef LTC_XSALSA20
  34. DO(xsalsa20_test());
  35. #endif
  36. #ifdef LTC_SOSEMANUK
  37. DO(sosemanuk_test());
  38. #endif
  39. #ifdef LTC_RABBIT
  40. DO(rabbit_test());
  41. #endif
  42. #ifdef LTC_RC4_STREAM
  43. DO(rc4_stream_test());
  44. #endif
  45. #ifdef LTC_SOBER128_STREAM
  46. DO(sober128_stream_test());
  47. #endif
  48. /* test hashes */
  49. for (x = 0; hash_descriptor[x].name != NULL; x++) {
  50. DOX(hash_descriptor[x].test(), hash_descriptor[x].name);
  51. }
  52. #ifdef LTC_SHA3
  53. /* SHAKE128 + SHAKE256 tests are a bit special */
  54. DOX(sha3_shake_test(), "sha3_shake");
  55. #endif
  56. return 0;
  57. }