sha512_kunit.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright 2025 Google LLC
  4. */
  5. #include <crypto/sha2.h>
  6. #include "sha512-testvecs.h"
  7. #define HASH sha512
  8. #define HASH_CTX sha512_ctx
  9. #define HASH_SIZE SHA512_DIGEST_SIZE
  10. #define HASH_INIT sha512_init
  11. #define HASH_UPDATE sha512_update
  12. #define HASH_FINAL sha512_final
  13. #define HMAC_KEY hmac_sha512_key
  14. #define HMAC_CTX hmac_sha512_ctx
  15. #define HMAC_PREPAREKEY hmac_sha512_preparekey
  16. #define HMAC_INIT hmac_sha512_init
  17. #define HMAC_UPDATE hmac_sha512_update
  18. #define HMAC_FINAL hmac_sha512_final
  19. #define HMAC hmac_sha512
  20. #define HMAC_USINGRAWKEY hmac_sha512_usingrawkey
  21. #include "hash-test-template.h"
  22. static struct kunit_case hash_test_cases[] = {
  23. HASH_KUNIT_CASES,
  24. KUNIT_CASE(benchmark_hash),
  25. {},
  26. };
  27. static struct kunit_suite hash_test_suite = {
  28. .name = "sha512",
  29. .test_cases = hash_test_cases,
  30. .suite_init = hash_suite_init,
  31. .suite_exit = hash_suite_exit,
  32. };
  33. kunit_test_suite(hash_test_suite);
  34. MODULE_DESCRIPTION("KUnit tests and benchmark for SHA-512 and HMAC-SHA512");
  35. MODULE_LICENSE("GPL");