lib/crypto/powerpc/aes.h
Source file repositories/reference/linux-study-clean/lib/crypto/powerpc/aes.h
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/powerpc/aes.h- Extension
.h- Size
- 7054 bytes
- Lines
- 241
- 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/simd.hasm/switch_to.hlinux/cpufeature.hlinux/jump_label.hlinux/preempt.hlinux/uaccess.h
Detected Declarations
function spe_beginfunction spe_endfunction aes_preparekey_archfunction aes_encrypt_archfunction aes_decrypt_archfunction is_vsx_formatfunction bytesfunction aes_preparekey_archfunction aes_encrypt_archfunction aes_decrypt_archfunction aes_mod_init_archexport ppc_expand_key_128export ppc_expand_key_192export ppc_expand_key_256export ppc_generate_decrypt_keyexport ppc_encrypt_ecbexport ppc_decrypt_ecbexport ppc_encrypt_cbcexport ppc_decrypt_cbcexport ppc_crypt_ctrexport ppc_encrypt_xtsexport ppc_decrypt_xtsexport aes_p8_set_encrypt_keyexport aes_p8_set_decrypt_keyexport aes_p8_encryptexport aes_p8_decryptexport aes_p8_cbc_encryptexport aes_p8_ctr32_encrypt_blocksexport aes_p8_xts_encryptexport aes_p8_xts_decrypt
Annotated Snippet
if (inv_k) {
ret = aes_p8_set_decrypt_key(in_key, keybits,
&inv_k->p8);
/* ... and likewise for aes_p8_set_decrypt_key(). */
WARN_ON_ONCE(ret);
}
disable_kernel_vsx();
pagefault_enable();
preempt_enable();
} else {
aes_expandkey_generic(k->rndkeys,
inv_k ? inv_k->inv_rndkeys : NULL,
in_key, key_len);
/* Mark the key as using the generic format. */
k->p8.nrounds = 0;
if (inv_k)
inv_k->p8.nrounds = 0;
}
}
static void aes_encrypt_arch(const struct aes_enckey *key,
u8 out[AES_BLOCK_SIZE],
const u8 in[AES_BLOCK_SIZE])
{
if (static_branch_likely(&have_vec_crypto) &&
likely(is_vsx_format(&key->k.p8) && may_use_simd())) {
preempt_disable();
pagefault_disable();
enable_kernel_vsx();
aes_p8_encrypt(in, out, &key->k.p8);
disable_kernel_vsx();
pagefault_enable();
preempt_enable();
} else if (unlikely(is_vsx_format(&key->k.p8))) {
/*
* This handles (the hopefully extremely rare) case where a key
* was prepared using the VSX optimized format, then encryption
* is done in a context that cannot use VSX instructions.
*/
u32 rndkeys[AES_MAX_KEYLENGTH_U32];
for (int i = 0; i < 4 * (key->nrounds + 1); i += 4)
rndkey_from_vsx(&rndkeys[i],
&key->k.p8.rndkeys[i], false);
aes_encrypt_generic(rndkeys, key->nrounds, out, in);
} else {
aes_encrypt_generic(key->k.rndkeys, key->nrounds, out, in);
}
}
static void aes_decrypt_arch(const struct aes_key *key, u8 out[AES_BLOCK_SIZE],
const u8 in[AES_BLOCK_SIZE])
{
if (static_branch_likely(&have_vec_crypto) &&
likely(is_vsx_format(&key->inv_k.p8) && may_use_simd())) {
preempt_disable();
pagefault_disable();
enable_kernel_vsx();
aes_p8_decrypt(in, out, &key->inv_k.p8);
disable_kernel_vsx();
pagefault_enable();
preempt_enable();
} else if (unlikely(is_vsx_format(&key->inv_k.p8))) {
/*
* This handles (the hopefully extremely rare) case where a key
* was prepared using the VSX optimized format, then decryption
* is done in a context that cannot use VSX instructions.
*/
u32 inv_rndkeys[AES_MAX_KEYLENGTH_U32];
int i;
rndkey_from_vsx(&inv_rndkeys[0],
&key->inv_k.p8.rndkeys[0], false);
for (i = 4; i < 4 * key->nrounds; i += 4) {
rndkey_from_vsx(&inv_rndkeys[i],
&key->inv_k.p8.rndkeys[i], true);
}
rndkey_from_vsx(&inv_rndkeys[i],
&key->inv_k.p8.rndkeys[i], false);
aes_decrypt_generic(inv_rndkeys, key->nrounds, out, in);
} 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)
{
if (cpu_has_feature(CPU_FTR_ARCH_207S) &&
Annotation
- Immediate include surface: `asm/simd.h`, `asm/switch_to.h`, `linux/cpufeature.h`, `linux/jump_label.h`, `linux/preempt.h`, `linux/uaccess.h`.
- Detected declarations: `function spe_begin`, `function spe_end`, `function aes_preparekey_arch`, `function aes_encrypt_arch`, `function aes_decrypt_arch`, `function is_vsx_format`, `function bytes`, `function aes_preparekey_arch`, `function aes_encrypt_arch`, `function aes_decrypt_arch`.
- 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.