drivers/crypto/ccree/cc_cipher.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccree/cc_cipher.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccree/cc_cipher.c- Extension
.c- Size
- 40726 bytes
- Lines
- 1472
- 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/string.hcrypto/algapi.hcrypto/internal/skcipher.hcrypto/internal/des.hcrypto/xts.hcrypto/sm4.hcrypto/scatterwalk.hcc_driver.hcc_lli_defs.hcc_buffer_mgr.hcc_cipher.hcc_request_mgr.h
Detected Declarations
struct cc_user_key_infostruct cc_hw_key_infostruct cc_cpp_key_infostruct cc_cipher_ctxenum cc_key_typefunction cc_key_typefunction validate_keys_sizesfunction validate_data_sizefunction cc_cipher_initfunction cc_cipher_exitfunction cc_slot_to_hw_keyfunction cc_slot_to_cpp_keyfunction cc_slot_to_key_typefunction cc_cipher_sethkeyfunction cc_cipher_setkeyfunction cc_out_setup_modefunction cc_setup_readiv_descfunction cc_setup_state_descfunction cc_setup_xex_state_descfunction cc_out_flow_modefunction cc_setup_key_descfunction cc_setup_mlli_descfunction cc_setup_flow_descfunction cc_cipher_completefunction cc_cipher_processfunction cc_cipher_encryptfunction cc_cipher_decryptfunction cc_cipher_freefunction cc_cipher_alloc
Annotated Snippet
struct cc_user_key_info {
u8 *key;
dma_addr_t key_dma_addr;
};
struct cc_hw_key_info {
enum cc_hw_crypto_key key1_slot;
enum cc_hw_crypto_key key2_slot;
};
struct cc_cpp_key_info {
u8 slot;
enum cc_cpp_alg alg;
};
enum cc_key_type {
CC_UNPROTECTED_KEY, /* User key */
CC_HW_PROTECTED_KEY, /* HW (FDE) key */
CC_POLICY_PROTECTED_KEY, /* CPP key */
CC_INVALID_PROTECTED_KEY /* Invalid key */
};
struct cc_cipher_ctx {
struct cc_drvdata *drvdata;
int keylen;
int cipher_mode;
int flow_mode;
unsigned int flags;
enum cc_key_type key_type;
struct cc_user_key_info user;
union {
struct cc_hw_key_info hw;
struct cc_cpp_key_info cpp;
};
struct crypto_shash *shash_tfm;
struct crypto_skcipher *fallback_tfm;
bool fallback_on;
};
static void cc_cipher_complete(struct device *dev, void *cc_req, int err);
static inline enum cc_key_type cc_key_type(struct crypto_tfm *tfm)
{
struct cc_cipher_ctx *ctx_p = crypto_tfm_ctx(tfm);
return ctx_p->key_type;
}
static int validate_keys_sizes(struct cc_cipher_ctx *ctx_p, u32 size)
{
switch (ctx_p->flow_mode) {
case S_DIN_to_AES:
switch (size) {
case CC_AES_128_BIT_KEY_SIZE:
case CC_AES_192_BIT_KEY_SIZE:
if (ctx_p->cipher_mode != DRV_CIPHER_XTS)
return 0;
break;
case CC_AES_256_BIT_KEY_SIZE:
return 0;
case (CC_AES_192_BIT_KEY_SIZE * 2):
case (CC_AES_256_BIT_KEY_SIZE * 2):
if (ctx_p->cipher_mode == DRV_CIPHER_XTS ||
ctx_p->cipher_mode == DRV_CIPHER_ESSIV)
return 0;
break;
default:
break;
}
break;
case S_DIN_to_DES:
if (size == DES3_EDE_KEY_SIZE || size == DES_KEY_SIZE)
return 0;
break;
case S_DIN_to_SM4:
if (size == SM4_KEY_SIZE)
return 0;
break;
default:
break;
}
return -EINVAL;
}
static int validate_data_size(struct cc_cipher_ctx *ctx_p,
unsigned int size)
{
switch (ctx_p->flow_mode) {
case S_DIN_to_AES:
switch (ctx_p->cipher_mode) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/string.h`, `crypto/algapi.h`, `crypto/internal/skcipher.h`, `crypto/internal/des.h`, `crypto/xts.h`, `crypto/sm4.h`.
- Detected declarations: `struct cc_user_key_info`, `struct cc_hw_key_info`, `struct cc_cpp_key_info`, `struct cc_cipher_ctx`, `enum cc_key_type`, `function cc_key_type`, `function validate_keys_sizes`, `function validate_data_size`, `function cc_cipher_init`, `function cc_cipher_exit`.
- 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.