drivers/crypto/ccp/ccp-crypto-aes-xts.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccp/ccp-crypto-aes-xts.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccp/ccp-crypto-aes-xts.c- Extension
.c- Size
- 7469 bytes
- Lines
- 289
- 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.
- 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/module.hlinux/sched.hlinux/delay.hlinux/scatterlist.hlinux/string.hcrypto/aes.hcrypto/xts.hcrypto/internal/skcipher.hcrypto/scatterwalk.hccp-crypto.h
Detected Declarations
struct ccp_aes_xts_defstruct ccp_unit_size_mapfunction ccp_aes_xts_completefunction ccp_aes_xts_setkeyfunction ccp_aes_xts_cryptfunction ccp_aes_xts_encryptfunction ccp_aes_xts_decryptfunction ccp_aes_xts_init_tfmfunction ccp_aes_xts_exit_tfmfunction ccp_register_aes_xts_algfunction ccp_register_aes_xts_algs
Annotated Snippet
struct ccp_aes_xts_def {
const char *name;
const char *drv_name;
};
static const struct ccp_aes_xts_def aes_xts_algs[] = {
{
.name = "xts(aes)",
.drv_name = "xts-aes-ccp",
},
};
struct ccp_unit_size_map {
unsigned int size;
u32 value;
};
static struct ccp_unit_size_map xts_unit_sizes[] = {
{
.size = 16,
.value = CCP_XTS_AES_UNIT_SIZE_16,
},
{
.size = 512,
.value = CCP_XTS_AES_UNIT_SIZE_512,
},
{
.size = 1024,
.value = CCP_XTS_AES_UNIT_SIZE_1024,
},
{
.size = 2048,
.value = CCP_XTS_AES_UNIT_SIZE_2048,
},
{
.size = 4096,
.value = CCP_XTS_AES_UNIT_SIZE_4096,
},
};
static int ccp_aes_xts_complete(struct crypto_async_request *async_req, int ret)
{
struct skcipher_request *req = skcipher_request_cast(async_req);
struct ccp_aes_req_ctx *rctx = skcipher_request_ctx_dma(req);
if (ret)
return ret;
memcpy(req->iv, rctx->iv, AES_BLOCK_SIZE);
return 0;
}
static int ccp_aes_xts_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int key_len)
{
struct ccp_ctx *ctx = crypto_skcipher_ctx_dma(tfm);
unsigned int ccpversion = ccp_version();
int ret;
ret = xts_verify_key(tfm, key, key_len);
if (ret)
return ret;
/* Version 3 devices support 128-bit keys; version 5 devices can
* accommodate 128- and 256-bit keys.
*/
switch (key_len) {
case AES_KEYSIZE_128 * 2:
memcpy(ctx->u.aes.key, key, key_len);
break;
case AES_KEYSIZE_256 * 2:
if (ccpversion > CCP_VERSION(3, 0))
memcpy(ctx->u.aes.key, key, key_len);
break;
}
ctx->u.aes.key_len = key_len / 2;
sg_init_one(&ctx->u.aes.key_sg, ctx->u.aes.key, key_len);
return crypto_skcipher_setkey(ctx->u.aes.tfm_skcipher, key, key_len);
}
static int ccp_aes_xts_crypt(struct skcipher_request *req,
unsigned int encrypt)
{
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct ccp_ctx *ctx = crypto_skcipher_ctx_dma(tfm);
struct ccp_aes_req_ctx *rctx = skcipher_request_ctx_dma(req);
unsigned int ccpversion = ccp_version();
unsigned int fallback = 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/sched.h`, `linux/delay.h`, `linux/scatterlist.h`, `linux/string.h`, `crypto/aes.h`, `crypto/xts.h`, `crypto/internal/skcipher.h`.
- Detected declarations: `struct ccp_aes_xts_def`, `struct ccp_unit_size_map`, `function ccp_aes_xts_complete`, `function ccp_aes_xts_setkey`, `function ccp_aes_xts_crypt`, `function ccp_aes_xts_encrypt`, `function ccp_aes_xts_decrypt`, `function ccp_aes_xts_init_tfm`, `function ccp_aes_xts_exit_tfm`, `function ccp_register_aes_xts_alg`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source 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.