cshake.h File Reference

cSHAKE128 and cSHAKE256 (customizable SHAKE function) More...

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

Go to the source code of this file.

Data Structures

struct  CshakeContext
 cSHAKE algorithm context More...
 

Functions

error_t cshakeCompute (uint_t strength, const void *input, size_t inputLen, const char_t *name, size_t nameLen, const char_t *custom, size_t customLen, uint8_t *output, size_t outputLen)
 Digest a message using cSHAKE128 or cSHAKE256. More...
 
error_t cshakeInit (CshakeContext *context, uint_t strength, const char_t *name, size_t nameLen, const char_t *custom, size_t customLen)
 Initialize cSHAKE context. More...
 
void cshakeAbsorb (CshakeContext *context, const void *input, size_t length)
 Absorb data. More...
 
void cshakeFinal (CshakeContext *context)
 Finish absorbing phase. More...
 
void cshakeSqueeze (CshakeContext *context, uint8_t *output, size_t length)
 Extract data from the squeezing phase. More...
 
void cshakeLeftEncode (size_t value, uint8_t *buffer, size_t *length)
 Encode integer as byte string. More...
 

Detailed Description

cSHAKE128 and cSHAKE256 (customizable SHAKE function)

License

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

Copyright (C) 2010-2024 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
2.4.0

Definition in file cshake.h.

Function Documentation

◆ cshakeAbsorb()

void cshakeAbsorb ( CshakeContext context,
const void *  input,
size_t  length 
)

Absorb data.

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

Definition at line 208 of file cshake.c.

◆ cshakeCompute()

error_t cshakeCompute ( uint_t  strength,
const void *  input,
size_t  inputLen,
const char_t name,
size_t  nameLen,
const char_t custom,
size_t  customLen,
uint8_t *  output,
size_t  outputLen 
)

Digest a message using cSHAKE128 or cSHAKE256.

Parameters
[in]strengthNumber of bits of security (128 for cSHAKE128 and 256 for cSHAKE256)
[in]inputPointer to the input data (X)
[in]inputLenLength of the input data
[in]nameFunction name (N)
[in]nameLenLength of the function name
[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 62 of file cshake.c.

◆ cshakeFinal()

void cshakeFinal ( CshakeContext context)

Finish absorbing phase.

Parameters
[in]contextPointer to the cSHAKE context

Definition at line 220 of file cshake.c.

◆ cshakeInit()

error_t cshakeInit ( CshakeContext context,
uint_t  strength,
const char_t name,
size_t  nameLen,
const char_t custom,
size_t  customLen 
)

Initialize cSHAKE context.

Parameters
[in]contextPointer to the cSHAKE context to initialize
[in]strengthNumber of bits of security (128 for cSHAKE128 and 256 for cSHAKE256)
[in]nameFunction name (N)
[in]nameLenLength of the function name
[in]customCustomization string (S)
[in]customLenLength of the customization string
Returns
Error code

Definition at line 124 of file cshake.c.

◆ cshakeLeftEncode()

void cshakeLeftEncode ( size_t  value,
uint8_t *  buffer,
size_t *  length 
)

Encode integer as byte string.

Parameters
[in]valueValue of the integer to be encoded
[out]bufferBuffer where to store the byte string representation
[out]lengthLength of the resulting byte string

Definition at line 262 of file cshake.c.

◆ cshakeSqueeze()

void cshakeSqueeze ( CshakeContext context,
uint8_t *  output,
size_t  length 
)

Extract data from the squeezing phase.

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

Definition at line 248 of file cshake.c.