SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkSslKeccak.h File Reference
#include <stddef.h>
#include <stdint.h>
#include "TargConfig.h"
#include "SharkSSL_cfg.h"

Go to the source code of this file.

Data Structures

struct  SharkSslKeccak
 Caller-owned sponge storage; treat all members as implementation details. More...
 

Typedefs

typedef struct SharkSslKeccak SharkSslKeccak
 Caller-owned sponge storage; treat all members as implementation details. More...
 

Enumerations

enum  {
  SHARKSSL_KECCAK_RATE_SHAKE128 = 168 , SHARKSSL_KECCAK_RATE_SHAKE256 = 136 , SHARKSSL_KECCAK_RATE_SHA3_256 = 136 , SHARKSSL_KECCAK_RATE_SHA3_512 = 72 ,
  SHARKSSL_KECCAK_SUFFIX_SHA3 = 0x06 , SHARKSSL_KECCAK_SUFFIX_SHAKE = 0x1f
}
 Rate and domain-separation constants for the supported sponge algorithms. More...
 

Functions

void SharkSslKeccak_init (SharkSslKeccak *o, unsigned rate)
 Initialize or reset a FIPS 202 sponge for the selected algorithm. More...
 
void SharkSslKeccak_absorb (SharkSslKeccak *o, const uint8_t *data, size_t len)
 Append message bytes before finalization. More...
 
void SharkSslKeccak_finalize (SharkSslKeccak *o, uint8_t suffix)
 Apply padding and switch from message input to output. More...
 
void SharkSslKeccak_squeeze (SharkSslKeccak *o, uint8_t *out, size_t len)
 Read output bytes, continuing where the preceding call stopped. More...
 
void SharkSslKeccak_clear (SharkSslKeccak *o)
 Erase the complete context and leave it inactive. More...
 

Detailed Description

Byte-oriented SHA-3 and SHAKE sponge interface.

Available when SHARKSSL_USE_SHAKE, SHARKSSL_USE_MLKEM, or SHARKSSL_USE_MLDSA is enabled. Call init, absorb zero or more times, finalize once, squeeze, then clear. Buffers must not overlap the context. Calls are synchronous; the caller owns the context and serializes access to it. Select the matching rate and suffix. SHA3-256 and SHA3-512 require exactly 32 and 64 output bytes respectively; SHAKE permits further output calls. Only whole-byte messages and output lengths are supported.