lib/crypto/sparc/aes.h
Source file repositories/reference/linux-study-clean/lib/crypto/sparc/aes.h
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/sparc/aes.h- Extension
.h- Size
- 4945 bytes
- Lines
- 150
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/fpumacro.hasm/opcodes.hasm/pstate.hasm/elf.h
Detected Declarations
function aes_preparekey_archfunction aes_sparc64_encryptfunction aes_encrypt_archfunction aes_sparc64_decryptfunction aes_decrypt_archfunction aes_mod_init_archexport aes_sparc64_key_expandexport aes_sparc64_load_encrypt_keys_128export aes_sparc64_load_encrypt_keys_192export aes_sparc64_load_encrypt_keys_256export aes_sparc64_load_decrypt_keys_128export aes_sparc64_load_decrypt_keys_192export aes_sparc64_load_decrypt_keys_256export aes_sparc64_ecb_encrypt_128export aes_sparc64_ecb_encrypt_192export aes_sparc64_ecb_encrypt_256export aes_sparc64_ecb_decrypt_128export aes_sparc64_ecb_decrypt_192export aes_sparc64_ecb_decrypt_256export aes_sparc64_cbc_encrypt_128export aes_sparc64_cbc_encrypt_192export aes_sparc64_cbc_encrypt_256export aes_sparc64_cbc_decrypt_128export aes_sparc64_cbc_decrypt_192export aes_sparc64_cbc_decrypt_256export aes_sparc64_ctr_crypt_128export aes_sparc64_ctr_crypt_192export aes_sparc64_ctr_crypt_256
Annotated Snippet
if (IS_ALIGNED((uintptr_t)in_key, 4)) {
aes_sparc64_key_expand((const u32 *)in_key,
k->sparc_rndkeys, key_len);
} else {
memcpy(aligned_key, in_key, key_len);
aes_sparc64_key_expand(aligned_key,
k->sparc_rndkeys, key_len);
memzero_explicit(aligned_key, key_len);
}
/*
* Note that nothing needs to be written to inv_k (if it's
* non-NULL) here, since the SPARC64 assembly code uses
* k->sparc_rndkeys for both encryption and decryption.
*/
} else {
aes_expandkey_generic(k->rndkeys,
inv_k ? inv_k->inv_rndkeys : NULL,
in_key, key_len);
}
}
static void aes_sparc64_encrypt(const struct aes_enckey *key,
const u32 *input, u32 *output)
{
if (key->len == AES_KEYSIZE_128)
aes_sparc64_encrypt_128(key->k.sparc_rndkeys, input, output);
else if (key->len == AES_KEYSIZE_192)
aes_sparc64_encrypt_192(key->k.sparc_rndkeys, input, output);
else
aes_sparc64_encrypt_256(key->k.sparc_rndkeys, input, output);
}
static void aes_encrypt_arch(const struct aes_enckey *key,
u8 out[AES_BLOCK_SIZE],
const u8 in[AES_BLOCK_SIZE])
{
u32 bounce_buf[AES_BLOCK_SIZE / 4];
if (static_branch_likely(&have_aes_opcodes)) {
if (IS_ALIGNED((uintptr_t)in | (uintptr_t)out, 4)) {
aes_sparc64_encrypt(key, (const u32 *)in, (u32 *)out);
} else {
memcpy(bounce_buf, in, AES_BLOCK_SIZE);
aes_sparc64_encrypt(key, bounce_buf, bounce_buf);
memcpy(out, bounce_buf, AES_BLOCK_SIZE);
}
} else {
aes_encrypt_generic(key->k.rndkeys, key->nrounds, out, in);
}
}
static void aes_sparc64_decrypt(const struct aes_key *key,
const u32 *input, u32 *output)
{
if (key->len == AES_KEYSIZE_128)
aes_sparc64_decrypt_128(key->k.sparc_rndkeys, input, output);
else if (key->len == AES_KEYSIZE_192)
aes_sparc64_decrypt_192(key->k.sparc_rndkeys, input, output);
else
aes_sparc64_decrypt_256(key->k.sparc_rndkeys, input, output);
}
static void aes_decrypt_arch(const struct aes_key *key,
u8 out[AES_BLOCK_SIZE],
const u8 in[AES_BLOCK_SIZE])
{
u32 bounce_buf[AES_BLOCK_SIZE / 4];
if (static_branch_likely(&have_aes_opcodes)) {
if (IS_ALIGNED((uintptr_t)in | (uintptr_t)out, 4)) {
aes_sparc64_decrypt(key, (const u32 *)in, (u32 *)out);
} else {
memcpy(bounce_buf, in, AES_BLOCK_SIZE);
aes_sparc64_decrypt(key, bounce_buf, bounce_buf);
memcpy(out, bounce_buf, AES_BLOCK_SIZE);
}
} else {
aes_decrypt_generic(key->inv_k.inv_rndkeys, key->nrounds,
out, in);
}
}
#define aes_mod_init_arch aes_mod_init_arch
static void aes_mod_init_arch(void)
{
unsigned long cfr;
if (!(sparc64_elf_hwcap & HWCAP_SPARC_CRYPTO))
return;
Annotation
- Immediate include surface: `asm/fpumacro.h`, `asm/opcodes.h`, `asm/pstate.h`, `asm/elf.h`.
- Detected declarations: `function aes_preparekey_arch`, `function aes_sparc64_encrypt`, `function aes_encrypt_arch`, `function aes_sparc64_decrypt`, `function aes_decrypt_arch`, `function aes_mod_init_arch`, `export aes_sparc64_key_expand`, `export aes_sparc64_load_encrypt_keys_128`, `export aes_sparc64_load_encrypt_keys_192`, `export aes_sparc64_load_encrypt_keys_256`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration 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.