crypto/lskcipher.c
Source file repositories/reference/linux-study-clean/crypto/lskcipher.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/lskcipher.c- Extension
.c- Size
- 16172 bytes
- Lines
- 588
- 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
linux/cryptouser.hlinux/err.hlinux/export.hlinux/kernel.hlinux/seq_file.hlinux/slab.hlinux/string.hnet/netlink.hskcipher.h
Detected Declarations
function Copyrightfunction lskcipher_setkey_unalignedfunction crypto_lskcipher_setkeyfunction crypto_lskcipher_crypt_unalignedfunction crypto_lskcipher_cryptfunction crypto_lskcipher_encryptfunction crypto_lskcipher_decryptfunction crypto_lskcipher_crypt_sgfunction crypto_lskcipher_encrypt_sgfunction crypto_lskcipher_decrypt_sgfunction crypto_lskcipher_exit_tfmfunction crypto_lskcipher_init_tfmfunction crypto_lskcipher_free_instancefunction crypto_lskcipher_showfunction crypto_lskcipher_reportfunction crypto_lskcipher_exit_tfm_sgfunction crypto_init_lskcipher_ops_sgfunction crypto_grab_lskcipherfunction lskcipher_prepare_algfunction crypto_register_lskcipherfunction crypto_unregister_lskcipherfunction crypto_register_lskciphersfunction crypto_unregister_lskciphersfunction lskcipher_register_instancefunction lskcipher_setkey_simplefunction lskcipher_init_tfm_simplefunction lskcipher_exit_tfm_simplefunction lskcipher_free_instance_simpleexport crypto_lskcipher_setkeyexport crypto_lskcipher_encryptexport crypto_lskcipher_decryptexport crypto_grab_lskcipherexport crypto_alloc_lskcipherexport crypto_register_lskcipherexport crypto_unregister_lskcipherexport crypto_register_lskciphersexport crypto_unregister_lskciphersexport lskcipher_register_instanceexport lskcipher_alloc_instance_simple
Annotated Snippet
if (ret) {
crypto_unregister_lskciphers(algs, i);
return ret;
}
}
return 0;
}
EXPORT_SYMBOL_GPL(crypto_register_lskciphers);
void crypto_unregister_lskciphers(struct lskcipher_alg *algs, int count)
{
int i;
for (i = count - 1; i >= 0; --i)
crypto_unregister_lskcipher(&algs[i]);
}
EXPORT_SYMBOL_GPL(crypto_unregister_lskciphers);
int lskcipher_register_instance(struct crypto_template *tmpl,
struct lskcipher_instance *inst)
{
int err;
if (WARN_ON(!inst->free))
return -EINVAL;
err = lskcipher_prepare_alg(&inst->alg);
if (err)
return err;
return crypto_register_instance(tmpl, lskcipher_crypto_instance(inst));
}
EXPORT_SYMBOL_GPL(lskcipher_register_instance);
static int lskcipher_setkey_simple(struct crypto_lskcipher *tfm, const u8 *key,
unsigned int keylen)
{
struct crypto_lskcipher *cipher = lskcipher_cipher_simple(tfm);
crypto_lskcipher_clear_flags(cipher, CRYPTO_TFM_REQ_MASK);
crypto_lskcipher_set_flags(cipher, crypto_lskcipher_get_flags(tfm) &
CRYPTO_TFM_REQ_MASK);
return crypto_lskcipher_setkey(cipher, key, keylen);
}
static int lskcipher_init_tfm_simple(struct crypto_lskcipher *tfm)
{
struct lskcipher_instance *inst = lskcipher_alg_instance(tfm);
struct crypto_lskcipher **ctx = crypto_lskcipher_ctx(tfm);
struct crypto_lskcipher_spawn *spawn;
struct crypto_lskcipher *cipher;
spawn = lskcipher_instance_ctx(inst);
cipher = crypto_spawn_lskcipher(spawn);
if (IS_ERR(cipher))
return PTR_ERR(cipher);
*ctx = cipher;
return 0;
}
static void lskcipher_exit_tfm_simple(struct crypto_lskcipher *tfm)
{
struct crypto_lskcipher **ctx = crypto_lskcipher_ctx(tfm);
crypto_free_lskcipher(*ctx);
}
static void lskcipher_free_instance_simple(struct lskcipher_instance *inst)
{
crypto_drop_lskcipher(lskcipher_instance_ctx(inst));
kfree(inst);
}
/**
* lskcipher_alloc_instance_simple - allocate instance of simple block cipher
*
* Allocate an lskcipher_instance for a simple block cipher mode of operation,
* e.g. cbc or ecb. The instance context will have just a single crypto_spawn,
* that for the underlying cipher. The {min,max}_keysize, ivsize, blocksize,
* alignmask, and priority are set from the underlying cipher but can be
* overridden if needed. The tfm context defaults to
* struct crypto_lskcipher *, and default ->setkey(), ->init(), and
* ->exit() methods are installed.
*
* @tmpl: the template being instantiated
* @tb: the template parameters
*
* Return: a pointer to the new instance, or an ERR_PTR(). The caller still
Annotation
- Immediate include surface: `linux/cryptouser.h`, `linux/err.h`, `linux/export.h`, `linux/kernel.h`, `linux/seq_file.h`, `linux/slab.h`, `linux/string.h`, `net/netlink.h`.
- Detected declarations: `function Copyright`, `function lskcipher_setkey_unaligned`, `function crypto_lskcipher_setkey`, `function crypto_lskcipher_crypt_unaligned`, `function crypto_lskcipher_crypt`, `function crypto_lskcipher_encrypt`, `function crypto_lskcipher_decrypt`, `function crypto_lskcipher_crypt_sg`, `function crypto_lskcipher_encrypt_sg`, `function crypto_lskcipher_decrypt_sg`.
- 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.