kmac_xof.c File Reference

KMACXOF (KMAC with arbitrary-length output) More...

#include "core/crypto.h"
#include "xof/kmac_xof.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 

Functions

error_t kmacXofCompute (uint_t strength, const void *key, size_t keyLen, const void *input, size_t inputLen, const char_t *custom, size_t customLen, uint8_t *output, size_t outputLen)
 Digest a message using KMACXOF. More...
 
error_t kmacXofInit (KmacXofContext *context, uint_t strength, const void *key, size_t keyLen, const char_t *custom, size_t customLen)
 Initialize KMACXOF context. More...
 
void kmacXofAbsorb (KmacXofContext *context, const void *input, size_t length)
 Absorb data. More...
 
void kmacXofFinal (KmacXofContext *context)
 Finish absorbing phase. More...
 
void kmacXofSqueeze (KmacXofContext *context, uint8_t *output, size_t length)
 Extract data from the squeezing phase. More...
 

Variables

const uint8_t KMAC_XOF128_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x15}
 
const uint8_t KMAC_XOF256_OID [9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x16}
 

Detailed Description

KMACXOF (KMAC with arbitrary-length output)

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2026 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.

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

Definition in file kmac_xof.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 28 of file kmac_xof.c.

Function Documentation

◆ kmacXofAbsorb()

void kmacXofAbsorb ( KmacXofContext *  context,
const void *  input,
size_t  length 
)

Absorb data.

Parameters
[in]contextPointer to the KMACXOF context
[in]inputPointer to the buffer being hashed
[in]lengthLength of the buffer

Definition at line 183 of file kmac_xof.c.

◆ kmacXofCompute()

error_t kmacXofCompute ( uint_t  strength,
const void *  key,
size_t  keyLen,
const void *  input,
size_t  inputLen,
const char_t *  custom,
size_t  customLen,
uint8_t *  output,
size_t  outputLen 
)

Digest a message using KMACXOF.

Parameters
[in]strengthNumber of bits of security (128 for KMACXOF128 and 256 for KMACXOF256)
[in]keyPointer to the secret key (K)
[in]keyLenLength of the secret key
[in]inputPointer to the input data (X)
[in]inputLenLength of the input data
[in]customCustomization string (S)
[in]customLenLength of the customization string
[out]outputPointer to the output data
[in]outputLenExpected length of the output data (L)
Returns
Error code

Definition at line 58 of file kmac_xof.c.

◆ kmacXofFinal()

void kmacXofFinal ( KmacXofContext *  context)

Finish absorbing phase.

Parameters
[in]contextPointer to the KMACXOF context

Definition at line 195 of file kmac_xof.c.

◆ kmacXofInit()

error_t kmacXofInit ( KmacXofContext *  context,
uint_t  strength,
const void *  key,
size_t  keyLen,
const char_t *  custom,
size_t  customLen 
)

Initialize KMACXOF context.

Parameters
[in]contextPointer to the KMACXOF context to initialize
[in]strengthNumber of bits of security (128 for KMACXOF128 and 256 for KMACXOF256)
[in]keyPointer to the secret key (K)
[in]keyLenLength of the secret key
[in]customCustomization string (S)
[in]customLenLength of the customization string
Returns
Error code

Definition at line 120 of file kmac_xof.c.

◆ kmacXofSqueeze()

void kmacXofSqueeze ( KmacXofContext *  context,
uint8_t *  output,
size_t  length 
)

Extract data from the squeezing phase.

Parameters
[in]contextPointer to the KMACXOF context
[out]outputOutput string
[in]lengthDesired output length, in bytes

Definition at line 217 of file kmac_xof.c.

Variable Documentation

◆ KMAC_XOF128_OID

const uint8_t KMAC_XOF128_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x15}

Definition at line 38 of file kmac_xof.c.

◆ KMAC_XOF256_OID

const uint8_t KMAC_XOF256_OID[9] = {0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x16}

Definition at line 40 of file kmac_xof.c.