gmac.c File Reference

GMAC (Galois Message Authentication Code) More...

#include "core/crypto.h"
#include "mac/gmac.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t gmacCompute (const CipherAlgo *cipher, const void *key, size_t keyLen, const uint8_t *iv, size_t ivLen, const void *data, size_t dataLen, uint8_t *mac, size_t macLen)
 Compute GMAC using the specified cipher algorithm. More...
 
error_t gmacInit (GmacContext *context, const CipherAlgo *cipher, const void *key, size_t keyLen)
 Initialize GMAC calculation. More...
 
error_t gmacReset (GmacContext *context, const uint8_t *iv, size_t ivLen)
 Reset GMAC context. More...
 
void gmacUpdate (GmacContext *context, const void *data, size_t dataLen)
 Update the GMAC context with a portion of the message being hashed. More...
 
error_t gmacFinal (GmacContext *context, uint8_t *mac, size_t macLen)
 Finish the GMAC calculation. More...
 
void gmacMul (GmacContext *context, uint8_t *x)
 Multiplication operation in GF(2^128) More...
 
void gmacXorBlock (uint8_t *x, const uint8_t *a, const uint8_t *b, size_t n)
 XOR operation. More...
 
void gmacIncCounter (uint8_t *x)
 Increment counter block. More...
 

Detailed Description

GMAC (Galois 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.

Description

GMAC is a message authentication code (MAC) based on GCM. Refer to SP 800-38D for more details

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

Definition in file gmac.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 35 of file gmac.c.

Function Documentation

◆ gmacCompute()

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

Compute GMAC using the specified cipher algorithm.

Parameters
[in]cipherCipher algorithm used to compute GMAC
[in]keyPointer to the secret key
[in]keyLenLength of the secret key
[in]ivInitialization vector
[in]ivLenLength of the initialization vector
[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 80 of file gmac.c.

◆ gmacFinal()

error_t gmacFinal ( GmacContext context,
uint8_t *  mac,
size_t  macLen 
)

Finish the GMAC calculation.

Parameters
[in]contextPointer to the GMAC context
[out]macCalculated MAC value
[in]macLenExpected length of the MAC

Definition at line 376 of file gmac.c.

◆ gmacIncCounter()

void gmacIncCounter ( uint8_t *  x)

Increment counter block.

Parameters
[in,out]xPointer to the counter block

Definition at line 506 of file gmac.c.

◆ gmacInit()

error_t gmacInit ( GmacContext context,
const CipherAlgo cipher,
const void *  key,
size_t  keyLen 
)

Initialize GMAC calculation.

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

Definition at line 135 of file gmac.c.

◆ gmacMul()

void gmacMul ( GmacContext context,
uint8_t *  x 
)

Multiplication operation in GF(2^128)

Parameters
[in]contextPointer to the GMAC context
[in,out]x16-byte block to be multiplied by H

Definition at line 420 of file gmac.c.

◆ gmacReset()

error_t gmacReset ( GmacContext context,
const uint8_t *  iv,
size_t  ivLen 
)

Reset GMAC context.

Parameters
[in]contextPointer to the GMAC context
[in]ivInitialization vector
[in]ivLenLength of the initialization vector
Returns
Error code

Definition at line 256 of file gmac.c.

◆ gmacUpdate()

void gmacUpdate ( GmacContext context,
const void *  data,
size_t  dataLen 
)

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

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

Definition at line 333 of file gmac.c.

◆ gmacXorBlock()

void gmacXorBlock ( 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 block
[in]bSecond block
[in]nSize of the block

Definition at line 489 of file gmac.c.