hmac.h File Reference

HMAC (Keyed-Hashing for Message Authentication) More...

#include "core/crypto.h"
#include "hash/md2.h"
#include "hash/md4.h"
#include "hash/md5.h"
#include "hash/ripemd128.h"
#include "hash/ripemd160.h"
#include "hash/sha1.h"
#include "hash/sha224.h"
#include "hash/sha256.h"
#include "hash/sha384.h"
#include "hash/sha512.h"
#include "hash/sha512_224.h"
#include "hash/sha512_256.h"
#include "hash/sha3_224.h"
#include "hash/sha3_256.h"
#include "hash/sha3_384.h"
#include "hash/sha3_512.h"
#include "hash/blake2b160.h"
#include "hash/blake2b256.h"
#include "hash/blake2b384.h"
#include "hash/blake2b512.h"
#include "hash/blake2s128.h"
#include "hash/blake2s160.h"
#include "hash/blake2s224.h"
#include "hash/blake2s256.h"
#include "hash/tiger.h"
#include "hash/whirlpool.h"

Go to the source code of this file.

Data Structures

struct  HmacContext
 HMAC algorithm context. More...
 

Macros

#define HMAC_IPAD   0x36
 
#define HMAC_OPAD   0x5C
 

Functions

error_t hmacCompute (const HashAlgo *hash, const void *key, size_t keyLen, const void *data, size_t dataLen, uint8_t *digest)
 Compute HMAC using the specified hash function. More...
 
void hmacInit (HmacContext *context, const HashAlgo *hash, const void *key, size_t keyLen)
 Initialize HMAC calculation. More...
 
void hmacUpdate (HmacContext *context, const void *data, size_t length)
 Update the HMAC context with a portion of the message being hashed. More...
 
void hmacFinal (HmacContext *context, uint8_t *digest)
 Finish the HMAC calculation. More...
 

Variables

const uint8_t HMAC_WITH_MD5_OID [8]
 
const uint8_t HMAC_WITH_TIGER_OID [8]
 
const uint8_t HMAC_WITH_RIPEMD160_OID [8]
 
const uint8_t HMAC_WITH_SHA1_OID [8]
 
const uint8_t HMAC_WITH_SHA224_OID [8]
 
const uint8_t HMAC_WITH_SHA256_OID [8]
 
const uint8_t HMAC_WITH_SHA384_OID [8]
 
const uint8_t HMAC_WITH_SHA512_OID [8]
 
const uint8_t HMAC_WITH_SHA3_224_OID [9]
 
const uint8_t HMAC_WITH_SHA3_256_OID [9]
 
const uint8_t HMAC_WITH_SHA3_384_OID [9]
 
const uint8_t HMAC_WITH_SHA3_512_OID [9]
 

Detailed Description

HMAC (Keyed-Hashing for Message Authentication)

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 hmac.h.

Macro Definition Documentation

◆ HMAC_IPAD

#define HMAC_IPAD   0x36

Definition at line 166 of file hmac.h.

◆ HMAC_OPAD

#define HMAC_OPAD   0x5C

Definition at line 168 of file hmac.h.

Function Documentation

◆ hmacCompute()

error_t hmacCompute ( const HashAlgo hash,
const void *  key,
size_t  keyLen,
const void *  data,
size_t  dataLen,
uint8_t *  digest 
)

Compute HMAC using the specified hash function.

Parameters
[in]hashHash algorithm used to compute HMAC
[in]keyKey to use in the hash algorithm
[in]keyLenLength of the key
[in]dataThe input data for which to compute the hash code
[in]dataLenLength of the input data
[out]digestThe computed HMAC value
Returns
Error code

Definition at line 83 of file hmac.c.

◆ hmacFinal()

void hmacFinal ( HmacContext context,
uint8_t *  digest 
)

Finish the HMAC calculation.

Parameters
[in]contextPointer to the HMAC context
[out]digestCalculated HMAC value (optional parameter)

Definition at line 183 of file hmac.c.

◆ hmacInit()

void hmacInit ( HmacContext context,
const HashAlgo hash,
const void *  key,
size_t  keyLen 
)

Initialize HMAC calculation.

Parameters
[in]contextPointer to the HMAC context to initialize
[in]hashHash algorithm used to compute HMAC
[in]keyKey to use in the hash algorithm
[in]keyLenLength of the key

Definition at line 116 of file hmac.c.

◆ hmacUpdate()

void hmacUpdate ( HmacContext context,
const void *  data,
size_t  length 
)

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

Parameters
[in]contextPointer to the HMAC context
[in]dataPointer to the buffer being hashed
[in]lengthLength of the buffer

Definition at line 166 of file hmac.c.

Variable Documentation

◆ HMAC_WITH_MD5_OID

const uint8_t HMAC_WITH_MD5_OID[8]

Definition at line 47 of file hmac.c.

◆ HMAC_WITH_RIPEMD160_OID

const uint8_t HMAC_WITH_RIPEMD160_OID[8]

Definition at line 51 of file hmac.c.

◆ HMAC_WITH_SHA1_OID

const uint8_t HMAC_WITH_SHA1_OID[8]

Definition at line 53 of file hmac.c.

◆ HMAC_WITH_SHA224_OID

const uint8_t HMAC_WITH_SHA224_OID[8]

Definition at line 55 of file hmac.c.

◆ HMAC_WITH_SHA256_OID

const uint8_t HMAC_WITH_SHA256_OID[8]

Definition at line 57 of file hmac.c.

◆ HMAC_WITH_SHA384_OID

const uint8_t HMAC_WITH_SHA384_OID[8]

Definition at line 59 of file hmac.c.

◆ HMAC_WITH_SHA3_224_OID

const uint8_t HMAC_WITH_SHA3_224_OID[9]

Definition at line 63 of file hmac.c.

◆ HMAC_WITH_SHA3_256_OID

const uint8_t HMAC_WITH_SHA3_256_OID[9]

Definition at line 65 of file hmac.c.

◆ HMAC_WITH_SHA3_384_OID

const uint8_t HMAC_WITH_SHA3_384_OID[9]

Definition at line 67 of file hmac.c.

◆ HMAC_WITH_SHA3_512_OID

const uint8_t HMAC_WITH_SHA3_512_OID[9]

Definition at line 69 of file hmac.c.

◆ HMAC_WITH_SHA512_OID

const uint8_t HMAC_WITH_SHA512_OID[8]

Definition at line 61 of file hmac.c.

◆ HMAC_WITH_TIGER_OID

const uint8_t HMAC_WITH_TIGER_OID[8]

Definition at line 49 of file hmac.c.