arch/arm64/crypto/sm4-ce-glue.c
Source file repositories/reference/linux-study-clean/arch/arm64/crypto/sm4-ce-glue.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm64/crypto/sm4-ce-glue.c- Extension
.c- Size
- 18902 bytes
- Lines
- 720
- Domain
- Architecture Layer
- Bucket
- arch/arm64
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- 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.hcrypto/b128ops.hcrypto/internal/hash.hcrypto/internal/skcipher.hcrypto/scatterwalk.hcrypto/sm4.hcrypto/utils.hcrypto/xts.hlinux/cpufeature.hlinux/kernel.hlinux/module.hlinux/string.h
Detected Declarations
struct sm4_xts_ctxstruct sm4_mac_tfm_ctxstruct sm4_mac_desc_ctxfunction sm4_setkeyfunction sm4_xts_setkeyfunction scoped_ksimdfunction sm4_ecb_do_cryptfunction scoped_ksimdfunction sm4_ecb_encryptfunction sm4_ecb_decryptfunction sm4_cbc_cryptfunction sm4_cbc_encryptfunction sm4_cbc_decryptfunction sm4_cbc_cts_cryptfunction scoped_ksimdfunction sm4_cbc_cts_encryptfunction sm4_cbc_cts_decryptfunction sm4_ctr_cryptfunction scoped_ksimdfunction sm4_xts_cryptfunction scoped_ksimdfunction sm4_xts_encryptfunction sm4_xts_decryptfunction sm4_cbcmac_setkeyfunction sm4_cmac_setkeyfunction scoped_ksimdfunction sm4_xcbc_setkeyfunction scoped_ksimdfunction sm4_mac_initfunction sm4_mac_updatefunction sm4_cmac_finupfunction sm4_cbcmac_finupfunction sm4_initfunction sm4_exitexport sm4_ce_expand_keyexport sm4_ce_crypt_blockexport sm4_ce_cbc_enc
Annotated Snippet
struct sm4_xts_ctx {
struct sm4_ctx key1;
struct sm4_ctx key2;
};
struct sm4_mac_tfm_ctx {
struct sm4_ctx key;
u8 __aligned(8) consts[];
};
struct sm4_mac_desc_ctx {
u8 digest[SM4_BLOCK_SIZE];
};
static int sm4_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int key_len)
{
struct sm4_ctx *ctx = crypto_skcipher_ctx(tfm);
if (key_len != SM4_KEY_SIZE)
return -EINVAL;
scoped_ksimd()
sm4_ce_expand_key(key, ctx->rkey_enc, ctx->rkey_dec,
crypto_sm4_fk, crypto_sm4_ck);
return 0;
}
static int sm4_xts_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int key_len)
{
struct sm4_xts_ctx *ctx = crypto_skcipher_ctx(tfm);
int ret;
if (key_len != SM4_KEY_SIZE * 2)
return -EINVAL;
ret = xts_verify_key(tfm, key, key_len);
if (ret)
return ret;
scoped_ksimd() {
sm4_ce_expand_key(key, ctx->key1.rkey_enc,
ctx->key1.rkey_dec, crypto_sm4_fk, crypto_sm4_ck);
sm4_ce_expand_key(&key[SM4_KEY_SIZE], ctx->key2.rkey_enc,
ctx->key2.rkey_dec, crypto_sm4_fk, crypto_sm4_ck);
}
return 0;
}
static int sm4_ecb_do_crypt(struct skcipher_request *req, const u32 *rkey)
{
struct skcipher_walk walk;
unsigned int nbytes;
int err;
err = skcipher_walk_virt(&walk, req, false);
while ((nbytes = walk.nbytes) > 0) {
const u8 *src = walk.src.virt.addr;
u8 *dst = walk.dst.virt.addr;
unsigned int nblks;
scoped_ksimd() {
nblks = BYTES2BLKS(nbytes);
if (nblks) {
sm4_ce_crypt(rkey, dst, src, nblks);
nbytes -= nblks * SM4_BLOCK_SIZE;
}
}
err = skcipher_walk_done(&walk, nbytes);
}
return err;
}
static int sm4_ecb_encrypt(struct skcipher_request *req)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct sm4_ctx *ctx = crypto_skcipher_ctx(tfm);
return sm4_ecb_do_crypt(req, ctx->rkey_enc);
}
static int sm4_ecb_decrypt(struct skcipher_request *req)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct sm4_ctx *ctx = crypto_skcipher_ctx(tfm);
Annotation
- Immediate include surface: `asm/simd.h`, `crypto/b128ops.h`, `crypto/internal/hash.h`, `crypto/internal/skcipher.h`, `crypto/scatterwalk.h`, `crypto/sm4.h`, `crypto/utils.h`, `crypto/xts.h`.
- Detected declarations: `struct sm4_xts_ctx`, `struct sm4_mac_tfm_ctx`, `struct sm4_mac_desc_ctx`, `function sm4_setkey`, `function sm4_xts_setkey`, `function scoped_ksimd`, `function sm4_ecb_do_crypt`, `function scoped_ksimd`, `function sm4_ecb_encrypt`, `function sm4_ecb_decrypt`.
- Atlas domain: Architecture Layer / arch/arm64.
- 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.