KMAC (Keccak Message Authentication Code) More...
Go to the source code of this file.
| Macros | |
| #define | TRACE_LEVEL CRYPTO_TRACE_LEVEL | 
| Functions | |
| error_t | kmacCompute (uint_t strength, const void *key, size_t keyLen, const void *data, size_t dataLen, const char_t *custom, size_t customLen, uint8_t *mac, size_t macLen) | 
| Compute KMAC message authentication code.  More... | |
| error_t | kmacInit (KmacContext *context, uint_t strength, const void *key, size_t keyLen, const char_t *custom, size_t customLen) | 
| Initialize KMAC calculation.  More... | |
| void | kmacUpdate (KmacContext *context, const void *data, size_t dataLen) | 
| Update the KMAC context with a portion of the message being hashed.  More... | |
| error_t | kmacFinal (KmacContext *context, uint8_t *mac, size_t macLen) | 
| Finish the KMAC calculation.  More... | |
| void | kmacDeinit (KmacContext *context) | 
| Release KMAC context.  More... | |
| void | kmacRightEncode (size_t value, uint8_t *buffer, size_t *length) | 
| Encode integer as byte string.  More... | |
| Variables | |
| const uint8_t | KMAC128_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x13} | 
| const uint8_t | KMAC256_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x14} | 
Detailed Description
KMAC (Keccak Message Authentication Code)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2025 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
The Keccak Message Authentication Code (KMAC) algorithm is a PRF and keyed hash function based on Keccak. KMAC has two variants, KMAC128 and KMAC256, built from cSHAKE128 and cSHAKE256, respectively
- Version
- 2.5.4
Definition in file kmac.c.
Macro Definition Documentation
◆ TRACE_LEVEL
Function Documentation
◆ kmacCompute()
| error_t kmacCompute | ( | uint_t | strength, | 
| const void * | key, | ||
| size_t | keyLen, | ||
| const void * | data, | ||
| size_t | dataLen, | ||
| const char_t * | custom, | ||
| size_t | customLen, | ||
| uint8_t * | mac, | ||
| size_t | macLen | ||
| ) | 
Compute KMAC message authentication code.
- Parameters
- 
  [in] strength Number of bits of security (128 for KMAC128 and 256 for KMAC256) [in] key Pointer to the secret key (K) [in] keyLen Length of the secret key [in] data Pointer to the input message (X) [in] dataLen Length of the input data [in] custom Customization string (S) [in] customLen Length of the customization string [out] mac Calculated MAC value [in] macLen Expected length of the MAC (L) 
- Returns
- Error code
◆ kmacDeinit()
| void kmacDeinit | ( | KmacContext * | context | ) | 
◆ kmacFinal()
| error_t kmacFinal | ( | KmacContext * | context, | 
| uint8_t * | mac, | ||
| size_t | macLen | ||
| ) | 
◆ kmacInit()
| error_t kmacInit | ( | KmacContext * | context, | 
| uint_t | strength, | ||
| const void * | key, | ||
| size_t | keyLen, | ||
| const char_t * | custom, | ||
| size_t | customLen | ||
| ) | 
Initialize KMAC calculation.
- Parameters
- 
  [in] context Pointer to the KMAC context to initialize [in] strength Number of bits of security (128 for KMAC128 and 256 for KMAC256) [in] key Pointer to the secret key (K) [in] keyLen Length of the secret key [in] custom Customization string (S) [in] customLen Length of the customization string 
- Returns
- Error code
◆ kmacRightEncode()
| void kmacRightEncode | ( | size_t | value, | 
| uint8_t * | buffer, | ||
| size_t * | length | ||
| ) | 
◆ kmacUpdate()
| void kmacUpdate | ( | KmacContext * | context, | 
| const void * | data, | ||
| size_t | dataLen | ||
| ) | 
Variable Documentation
◆ KMAC128_OID
| const uint8_t KMAC128_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x13} | 
