drivers/crypto/talitos.c
Source file repositories/reference/linux-study-clean/drivers/crypto/talitos.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/talitos.c- Extension
.c- Size
- 107094 bytes
- Lines
- 3641
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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
linux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/device.hlinux/interrupt.hlinux/crypto.hlinux/hw_random.hlinux/of.hlinux/of_irq.hlinux/platform_device.hlinux/dma-mapping.hlinux/io.hlinux/spinlock.hlinux/rtnetlink.hlinux/slab.hcrypto/algapi.hcrypto/aes.hcrypto/internal/des.hcrypto/sha1.hcrypto/sha2.hcrypto/md5.hcrypto/internal/aead.hcrypto/authenc.hcrypto/internal/skcipher.hcrypto/hash.hcrypto/internal/hash.hcrypto/scatterwalk.htalitos.h
Detected Declarations
struct talitos_ctxstruct talitos_ahash_req_ctxstruct talitos_export_statestruct talitos_alg_templatestruct talitos_crypto_algfunction Copyrightfunction copy_talitos_ptrfunction from_talitos_ptr_lenfunction to_talitos_ptr_ext_setfunction to_talitos_ptr_ext_orfunction singlefunction map_single_talitos_ptrfunction map_single_talitos_ptr_nosyncfunction singlefunction reset_channelfunction reset_devicefunction init_devicefunction dma_map_requestfunction talitos_submitfunction get_request_hdrfunction dma_unmap_requestfunction flush_channelfunction search_desc_hdr_in_requestfunction currentfunction report_eu_errorfunction talitos_errorfunction talitos_rng_data_presentfunction talitos_rng_data_readfunction talitos_rng_initfunction talitos_register_rngfunction talitos_unregister_rngfunction aead_setkeyfunction aead_des3_setkeyfunction talitos_sg_unmapfunction ipsec_esp_unmapfunction ipsec_esp_encrypt_donefunction ipsec_esp_decrypt_swauth_donefunction ipsec_esp_decrypt_hwauth_donefunction sg_to_link_tbl_offsetfunction talitos_sg_map_extfunction talitos_sg_mapfunction ipsec_espfunction aead_encryptfunction aead_decryptfunction skcipher_setkeyfunction skcipher_des_setkeyfunction skcipher_des3_setkeyfunction skcipher_aes_setkey
Annotated Snippet
struct talitos_ctx {
struct device *dev;
int ch;
__be32 desc_hdr_template;
u8 key[TALITOS_MAX_KEY_SIZE];
u8 iv[TALITOS_MAX_IV_LENGTH];
dma_addr_t dma_key;
unsigned int keylen;
unsigned int enckeylen;
unsigned int authkeylen;
};
#define HASH_MAX_BLOCK_SIZE SHA512_BLOCK_SIZE
#define TALITOS_MDEU_MAX_CONTEXT_SIZE TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512
struct talitos_ahash_req_ctx {
u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
unsigned int hw_context_size;
u8 buf[2][HASH_MAX_BLOCK_SIZE];
int buf_idx;
unsigned int swinit;
unsigned int first_request;
unsigned int last_request;
unsigned int to_hash_later;
unsigned int nbuf;
struct scatterlist bufsl[2];
struct scatterlist *psrc;
};
struct talitos_export_state {
u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
u8 buf[HASH_MAX_BLOCK_SIZE];
unsigned int swinit;
unsigned int first_request;
unsigned int last_request;
unsigned int to_hash_later;
unsigned int nbuf;
};
static int aead_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen)
{
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
struct device *dev = ctx->dev;
struct crypto_authenc_keys keys;
if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
goto badkey;
if (keys.authkeylen + keys.enckeylen > TALITOS_MAX_KEY_SIZE)
goto badkey;
if (ctx->keylen)
dma_unmap_single(dev, ctx->dma_key, ctx->keylen, DMA_TO_DEVICE);
memcpy(ctx->key, keys.authkey, keys.authkeylen);
memcpy(&ctx->key[keys.authkeylen], keys.enckey, keys.enckeylen);
ctx->keylen = keys.authkeylen + keys.enckeylen;
ctx->enckeylen = keys.enckeylen;
ctx->authkeylen = keys.authkeylen;
ctx->dma_key = dma_map_single(dev, ctx->key, ctx->keylen,
DMA_TO_DEVICE);
memzero_explicit(&keys, sizeof(keys));
return 0;
badkey:
memzero_explicit(&keys, sizeof(keys));
return -EINVAL;
}
static int aead_des3_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen)
{
struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
struct device *dev = ctx->dev;
struct crypto_authenc_keys keys;
int err;
err = crypto_authenc_extractkeys(&keys, key, keylen);
if (unlikely(err))
goto out;
err = -EINVAL;
if (keys.authkeylen + keys.enckeylen > TALITOS_MAX_KEY_SIZE)
goto out;
err = verify_aead_des3_key(authenc, keys.enckey, keys.enckeylen);
if (err)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/device.h`, `linux/interrupt.h`, `linux/crypto.h`, `linux/hw_random.h`, `linux/of.h`.
- Detected declarations: `struct talitos_ctx`, `struct talitos_ahash_req_ctx`, `struct talitos_export_state`, `struct talitos_alg_template`, `struct talitos_crypto_alg`, `function Copyright`, `function copy_talitos_ptr`, `function from_talitos_ptr_len`, `function to_talitos_ptr_ext_set`, `function to_talitos_ptr_ext_or`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.