include/crypto/aes-cbc-macs.h
Source file repositories/reference/linux-study-clean/include/crypto/aes-cbc-macs.h
File Facts
- System
- Linux kernel
- Corpus path
include/crypto/aes-cbc-macs.h- Extension
.h- Size
- 5195 bytes
- Lines
- 155
- Domain
- Repository Root And Misc
- Bucket
- include
- Inferred role
- Repository Root And Misc: implementation source
- Status
- source implementation candidate
Why This File Exists
Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Top-level or miscellaneous repository surface. Use this as map coverage unless a later manual pass promotes the file into a deeper subsystem dossier.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/aes.h
Detected Declarations
struct aes_cmac_keystruct aes_cmac_ctxstruct aes_cbcmac_ctxfunction aes_cmac_initfunction aes_cmacfunction aes_cbcmac_init
Annotated Snippet
struct aes_cmac_key {
struct aes_enckey aes;
union {
u8 b[AES_BLOCK_SIZE];
__be64 w[2];
} k_final[2];
};
/**
* struct aes_cmac_ctx - Context for computing an AES-CMAC or AES-XCBC-MAC value
* @key: Pointer to the key struct. A pointer is used rather than a copy of the
* struct, since the key struct size may be large. It is assumed that the
* key lives at least as long as the context.
* @partial_len: Number of bytes that have been XOR'ed into @h since the last
* AES encryption. This is 0 if no data has been processed yet,
* or between 1 and AES_BLOCK_SIZE inclusive otherwise.
* @h: The current chaining value
*/
struct aes_cmac_ctx {
const struct aes_cmac_key *key;
size_t partial_len;
u8 h[AES_BLOCK_SIZE];
};
/**
* aes_cmac_preparekey() - Prepare a key for AES-CMAC
* @key: (output) The key struct to initialize
* @in_key: The raw AES key
* @key_len: Length of the raw key in bytes. The supported values are
* AES_KEYSIZE_128, AES_KEYSIZE_192, and AES_KEYSIZE_256.
*
* Context: Any context.
* Return: 0 on success or -EINVAL if the given key length is invalid. No other
* errors are possible, so callers that always pass a valid key length
* don't need to check for errors.
*/
int aes_cmac_preparekey(struct aes_cmac_key *key, const u8 *in_key,
size_t key_len);
/**
* aes_xcbcmac_preparekey() - Prepare a key for AES-XCBC-MAC
* @key: (output) The key struct to initialize
* @in_key: The raw key. As per the AES-XCBC-MAC specification (RFC 3566), this
* is 128 bits, matching the internal use of AES-128.
*
* AES-XCBC-MAC and AES-CMAC are the same except for the key preparation. After
* that step, AES-XCBC-MAC is supported via the aes_cmac_* functions.
*
* New users should use AES-CMAC instead of AES-XCBC-MAC.
*
* Context: Any context.
*/
void aes_xcbcmac_preparekey(struct aes_cmac_key *key,
const u8 in_key[at_least AES_KEYSIZE_128]);
/**
* aes_cmac_init() - Start computing an AES-CMAC or AES-XCBC-MAC value
* @ctx: (output) The context to initialize
* @key: The key to use. Note that a pointer to the key is saved in the
* context, so the key must live at least as long as the context.
*
* This supports both AES-CMAC and AES-XCBC-MAC. Which one is done depends on
* whether aes_cmac_preparekey() or aes_xcbcmac_preparekey() was called.
*/
static inline void aes_cmac_init(struct aes_cmac_ctx *ctx,
const struct aes_cmac_key *key)
{
*ctx = (struct aes_cmac_ctx){ .key = key };
}
/**
* aes_cmac_update() - Update an AES-CMAC or AES-XCBC-MAC context with more data
* @ctx: The context to update; must have been initialized
* @data: The message data
* @data_len: The data length in bytes. Doesn't need to be block-aligned.
*
* This can be called any number of times.
*
* Context: Any context.
*/
void aes_cmac_update(struct aes_cmac_ctx *ctx, const u8 *data, size_t data_len);
/**
* aes_cmac_final() - Finish computing an AES-CMAC or AES-XCBC-MAC value
* @ctx: The context to finalize; must have been initialized
* @out: (output) The resulting MAC
*
* After finishing, this zeroizes @ctx. So the caller does not need to do it.
*
* Context: Any context.
Annotation
- Immediate include surface: `crypto/aes.h`.
- Detected declarations: `struct aes_cmac_key`, `struct aes_cmac_ctx`, `struct aes_cbcmac_ctx`, `function aes_cmac_init`, `function aes_cmac`, `function aes_cbcmac_init`.
- Atlas domain: Repository Root And Misc / include.
- 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.