MagickCore 7.0.10
sha3.c File Reference
#include "wizard/studio.h"
#include "wizard/exception.h"
#include "wizard/exception-private.h"
#include "wizard/memory_.h"
#include "wizard/sha3.h"
Include dependency graph for sha3.c:

Go to the source code of this file.

Data Structures

struct  _SHA3Info
 

Macros

#define SHA3Blocksize   64
 
#define SHA3Digestsize   64
 
#define SHA3Index(x, y)   (((x) % 5)+5*((y) % 5))
 
#define SHA3Lanes   25
 
#define SHA3MaximumRate   1536
 
#define SHA3PermutationSize   1600
 
#define SHA3RotateLeft(x, offset)
 
#define SHA3Rounds   24
 

Functions

WizardExport SHA3InfoAcquireSHA3Info (const HashType hash)
 
WizardExport SHA3InfoDestroySHA3Info (SHA3Info *sha_info)
 
static void ConvertBytesToWords (const unsigned char *bytes, WizardSizeType *words)
 
static void ConvertWordsToBytes (const WizardSizeType *words, unsigned char *bytes)
 
static void SHA3PermutationOnWords (const SHA3Info *sha_info, WizardSizeType *state)
 
static void SHA3Permutation (const SHA3Info *sha_info, unsigned char *bytes)
 
static void SHA3PermutationAfterXor (const SHA3Info *sha_info, const unsigned char *message, const size_t length, unsigned char *state)
 
static void AbsorbQueue (SHA3Info *sha_info)
 
static void PadAndSwitchToSqueezingPhase (SHA3Info *sha_info)
 
static WizardBooleanType Squeeze (SHA3Info *sha_info, const size_t length, unsigned char *output)
 
WizardExport WizardBooleanType FinalizeSHA3 (SHA3Info *sha_info)
 
WizardExport unsigned int GetSHA3Blocksize (const SHA3Info *sha_info)
 
WizardExport const StringInfoGetSHA3Digest (const SHA3Info *sha_info)
 
WizardExport unsigned int GetSHA3Digestsize (const SHA3Info *sha_info)
 
static int LFSR86540 (unsigned char *byte)
 
static void SHA3InitializeRoundConstants (SHA3Info *sha_info)
 
static void SHA3InitializeRho (SHA3Info *sha_info)
 
static WizardBooleanType InitializeSponge (SHA3Info *sha_info, const unsigned int rate, const unsigned int capacity)
 
WizardExport WizardBooleanType InitializeSHA3 (SHA3Info *sha_info)
 
static WizardBooleanType Absorb (SHA3Info *sha_info, const unsigned char *message, const size_t length)
 
WizardExport WizardBooleanType UpdateSHA3 (SHA3Info *sha_info, const StringInfo *message)
 

Macro Definition Documentation

◆ SHA3Blocksize

#define SHA3Blocksize   64

Definition at line 53 of file sha3.c.

◆ SHA3Digestsize

#define SHA3Digestsize   64

Definition at line 54 of file sha3.c.

◆ SHA3Index

#define SHA3Index (   x,
 
)    (((x) % 5)+5*((y) % 5))

Definition at line 55 of file sha3.c.

◆ SHA3Lanes

#define SHA3Lanes   25

Definition at line 56 of file sha3.c.

◆ SHA3MaximumRate

#define SHA3MaximumRate   1536

Definition at line 57 of file sha3.c.

◆ SHA3PermutationSize

#define SHA3PermutationSize   1600

Definition at line 58 of file sha3.c.

◆ SHA3RotateLeft

#define SHA3RotateLeft (   x,
  offset 
)
Value:
((offset) != 0 ? ((((WizardSizeType) (x)) << \
offset) ^ (((WizardSizeType) (x)) >> (64-(offset)))) : (x))
size_t WizardSizeType
Definition wizard-type.h:51

Definition at line 59 of file sha3.c.

◆ SHA3Rounds

#define SHA3Rounds   24

Definition at line 61 of file sha3.c.

Function Documentation

◆ Absorb()

static WizardBooleanType Absorb ( SHA3Info sha_info,
const unsigned char *  message,
const size_t  length 
)
inlinestatic

◆ AbsorbQueue()

static void AbsorbQueue ( SHA3Info sha_info)
inlinestatic

◆ AcquireSHA3Info()

◆ ConvertBytesToWords()

static void ConvertBytesToWords ( const unsigned char *  bytes,
WizardSizeType words 
)
inlinestatic

Definition at line 243 of file sha3.c.

References SHA3PermutationSize.

Referenced by SHA3Permutation().

◆ ConvertWordsToBytes()

static void ConvertWordsToBytes ( const WizardSizeType words,
unsigned char *  bytes 
)
inlinestatic

Definition at line 260 of file sha3.c.

References SHA3PermutationSize.

Referenced by SHA3Permutation().

◆ DestroySHA3Info()

◆ FinalizeSHA3()

◆ GetSHA3Blocksize()

WizardExport unsigned int GetSHA3Blocksize ( const SHA3Info sha_info)

◆ GetSHA3Digest()

WizardExport const StringInfo * GetSHA3Digest ( const SHA3Info sha_info)

◆ GetSHA3Digestsize()

WizardExport unsigned int GetSHA3Digestsize ( const SHA3Info sha_info)

◆ InitializeSHA3()

◆ InitializeSponge()

static WizardBooleanType InitializeSponge ( SHA3Info sha_info,
const unsigned int  rate,
const unsigned int  capacity 
)
inlinestatic

◆ LFSR86540()

static int LFSR86540 ( unsigned char *  byte)
inlinestatic

Definition at line 618 of file sha3.c.

Referenced by SHA3InitializeRoundConstants().

◆ PadAndSwitchToSqueezingPhase()

static void PadAndSwitchToSqueezingPhase ( SHA3Info sha_info)
inlinestatic

◆ SHA3InitializeRho()

static void SHA3InitializeRho ( SHA3Info sha_info)
inlinestatic

Definition at line 661 of file sha3.c.

References _SHA3Info::rho, and SHA3Index.

Referenced by InitializeSponge().

◆ SHA3InitializeRoundConstants()

static void SHA3InitializeRoundConstants ( SHA3Info sha_info)
inlinestatic

Definition at line 634 of file sha3.c.

References LFSR86540(), _SHA3Info::rounds, and SHA3Rounds.

Referenced by InitializeSponge().

◆ SHA3Permutation()

static void SHA3Permutation ( const SHA3Info sha_info,
unsigned char *  bytes 
)
inlinestatic

◆ SHA3PermutationAfterXor()

static void SHA3PermutationAfterXor ( const SHA3Info sha_info,
const unsigned char *  message,
const size_t  length,
unsigned char *  state 
)
inlinestatic

Definition at line 357 of file sha3.c.

References SHA3Permutation().

Referenced by Absorb(), and AbsorbQueue().

◆ SHA3PermutationOnWords()

static void SHA3PermutationOnWords ( const SHA3Info sha_info,
WizardSizeType state 
)
static

Definition at line 276 of file sha3.c.

References _SHA3Info::rho, _SHA3Info::rounds, SHA3Index, SHA3RotateLeft, and SHA3Rounds.

Referenced by SHA3Permutation().

◆ Squeeze()

static WizardBooleanType Squeeze ( SHA3Info sha_info,
const size_t  length,
unsigned char *  output 
)
inlinestatic

◆ UpdateSHA3()

WizardExport WizardBooleanType UpdateSHA3 ( SHA3Info sha_info,
const StringInfo message 
)

Definition at line 903 of file sha3.c.

References Absorb(), GetStringInfoDatum(), GetStringInfoLength(), _SHA3Info::signature, and WizardSignature.

Referenced by UpdateHash().