drivers/crypto/ccp/ccp-crypto-sha.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccp/ccp-crypto-sha.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccp/ccp-crypto-sha.c- Extension
.c- Size
- 12879 bytes
- Lines
- 530
- 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/crypto.hcrypto/algapi.hcrypto/hash.hcrypto/hmac.hcrypto/internal/hash.hcrypto/sha1.hcrypto/sha2.hcrypto/scatterwalk.hlinux/string.hccp-crypto.h
Detected Declarations
struct ccp_sha_deffunction Coprocessorfunction ccp_do_sha_updatefunction ccp_sha_initfunction ccp_sha_updatefunction ccp_sha_finalfunction ccp_sha_finupfunction ccp_sha_digestfunction ccp_sha_exportfunction ccp_sha_importfunction ccp_sha_setkeyfunction ccp_sha_cra_initfunction ccp_sha_cra_exitfunction ccp_hmac_sha_cra_exitfunction ccp_register_hmac_algfunction ccp_register_sha_algfunction ccp_register_sha_algs
Annotated Snippet
struct ccp_sha_def {
unsigned int version;
const char *name;
const char *drv_name;
enum ccp_sha_type type;
u32 digest_size;
u32 block_size;
};
static struct ccp_sha_def sha_algs[] = {
{
.version = CCP_VERSION(3, 0),
.name = "sha1",
.drv_name = "sha1-ccp",
.type = CCP_SHA_TYPE_1,
.digest_size = SHA1_DIGEST_SIZE,
.block_size = SHA1_BLOCK_SIZE,
},
{
.version = CCP_VERSION(3, 0),
.name = "sha224",
.drv_name = "sha224-ccp",
.type = CCP_SHA_TYPE_224,
.digest_size = SHA224_DIGEST_SIZE,
.block_size = SHA224_BLOCK_SIZE,
},
{
.version = CCP_VERSION(3, 0),
.name = "sha256",
.drv_name = "sha256-ccp",
.type = CCP_SHA_TYPE_256,
.digest_size = SHA256_DIGEST_SIZE,
.block_size = SHA256_BLOCK_SIZE,
},
{
.version = CCP_VERSION(5, 0),
.name = "sha384",
.drv_name = "sha384-ccp",
.type = CCP_SHA_TYPE_384,
.digest_size = SHA384_DIGEST_SIZE,
.block_size = SHA384_BLOCK_SIZE,
},
{
.version = CCP_VERSION(5, 0),
.name = "sha512",
.drv_name = "sha512-ccp",
.type = CCP_SHA_TYPE_512,
.digest_size = SHA512_DIGEST_SIZE,
.block_size = SHA512_BLOCK_SIZE,
},
};
static int ccp_register_hmac_alg(struct list_head *head,
const struct ccp_sha_def *def,
const struct ccp_crypto_ahash_alg *base_alg)
{
struct ccp_crypto_ahash_alg *ccp_alg;
struct ahash_alg *alg;
struct hash_alg_common *halg;
struct crypto_alg *base;
int ret;
ccp_alg = kzalloc_obj(*ccp_alg);
if (!ccp_alg)
return -ENOMEM;
/* Copy the base algorithm and only change what's necessary */
*ccp_alg = *base_alg;
INIT_LIST_HEAD(&ccp_alg->entry);
strscpy(ccp_alg->child_alg, def->name, CRYPTO_MAX_ALG_NAME);
alg = &ccp_alg->alg;
alg->setkey = ccp_sha_setkey;
halg = &alg->halg;
base = &halg->base;
snprintf(base->cra_name, CRYPTO_MAX_ALG_NAME, "hmac(%s)", def->name);
snprintf(base->cra_driver_name, CRYPTO_MAX_ALG_NAME, "hmac-%s",
def->drv_name);
base->cra_init = ccp_hmac_sha_cra_init;
base->cra_exit = ccp_hmac_sha_cra_exit;
ret = crypto_register_ahash(alg);
if (ret) {
pr_err("%s ahash algorithm registration error (%d)\n",
base->cra_name, ret);
kfree(ccp_alg);
return ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/sched.h`, `linux/delay.h`, `linux/scatterlist.h`, `linux/crypto.h`, `crypto/algapi.h`, `crypto/hash.h`, `crypto/hmac.h`.
- Detected declarations: `struct ccp_sha_def`, `function Coprocessor`, `function ccp_do_sha_update`, `function ccp_sha_init`, `function ccp_sha_update`, `function ccp_sha_final`, `function ccp_sha_finup`, `function ccp_sha_digest`, `function ccp_sha_export`, `function ccp_sha_import`.
- 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.