libnx  v4.2.2
cmac.h
Go to the documentation of this file.
1 /**
2  * @file cmac.h
3  * @brief Hardware accelerated AES-CMAC implementation.
4  * @copyright libnx Authors
5  */
6 #pragma once
7 #include "aes.h"
8 
9 /// Context for AES-128 CMAC.
10 typedef struct {
11  Aes128Context ctx;
12  u8 subkey[AES_BLOCK_SIZE];
13  u8 mac[AES_BLOCK_SIZE];
14  u8 buffer[AES_BLOCK_SIZE];
15  size_t num_buffered;
16  bool finalized;
18 
19 /// Context for AES-192 CMAC.
20 typedef struct {
21  Aes192Context ctx;
22  u8 subkey[AES_BLOCK_SIZE];
23  u8 mac[AES_BLOCK_SIZE];
24  u8 buffer[AES_BLOCK_SIZE];
25  size_t num_buffered;
26  bool finalized;
28 
29 /// Context for AES-256 CMAC.
30 typedef struct {
31  Aes256Context ctx;
32  u8 subkey[AES_BLOCK_SIZE];
33  u8 mac[AES_BLOCK_SIZE];
34  u8 buffer[AES_BLOCK_SIZE];
35  size_t num_buffered;
36  bool finalized;
38 
39 /// Initialize an AES-128-CMAC context.
40 void cmacAes128ContextCreate(Aes128CmacContext *out, const void *key);
41 /// Updates AES-128-CMAC context with data to hash
42 void cmacAes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size);
43 /// Gets the context's output mac, finalizes the context.
44 void cmacAes128ContextGetMac(Aes128CmacContext *ctx, void *dst);
45 
46 /// Simple all-in-one AES-128-CMAC calculator.
47 void cmacAes128CalculateMac(void *dst, const void *key, const void *src, size_t size);
48 
49 /// Initialize an AES-192-CMAC context.
50 void cmacAes192ContextCreate(Aes192CmacContext *out, const void *key);
51 /// Updates AES-192-CMAC context with data to hash
52 void cmacAes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size);
53 /// Gets the context's output mac, finalizes the context.
54 void cmacAes192ContextGetMac(Aes192CmacContext *ctx, void *dst);
55 
56 /// Simple all-in-one AES-192-CMAC calculator.
57 void cmacAes192CalculateMac(void *dst, const void *key, const void *src, size_t size);
58 
59 /// Initialize an AES-256-CMAC context.
60 void cmacAes256ContextCreate(Aes256CmacContext *out, const void *key);
61 /// Updates AES-256-CMAC context with data to hash
62 void cmacAes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size);
63 /// Gets the context's output mac, finalizes the context.
64 void cmacAes256ContextGetMac(Aes256CmacContext *ctx, void *dst);
65 
66 /// Simple all-in-one AES-256-CMAC calculator.
67 void cmacAes256CalculateMac(void *dst, const void *key, const void *src, size_t size);
cmacAes128ContextUpdate
void cmacAes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size)
Updates AES-128-CMAC context with data to hash.
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
cmacAes256ContextCreate
void cmacAes256ContextCreate(Aes256CmacContext *out, const void *key)
Initialize an AES-256-CMAC context.
cmacAes256ContextGetMac
void cmacAes256ContextGetMac(Aes256CmacContext *ctx, void *dst)
Gets the context's output mac, finalizes the context.
cmacAes192CalculateMac
void cmacAes192CalculateMac(void *dst, const void *key, const void *src, size_t size)
Simple all-in-one AES-192-CMAC calculator.
cmacAes192ContextCreate
void cmacAes192ContextCreate(Aes192CmacContext *out, const void *key)
Initialize an AES-192-CMAC context.
cmacAes256CalculateMac
void cmacAes256CalculateMac(void *dst, const void *key, const void *src, size_t size)
Simple all-in-one AES-256-CMAC calculator.
cmacAes128CalculateMac
void cmacAes128CalculateMac(void *dst, const void *key, const void *src, size_t size)
Simple all-in-one AES-128-CMAC calculator.
Aes128CmacContext
Context for AES-128 CMAC.
Definition: cmac.h:10
cmacAes128ContextGetMac
void cmacAes128ContextGetMac(Aes128CmacContext *ctx, void *dst)
Gets the context's output mac, finalizes the context.
aes.h
Hardware accelerated AES-ECB implementation.
cmacAes128ContextCreate
void cmacAes128ContextCreate(Aes128CmacContext *out, const void *key)
Initialize an AES-128-CMAC context.
Aes128Context
Context for AES-128 operations.
Definition: aes.h:41
Aes256Context
Context for AES-256 operations.
Definition: aes.h:51
cmacAes192ContextGetMac
void cmacAes192ContextGetMac(Aes192CmacContext *ctx, void *dst)
Gets the context's output mac, finalizes the context.
Aes192CmacContext
Context for AES-192 CMAC.
Definition: cmac.h:20
Aes256CmacContext
Context for AES-256 CMAC.
Definition: cmac.h:30
cmacAes256ContextUpdate
void cmacAes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size)
Updates AES-256-CMAC context with data to hash.
cmacAes192ContextUpdate
void cmacAes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size)
Updates AES-192-CMAC context with data to hash.
Aes192Context
Context for AES-192 operations.
Definition: aes.h:46