cmac.h File Reference

CMAC (Cipher-based Message Authentication Code) More...

#include "core/crypto.h"
#include "cipher/rc2.h"
#include "cipher/rc6.h"
#include "cipher/idea.h"
#include "cipher/des.h"
#include "cipher/des3.h"
#include "cipher/aes.h"
#include "cipher/camellia.h"
#include "cipher/seed.h"
#include "cipher/aria.h"
#include "cipher/present.h"

Go to the source code of this file.

Data Structures

struct  CmacContext
 CMAC algorithm context. More...
 

Functions

error_t cmacCompute (const CipherAlgo *cipher, const void *key, size_t keyLen, const void *data, size_t dataLen, uint8_t *mac, size_t macLen)
 Compute CMAC using the specified cipher algorithm. More...
 
error_t cmacInit (CmacContext *context, const CipherAlgo *cipher, const void *key, size_t keyLen)
 Initialize CMAC calculation. More...
 
void cmacReset (CmacContext *context)
 Reset CMAC context. More...
 
void cmacUpdate (CmacContext *context, const void *data, size_t dataLen)
 Update the CMAC context with a portion of the message being hashed. More...
 
error_t cmacFinal (CmacContext *context, uint8_t *mac, size_t macLen)
 Finish the CMAC calculation. More...
 
void cmacMul (uint8_t *x, const uint8_t *a, size_t n, uint8_t rb)
 Multiplication by x in GF(2^128) More...
 
void cmacXorBlock (uint8_t *x, const uint8_t *a, const uint8_t *b, size_t n)
 XOR operation. More...
 

Detailed Description

CMAC (Cipher-based Message Authentication Code)

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCrypto Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file cmac.h.

Function Documentation

◆ cmacCompute()

error_t cmacCompute ( const CipherAlgo cipher,
const void *  key,
size_t  keyLen,
const void *  data,
size_t  dataLen,
uint8_t *  mac,
size_t  macLen 
)

Compute CMAC using the specified cipher algorithm.

Parameters
[in]cipherCipher algorithm used to compute CMAC
[in]keyPointer to the secret key
[in]keyLenLength of the secret key
[in]dataPointer to the input message
[in]dataLenLength of the input data
[out]macCalculated MAC value
[in]macLenExpected length of the MAC
Returns
Error code

Definition at line 56 of file cmac.c.

◆ cmacFinal()

error_t cmacFinal ( CmacContext context,
uint8_t *  mac,
size_t  macLen 
)

Finish the CMAC calculation.

Parameters
[in]contextPointer to the CMAC context
[out]macCalculated MAC value
[in]macLenExpected length of the MAC
Returns
Error code

Definition at line 227 of file cmac.c.

◆ cmacInit()

error_t cmacInit ( CmacContext context,
const CipherAlgo cipher,
const void *  key,
size_t  keyLen 
)

Initialize CMAC calculation.

Parameters
[in]contextPointer to the CMAC context to initialize
[in]cipherCipher algorithm used to compute CMAC
[in]keyPointer to the secret key
[in]keyLenLength of the secret key
Returns
Error code

Definition at line 103 of file cmac.c.

◆ cmacMul()

void cmacMul ( uint8_t *  x,
const uint8_t *  a,
size_t  n,
uint8_t  rb 
)

Multiplication by x in GF(2^128)

Parameters
[out]xPointer to the output block
[out]aPointer to the input block
[in]nSize of the block, in bytes
[in]rbRepresentation of the irreducible binary polynomial

Definition at line 283 of file cmac.c.

◆ cmacReset()

void cmacReset ( CmacContext context)

Reset CMAC context.

Parameters
[in]contextPointer to the CMAC context

Definition at line 162 of file cmac.c.

◆ cmacUpdate()

void cmacUpdate ( CmacContext context,
const void *  data,
size_t  dataLen 
)

Update the CMAC context with a portion of the message being hashed.

Parameters
[in]contextPointer to the CMAC context
[in]dataPointer to the input data
[in]dataLenLength of the buffer

Definition at line 181 of file cmac.c.

◆ cmacXorBlock()

void cmacXorBlock ( uint8_t *  x,
const uint8_t *  a,
const uint8_t *  b,
size_t  n 
)

XOR operation.

Parameters
[out]xBlock resulting from the XOR operation
[in]aFirst input block
[in]bSecond input block
[in]nSize of the block, in bytes

Definition at line 314 of file cmac.c.