crypto/akcipher.c
Source file repositories/reference/linux-study-clean/crypto/akcipher.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/akcipher.c- Extension
.c- Size
- 6277 bytes
- Lines
- 253
- Domain
- Kernel Services
- Bucket
- crypto
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/internal/akcipher.hlinux/cryptouser.hlinux/errno.hlinux/kernel.hlinux/module.hlinux/scatterlist.hlinux/seq_file.hlinux/slab.hlinux/string.hnet/netlink.hinternal.h
Detected Declarations
struct crypto_akcipher_sync_datafunction crypto_akcipher_reportfunction crypto_akcipher_showfunction crypto_akcipher_exit_tfmfunction crypto_akcipher_init_tfmfunction crypto_akcipher_free_instancefunction crypto_grab_akcipherfunction akcipher_prepare_algfunction akcipher_default_opfunction akcipher_default_set_keyfunction crypto_register_akcipherfunction crypto_unregister_akcipherfunction akcipher_register_instancefunction crypto_akcipher_sync_prepfunction crypto_akcipher_sync_postfunction crypto_akcipher_sync_encryptfunction crypto_akcipher_sync_decryptexport crypto_grab_akcipherexport crypto_alloc_akcipherexport crypto_register_akcipherexport crypto_unregister_akcipherexport akcipher_register_instanceexport crypto_akcipher_sync_encryptexport crypto_akcipher_sync_decrypt
Annotated Snippet
struct crypto_akcipher_sync_data {
struct crypto_akcipher *tfm;
const void *src;
void *dst;
unsigned int slen;
unsigned int dlen;
struct akcipher_request *req;
struct crypto_wait cwait;
struct scatterlist sg;
u8 *buf;
};
static int __maybe_unused crypto_akcipher_report(
struct sk_buff *skb, struct crypto_alg *alg)
{
struct crypto_report_akcipher rakcipher = {
.type = "akcipher",
};
return nla_put(skb, CRYPTOCFGA_REPORT_AKCIPHER,
sizeof(rakcipher), &rakcipher);
}
static void __maybe_unused crypto_akcipher_show(struct seq_file *m,
struct crypto_alg *alg)
{
seq_puts(m, "type : akcipher\n");
}
static void crypto_akcipher_exit_tfm(struct crypto_tfm *tfm)
{
struct crypto_akcipher *akcipher = __crypto_akcipher_tfm(tfm);
struct akcipher_alg *alg = crypto_akcipher_alg(akcipher);
alg->exit(akcipher);
}
static int crypto_akcipher_init_tfm(struct crypto_tfm *tfm)
{
struct crypto_akcipher *akcipher = __crypto_akcipher_tfm(tfm);
struct akcipher_alg *alg = crypto_akcipher_alg(akcipher);
if (alg->exit)
akcipher->base.exit = crypto_akcipher_exit_tfm;
if (alg->init)
return alg->init(akcipher);
return 0;
}
static void crypto_akcipher_free_instance(struct crypto_instance *inst)
{
struct akcipher_instance *akcipher = akcipher_instance(inst);
akcipher->free(akcipher);
}
static const struct crypto_type crypto_akcipher_type = {
.extsize = crypto_alg_extsize,
.init_tfm = crypto_akcipher_init_tfm,
.free = crypto_akcipher_free_instance,
#ifdef CONFIG_PROC_FS
.show = crypto_akcipher_show,
#endif
#if IS_ENABLED(CONFIG_CRYPTO_USER)
.report = crypto_akcipher_report,
#endif
.maskclear = ~CRYPTO_ALG_TYPE_MASK,
.maskset = CRYPTO_ALG_TYPE_AHASH_MASK,
.type = CRYPTO_ALG_TYPE_AKCIPHER,
.tfmsize = offsetof(struct crypto_akcipher, base),
.algsize = offsetof(struct akcipher_alg, base),
};
int crypto_grab_akcipher(struct crypto_akcipher_spawn *spawn,
struct crypto_instance *inst,
const char *name, u32 type, u32 mask)
{
spawn->base.frontend = &crypto_akcipher_type;
return crypto_grab_spawn(&spawn->base, inst, name, type, mask);
}
EXPORT_SYMBOL_GPL(crypto_grab_akcipher);
struct crypto_akcipher *crypto_alloc_akcipher(const char *alg_name, u32 type,
u32 mask)
{
return crypto_alloc_tfm(alg_name, &crypto_akcipher_type, type, mask);
}
Annotation
- Immediate include surface: `crypto/internal/akcipher.h`, `linux/cryptouser.h`, `linux/errno.h`, `linux/kernel.h`, `linux/module.h`, `linux/scatterlist.h`, `linux/seq_file.h`, `linux/slab.h`.
- Detected declarations: `struct crypto_akcipher_sync_data`, `function crypto_akcipher_report`, `function crypto_akcipher_show`, `function crypto_akcipher_exit_tfm`, `function crypto_akcipher_init_tfm`, `function crypto_akcipher_free_instance`, `function crypto_grab_akcipher`, `function akcipher_prepare_alg`, `function akcipher_default_op`, `function akcipher_default_set_key`.
- Atlas domain: Kernel Services / crypto.
- 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.