1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Copyright 2025 Google LLC 4 */ 5 #include <crypto/nh.h> 6 #include <kunit/test.h> 7 #include "nh-testvecs.h" 8 #include "test-utils.h" 9 10 static void test_nh(struct kunit *test) 11 { 12 u32 *key = memdup_buf(test, nh_test_key, NH_KEY_BYTES); 13 __le64 hash[NH_NUM_PASSES]; 14 15 le32_to_cpu_array(key, NH_KEY_WORDS); 16 17 nh(key, nh_test_msg, 16, hash); 18 KUNIT_ASSERT_MEMEQ(test, hash, nh_test_val16, NH_HASH_BYTES); 19 20 nh(key, nh_test_msg, 96, hash); 21 KUNIT_ASSERT_MEMEQ(test, hash, nh_test_val96, NH_HASH_BYTES); 22 23 nh(key, nh_test_msg, 256, hash); 24 KUNIT_ASSERT_MEMEQ(test, hash, nh_test_val256, NH_HASH_BYTES); 25 26 nh(key, nh_test_msg, 1024, hash); 27 KUNIT_ASSERT_MEMEQ(test, hash, nh_test_val1024, NH_HASH_BYTES); 28 } 29 30 static struct kunit_case nh_test_cases[] = { 31 KUNIT_CASE(test_nh), 32 {}, 33 }; 34 35 static struct kunit_suite nh_test_suite = { 36 .name = "nh", 37 .test_cases = nh_test_cases, 38 }; 39 kunit_test_suite(nh_test_suite); 40 41 MODULE_DESCRIPTION("KUnit tests for NH"); 42 MODULE_LICENSE("GPL"); 43