lib/crypto/riscv/chacha.h
Source file repositories/reference/linux-study-clean/lib/crypto/riscv/chacha.h
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/riscv/chacha.h- Extension
.h- Size
- 1528 bytes
- Lines
- 52
- 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
asm/simd.hasm/vector.hcrypto/internal/simd.hlinux/linkage.h
Detected Declarations
function chacha_crypt_archfunction chacha_mod_init_arch
Annotated Snippet
#include <asm/simd.h>
#include <asm/vector.h>
#include <crypto/internal/simd.h>
#include <linux/linkage.h>
static __ro_after_init DEFINE_STATIC_KEY_FALSE(use_zvkb);
asmlinkage void chacha_zvkb(struct chacha_state *state, const u8 *in, u8 *out,
size_t nblocks, int nrounds);
#define hchacha_block_arch hchacha_block_generic /* not implemented yet */
static void chacha_crypt_arch(struct chacha_state *state, u8 *dst,
const u8 *src, unsigned int bytes, int nrounds)
{
u8 block_buffer[CHACHA_BLOCK_SIZE];
unsigned int full_blocks = bytes / CHACHA_BLOCK_SIZE;
unsigned int tail_bytes = bytes % CHACHA_BLOCK_SIZE;
if (!static_branch_likely(&use_zvkb) || !crypto_simd_usable())
return chacha_crypt_generic(state, dst, src, bytes, nrounds);
kernel_vector_begin();
if (full_blocks) {
chacha_zvkb(state, src, dst, full_blocks, nrounds);
src += full_blocks * CHACHA_BLOCK_SIZE;
dst += full_blocks * CHACHA_BLOCK_SIZE;
}
if (tail_bytes) {
memcpy(block_buffer, src, tail_bytes);
chacha_zvkb(state, block_buffer, block_buffer, 1, nrounds);
memcpy(dst, block_buffer, tail_bytes);
}
kernel_vector_end();
}
#define chacha_mod_init_arch chacha_mod_init_arch
static void chacha_mod_init_arch(void)
{
if (riscv_isa_extension_available(NULL, ZVKB) &&
riscv_vector_vlen() >= 128)
static_branch_enable(&use_zvkb);
}
Annotation
- Immediate include surface: `asm/simd.h`, `asm/vector.h`, `crypto/internal/simd.h`, `linux/linkage.h`.
- Detected declarations: `function chacha_crypt_arch`, `function chacha_mod_init_arch`.
- 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.