lib/crypto/tests/polyval_kunit.c
Source file repositories/reference/linux-study-clean/lib/crypto/tests/polyval_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/tests/polyval_kunit.c- Extension
.c- Size
- 6904 bytes
- Lines
- 224
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/gf128hash.hpolyval-testvecs.hhash-test-template.h
Detected Declarations
struct polyval_irq_test_statefunction polyval_init_withtestkeyfunction polyval_withtestkeyfunction RFC8452function test_polyval_allones_key_and_messagefunction identicalfunction test_polyval_with_guarded_keyfunction __alignof__function polyval_irq_test_funcfunction polyval_preparekeyfunction polyval_suite_initfunction polyval_suite_exit
Annotated Snippet
struct polyval_irq_test_state {
struct polyval_key expected_key;
u8 raw_key[POLYVAL_BLOCK_SIZE];
};
static bool polyval_irq_test_func(void *state_)
{
struct polyval_irq_test_state *state = state_;
struct polyval_key key;
polyval_preparekey(&key, state->raw_key);
return memcmp(&key, &state->expected_key, sizeof(key)) == 0;
}
/*
* Test that polyval_preparekey() produces the same output regardless of whether
* FPU or vector registers are usable when it is called.
*/
static void test_polyval_preparekey_in_irqs(struct kunit *test)
{
struct polyval_irq_test_state state;
rand_bytes(state.raw_key, sizeof(state.raw_key));
polyval_preparekey(&state.expected_key, state.raw_key);
kunit_run_irq_test(test, polyval_irq_test_func, 200000, &state);
}
static int polyval_suite_init(struct kunit_suite *suite)
{
u8 raw_key[POLYVAL_BLOCK_SIZE];
rand_bytes_seeded_from_len(raw_key, sizeof(raw_key));
polyval_preparekey(&test_key, raw_key);
return hash_suite_init(suite);
}
static void polyval_suite_exit(struct kunit_suite *suite)
{
hash_suite_exit(suite);
}
static struct kunit_case polyval_test_cases[] = {
HASH_KUNIT_CASES,
KUNIT_CASE(test_polyval_rfc8452_testvec),
KUNIT_CASE(test_polyval_allones_key_and_message),
KUNIT_CASE(test_polyval_with_guarded_key),
KUNIT_CASE(test_polyval_with_minimally_aligned_key),
KUNIT_CASE(test_polyval_preparekey_in_irqs),
KUNIT_CASE(benchmark_hash),
{},
};
static struct kunit_suite polyval_test_suite = {
.name = "polyval",
.test_cases = polyval_test_cases,
.suite_init = polyval_suite_init,
.suite_exit = polyval_suite_exit,
};
kunit_test_suite(polyval_test_suite);
MODULE_DESCRIPTION("KUnit tests and benchmark for POLYVAL");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `crypto/gf128hash.h`, `polyval-testvecs.h`, `hash-test-template.h`.
- Detected declarations: `struct polyval_irq_test_state`, `function polyval_init_withtestkey`, `function polyval_withtestkey`, `function RFC8452`, `function test_polyval_allones_key_and_message`, `function identical`, `function test_polyval_with_guarded_key`, `function __alignof__`, `function polyval_irq_test_func`, `function polyval_preparekey`.
- Atlas domain: Kernel Services / lib.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.