lib/crypto/s390/aes.h
Source file repositories/reference/linux-study-clean/lib/crypto/s390/aes.h
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/s390/aes.h- Extension
.h- Size
- 3154 bytes
- Lines
- 107
- 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/cpacf.hlinux/cpufeature.h
Detected Declarations
function aes_preparekey_archfunction aes_crypt_s390function aes_encrypt_archfunction aes_decrypt_archfunction aes_mod_init_arch
Annotated Snippet
if (static_branch_likely(&have_cpacf_aes128)) {
memcpy(k->raw_key, in_key, AES_KEYSIZE_128);
return;
}
} else if (key_len == AES_KEYSIZE_192) {
if (static_branch_likely(&have_cpacf_aes192)) {
memcpy(k->raw_key, in_key, AES_KEYSIZE_192);
return;
}
} else {
if (static_branch_likely(&have_cpacf_aes256)) {
memcpy(k->raw_key, in_key, AES_KEYSIZE_256);
return;
}
}
aes_expandkey_generic(k->rndkeys, inv_k ? inv_k->inv_rndkeys : NULL,
in_key, key_len);
}
static inline bool aes_crypt_s390(const struct aes_enckey *key,
u8 out[AES_BLOCK_SIZE],
const u8 in[AES_BLOCK_SIZE], int decrypt)
{
if (key->len == AES_KEYSIZE_128) {
if (static_branch_likely(&have_cpacf_aes128)) {
cpacf_km(CPACF_KM_AES_128 | decrypt,
(void *)key->k.raw_key, out, in,
AES_BLOCK_SIZE);
return true;
}
} else if (key->len == AES_KEYSIZE_192) {
if (static_branch_likely(&have_cpacf_aes192)) {
cpacf_km(CPACF_KM_AES_192 | decrypt,
(void *)key->k.raw_key, out, in,
AES_BLOCK_SIZE);
return true;
}
} else {
if (static_branch_likely(&have_cpacf_aes256)) {
cpacf_km(CPACF_KM_AES_256 | decrypt,
(void *)key->k.raw_key, out, in,
AES_BLOCK_SIZE);
return true;
}
}
return false;
}
static void aes_encrypt_arch(const struct aes_enckey *key,
u8 out[AES_BLOCK_SIZE],
const u8 in[AES_BLOCK_SIZE])
{
if (likely(aes_crypt_s390(key, out, in, 0)))
return;
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 (likely(aes_crypt_s390((const struct aes_enckey *)key, out, in,
CPACF_DECRYPT)))
return;
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_have_feature(S390_CPU_FEATURE_MSA)) {
cpacf_mask_t km_functions;
cpacf_query(CPACF_KM, &km_functions);
if (cpacf_test_func(&km_functions, CPACF_KM_AES_128))
static_branch_enable(&have_cpacf_aes128);
if (cpacf_test_func(&km_functions, CPACF_KM_AES_192))
static_branch_enable(&have_cpacf_aes192);
if (cpacf_test_func(&km_functions, CPACF_KM_AES_256))
static_branch_enable(&have_cpacf_aes256);
}
}
Annotation
- Immediate include surface: `asm/cpacf.h`, `linux/cpufeature.h`.
- Detected declarations: `function aes_preparekey_arch`, `function aes_crypt_s390`, `function aes_encrypt_arch`, `function aes_decrypt_arch`, `function aes_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.