crypto/tcrypt.c
Source file repositories/reference/linux-study-clean/crypto/tcrypt.c
File Facts
- System
- Linux kernel
- Corpus path
crypto/tcrypt.c- Extension
.c- Size
- 75765 bytes
- Lines
- 2855
- Domain
- Kernel Services
- Bucket
- crypto
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/aead.hcrypto/hash.hcrypto/skcipher.hlinux/err.hlinux/fips.hlinux/init.hlinux/interrupt.hlinux/jiffies.hlinux/kernel.hlinux/module.hlinux/moduleparam.hlinux/scatterlist.hlinux/slab.hlinux/string.hlinux/timex.hinternal.htcrypt.h
Detected Declarations
struct test_mb_aead_datastruct test_mb_skcipher_datafunction testmgr_alloc_buffunction testmgr_free_buffunction sg_init_aeadfunction do_one_aead_opfunction do_mult_aead_opfunction test_mb_aead_jiffiesfunction test_mb_aead_cyclesfunction test_mb_aead_speedfunction test_aead_jiffiesfunction test_aead_cyclesfunction test_aead_speedfunction test_hash_sg_initfunction do_one_ahash_opfunction test_ahash_jiffies_digestfunction test_ahash_jiffiesfunction test_ahash_cycles_digestfunction test_ahash_cyclesfunction test_ahash_speed_commonfunction test_ahash_speedfunction test_hash_speedfunction do_mult_acipher_opfunction test_mb_acipher_jiffiesfunction test_mb_acipher_cyclesfunction test_mb_skcipher_speedfunction do_one_acipher_opfunction test_acipher_jiffiesfunction test_acipher_cyclesfunction test_skcipher_speedfunction test_acipher_speedfunction test_cipher_speedfunction tcrypt_testfunction do_testfunction tcrypt_mod_initfunction tcrypt_mod_fini
Annotated Snippet
struct test_mb_aead_data {
struct scatterlist sg[XBUFSIZE];
struct scatterlist sgout[XBUFSIZE];
struct aead_request *req;
struct crypto_wait wait;
char *xbuf[XBUFSIZE];
char *xoutbuf[XBUFSIZE];
char *axbuf[XBUFSIZE];
};
static int do_mult_aead_op(struct test_mb_aead_data *data, int enc,
u32 num_mb, int *rc)
{
int i, err = 0;
/* Fire up a bunch of concurrent requests */
for (i = 0; i < num_mb; i++) {
if (enc == ENCRYPT)
rc[i] = crypto_aead_encrypt(data[i].req);
else
rc[i] = crypto_aead_decrypt(data[i].req);
}
/* Wait for all requests to finish */
for (i = 0; i < num_mb; i++) {
rc[i] = crypto_wait_req(rc[i], &data[i].wait);
if (rc[i]) {
pr_info("concurrent request %d error %d\n", i, rc[i]);
err = rc[i];
}
}
return err;
}
static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc,
int blen, int secs, u32 num_mb)
{
unsigned long start, end;
int bcount;
int ret = 0;
int *rc;
rc = kzalloc_objs(*rc, num_mb);
if (!rc)
return -ENOMEM;
for (start = jiffies, end = start + secs * HZ, bcount = 0;
time_before(jiffies, end); bcount++) {
ret = do_mult_aead_op(data, enc, num_mb, rc);
if (ret)
goto out;
}
pr_cont("%d operations in %d seconds (%llu bytes)\n",
bcount * num_mb, secs, (u64)bcount * blen * num_mb);
out:
kfree(rc);
return ret;
}
static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
int blen, u32 num_mb)
{
unsigned long cycles = 0;
int ret = 0;
int i;
int *rc;
rc = kzalloc_objs(*rc, num_mb);
if (!rc)
return -ENOMEM;
/* Warm-up run. */
for (i = 0; i < 4; i++) {
ret = do_mult_aead_op(data, enc, num_mb, rc);
if (ret)
goto out;
}
/* The real thing. */
for (i = 0; i < 8; i++) {
cycles_t start, end;
start = get_cycles();
ret = do_mult_aead_op(data, enc, num_mb, rc);
end = get_cycles();
Annotation
- Immediate include surface: `crypto/aead.h`, `crypto/hash.h`, `crypto/skcipher.h`, `linux/err.h`, `linux/fips.h`, `linux/init.h`, `linux/interrupt.h`, `linux/jiffies.h`.
- Detected declarations: `struct test_mb_aead_data`, `struct test_mb_skcipher_data`, `function testmgr_alloc_buf`, `function testmgr_free_buf`, `function sg_init_aead`, `function do_one_aead_op`, `function do_mult_aead_op`, `function test_mb_aead_jiffies`, `function test_mb_aead_cycles`, `function test_mb_aead_speed`.
- Atlas domain: Kernel Services / crypto.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.