drivers/crypto/ccree/cc_aead.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccree/cc_aead.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccree/cc_aead.c- Extension
.c- Size
- 77056 bytes
- Lines
- 2668
- 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.
- 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/rtnetlink.hlinux/string.hcrypto/algapi.hcrypto/internal/aead.hcrypto/authenc.hcrypto/gcm.hcrypto/internal/des.hcc_driver.hcc_buffer_mgr.hcc_aead.hcc_request_mgr.hcc_hash.hcc_sram_mgr.h
Detected Declarations
struct cc_aead_handlestruct cc_hmac_sstruct cc_xcbc_sstruct cc_aead_ctxfunction cc_aead_exitfunction cc_get_aead_hash_lenfunction cc_aead_initfunction cc_aead_completefunction xcbc_setkeyfunction hmac_setkeyfunction validate_keys_sizesfunction cc_get_plain_hmac_keyfunction cc_aead_setkeyfunction cc_des3_aead_setkeyfunction cc_rfc4309_ccm_setkeyfunction cc_aead_setauthsizefunction cc_rfc4309_ccm_setauthsizefunction cc_ccm_setauthsizefunction cc_set_assoc_descfunction cc_proc_authen_descfunction cc_proc_cipher_descfunction cc_proc_digest_descfunction cc_set_cipher_descfunction cc_proc_cipherfunction cc_set_hmac_descfunction cc_set_xcbc_descfunction cc_proc_header_descfunction cc_proc_scheme_descfunction cc_mlli_to_sramfunction cc_get_data_flowfunction cc_hmac_authencfunction cc_xcbc_authencfunction validate_data_sizefunction format_ccm_a0function set_msg_lenfunction cc_ccmfunction config_ccm_adatafunction cc_proc_rfc4309_ccmfunction cc_set_ghash_descfunction cc_set_gctr_descfunction cc_proc_gcm_resultfunction cc_gcmfunction config_gcm_contextfunction cc_proc_rfc4_gcmfunction cc_proc_aeadfunction cc_aead_encryptfunction cc_rfc4309_ccm_encryptfunction cc_aead_decrypt
Annotated Snippet
struct cc_aead_handle {
u32 sram_workspace_addr;
struct list_head aead_list;
};
struct cc_hmac_s {
u8 *padded_authkey;
u8 *ipad_opad; /* IPAD, OPAD*/
dma_addr_t padded_authkey_dma_addr;
dma_addr_t ipad_opad_dma_addr;
};
struct cc_xcbc_s {
u8 *xcbc_keys; /* K1,K2,K3 */
dma_addr_t xcbc_keys_dma_addr;
};
struct cc_aead_ctx {
struct cc_drvdata *drvdata;
u8 ctr_nonce[MAX_NONCE_SIZE]; /* used for ctr3686 iv and aes ccm */
u8 *enckey;
dma_addr_t enckey_dma_addr;
union {
struct cc_hmac_s hmac;
struct cc_xcbc_s xcbc;
} auth_state;
unsigned int enc_keylen;
unsigned int auth_keylen;
unsigned int authsize; /* Actual (reduced?) size of the MAC/ICv */
unsigned int hash_len;
enum drv_cipher_mode cipher_mode;
enum cc_flow_mode flow_mode;
enum drv_hash_mode auth_mode;
};
static void cc_aead_exit(struct crypto_aead *tfm)
{
struct cc_aead_ctx *ctx = crypto_aead_ctx(tfm);
struct device *dev = drvdata_to_dev(ctx->drvdata);
dev_dbg(dev, "Clearing context @%p for %s\n", crypto_aead_ctx(tfm),
crypto_tfm_alg_name(&tfm->base));
/* Unmap enckey buffer */
if (ctx->enckey) {
dma_free_coherent(dev, AES_MAX_KEY_SIZE, ctx->enckey,
ctx->enckey_dma_addr);
dev_dbg(dev, "Freed enckey DMA buffer enckey_dma_addr=%pad\n",
&ctx->enckey_dma_addr);
ctx->enckey_dma_addr = 0;
ctx->enckey = NULL;
}
if (ctx->auth_mode == DRV_HASH_XCBC_MAC) { /* XCBC authetication */
struct cc_xcbc_s *xcbc = &ctx->auth_state.xcbc;
if (xcbc->xcbc_keys) {
dma_free_coherent(dev, CC_AES_128_BIT_KEY_SIZE * 3,
xcbc->xcbc_keys,
xcbc->xcbc_keys_dma_addr);
}
dev_dbg(dev, "Freed xcbc_keys DMA buffer xcbc_keys_dma_addr=%pad\n",
&xcbc->xcbc_keys_dma_addr);
xcbc->xcbc_keys_dma_addr = 0;
xcbc->xcbc_keys = NULL;
} else if (ctx->auth_mode != DRV_HASH_NULL) { /* HMAC auth. */
struct cc_hmac_s *hmac = &ctx->auth_state.hmac;
if (hmac->ipad_opad) {
dma_free_coherent(dev, 2 * MAX_HMAC_DIGEST_SIZE,
hmac->ipad_opad,
hmac->ipad_opad_dma_addr);
dev_dbg(dev, "Freed ipad_opad DMA buffer ipad_opad_dma_addr=%pad\n",
&hmac->ipad_opad_dma_addr);
hmac->ipad_opad_dma_addr = 0;
hmac->ipad_opad = NULL;
}
if (hmac->padded_authkey) {
dma_free_coherent(dev, MAX_HMAC_BLOCK_SIZE,
hmac->padded_authkey,
hmac->padded_authkey_dma_addr);
dev_dbg(dev, "Freed padded_authkey DMA buffer padded_authkey_dma_addr=%pad\n",
&hmac->padded_authkey_dma_addr);
hmac->padded_authkey_dma_addr = 0;
hmac->padded_authkey = NULL;
}
}
}
static unsigned int cc_get_aead_hash_len(struct crypto_aead *tfm)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/rtnetlink.h`, `linux/string.h`, `crypto/algapi.h`, `crypto/internal/aead.h`, `crypto/authenc.h`, `crypto/gcm.h`.
- Detected declarations: `struct cc_aead_handle`, `struct cc_hmac_s`, `struct cc_xcbc_s`, `struct cc_aead_ctx`, `function cc_aead_exit`, `function cc_get_aead_hash_len`, `function cc_aead_init`, `function cc_aead_complete`, `function xcbc_setkey`, `function hmac_setkey`.
- Atlas domain: Driver Families / drivers/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.