cmac.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 FundaciĆ³n Inria Chile
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef HASHES_CMAC_H
23 #define HASHES_CMAC_H
24 
25 #include <stdio.h>
26 #include "crypto/ciphers.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define CMAC_BLOCK_SIZE 16
36 
40 typedef struct {
44  uint8_t X[CMAC_BLOCK_SIZE];
46  uint8_t M_last[CMAC_BLOCK_SIZE];
48  uint32_t M_n;
50 
61 int cmac_init(cmac_context_t *ctx, const uint8_t *key, uint8_t key_size);
62 
70 void cmac_update(cmac_context_t *ctx, const void *data, size_t len);
71 
78 void cmac_final(cmac_context_t *ctx, void *digest);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* HASHES_CMAC_H */
85 
cipher_t
basic struct for using block ciphers contains the cipher interface and the context
Definition: ciphers.h:104
CMAC_BLOCK_SIZE
#define CMAC_BLOCK_SIZE
Length of AES_CMAC block in bytes.
Definition: cmac.h:35
cmac_context_t
AES_CMAC calculation context.
Definition: cmac.h:40
ciphers.h
Headers for the packet encryption class. They are used to encrypt single packets.
cmac_init
int cmac_init(cmac_context_t *ctx, const uint8_t *key, uint8_t key_size)
Initialize CMAC message digest context.
cmac_context_t::aes_ctx
cipher_t aes_ctx
AES128 context.
Definition: cmac.h:42
cmac_context_t::M_n
uint32_t M_n
last byte in last block
Definition: cmac.h:48
cmac_update
void cmac_update(cmac_context_t *ctx, const void *data, size_t len)
Update the CMAC context with a portion of the message being hashed.
cmac_final
void cmac_final(cmac_context_t *ctx, void *digest)
Finalizes the CMAC message digest.