lib/crypto/tests/poly1305_kunit.c
Source file repositories/reference/linux-study-clean/lib/crypto/tests/poly1305_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/tests/poly1305_kunit.c- Extension
.c- Size
- 5600 bytes
- Lines
- 166
- 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/poly1305.hpoly1305-testvecs.hhash-test-template.h
Detected Declarations
function poly1305function poly1305_init_withtestkeyfunction poly1305_withtestkeyfunction poly1305_suite_initfunction poly1305_suite_exitfunction lengthsfunction test_poly1305_reduction_edge_cases
Annotated Snippet
if (i <= 5) {
expected_mac[0] = 5 - i;
memset(&expected_mac[1], 0, POLY1305_DIGEST_SIZE - 1);
} else {
expected_mac[0] = -i;
memset(&expected_mac[1], 0xff,
POLY1305_DIGEST_SIZE - 1);
}
/* Compute and verify the MAC. */
poly1305(key, data, sizeof(data), actual_mac);
KUNIT_ASSERT_MEMEQ(test, actual_mac, expected_mac,
POLY1305_DIGEST_SIZE);
}
}
static struct kunit_case poly1305_test_cases[] = {
HASH_KUNIT_CASES,
KUNIT_CASE(test_poly1305_allones_keys_and_message),
KUNIT_CASE(test_poly1305_reduction_edge_cases),
KUNIT_CASE(benchmark_hash),
{},
};
static struct kunit_suite poly1305_test_suite = {
.name = "poly1305",
.test_cases = poly1305_test_cases,
.suite_init = poly1305_suite_init,
.suite_exit = poly1305_suite_exit,
};
kunit_test_suite(poly1305_test_suite);
MODULE_DESCRIPTION("KUnit tests and benchmark for Poly1305");
MODULE_LICENSE("GPL");
Annotation
- Immediate include surface: `crypto/poly1305.h`, `poly1305-testvecs.h`, `hash-test-template.h`.
- Detected declarations: `function poly1305`, `function poly1305_init_withtestkey`, `function poly1305_withtestkey`, `function poly1305_suite_init`, `function poly1305_suite_exit`, `function lengths`, `function test_poly1305_reduction_edge_cases`.
- 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.