Kagome
Polkadot Runtime Engine in C++17
keccak.c File Reference
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "crypto/keccak/keccak.h"
#include "macro/endianness_utils.hpp"
Include dependency graph for keccak.c:

Go to the source code of this file.

Macros

#define SHA3_ASSERT(x)
 
#define SHA3_TRACE(format, args...)
 
#define SHA3_TRACE_BUF(format, buf, l, args...)
 
#define SHA3_USE_KECCAK_FLAG   0x80000000
 
#define SHA3_CW(x)   ((x) & (~SHA3_USE_KECCAK_FLAG))
 
#define SHA3_CONST(x)   x##L
 
#define SHA3_ROTL64(x, y)   (((x) << (y)) | ((x) >> ((sizeof(uint64_t) * 8) - (y))))
 
#define KECCAK_ROUNDS   24
 

Functions

void keccakf (uint64_t s[25])
 
sha3_return_t sha3_Init (void *priv, unsigned bitSize)
 
void sha3_Init256 (void *priv)
 
void sha3_Init384 (void *priv)
 
void sha3_Init512 (void *priv)
 
enum SHA3_FLAGS sha3_SetFlags (void *priv, enum SHA3_FLAGS flags)
 
void sha3_Update (void *priv, void const *bufIn, size_t len)
 
void const * sha3_Finalize (void *priv)
 
sha3_return_t sha3_HashBuffer (unsigned bitSize, enum SHA3_FLAGS flags, const void *in, unsigned inBytes, void *out, unsigned outBytes)
 

Variables

static const uint64_t keccakf_rndc [24]
 
static const unsigned keccakf_rotc [24]
 
static const unsigned keccakf_piln [24]
 

Macro Definition Documentation

#define KECCAK_ROUNDS   24
#define SHA3_ASSERT (   x)

Copyright Soramitsu Co., Ltd. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

Definition at line 13 of file keccak.c.

#define SHA3_CONST (   x)    x##L

Definition at line 31 of file keccak.c.

#define SHA3_CW (   x)    ((x) & (~SHA3_USE_KECCAK_FLAG))

Definition at line 26 of file keccak.c.

#define SHA3_ROTL64 (   x,
 
)    (((x) << (y)) | ((x) >> ((sizeof(uint64_t) * 8) - (y))))

Definition at line 35 of file keccak.c.

#define SHA3_TRACE (   format,
  args... 
)

Definition at line 18 of file keccak.c.

#define SHA3_TRACE_BUF (   format,
  buf,
  l,
  args... 
)

Definition at line 19 of file keccak.c.

#define SHA3_USE_KECCAK_FLAG   0x80000000

Definition at line 25 of file keccak.c.

Function Documentation

void keccakf ( uint64_t  s[25])

Definition at line 64 of file keccak.c.

void const* sha3_Finalize ( void *  priv)

Definition at line 232 of file keccak.c.

sha3_return_t sha3_HashBuffer ( unsigned  bitSize,
enum SHA3_FLAGS  flags,
const void *  in,
unsigned  inBytes,
void *  out,
unsigned  outBytes 
)

Definition at line 286 of file keccak.c.

sha3_return_t sha3_Init ( void *  priv,
unsigned  bitSize 
)

Definition at line 114 of file keccak.c.

void sha3_Init256 ( void *  priv)

Definition at line 123 of file keccak.c.

void sha3_Init384 ( void *  priv)

Definition at line 127 of file keccak.c.

void sha3_Init512 ( void *  priv)

Definition at line 131 of file keccak.c.

enum SHA3_FLAGS sha3_SetFlags ( void *  priv,
enum SHA3_FLAGS  flags 
)

Definition at line 135 of file keccak.c.

void sha3_Update ( void *  priv,
void const *  bufIn,
size_t  len 
)

Definition at line 142 of file keccak.c.

Variable Documentation

const unsigned keccakf_piln[24]
static
Initial value:
= {10, 7, 11, 17, 18, 3, 5, 16,
8, 21, 24, 4, 15, 23, 19, 13,
12, 2, 20, 14, 22, 9, 6, 1}

Definition at line 57 of file keccak.c.

const uint64_t keccakf_rndc[24]
static
Initial value:
= {
SHA3_CONST(0x0000000000000001UL), SHA3_CONST(0x0000000000008082UL),
SHA3_CONST(0x800000000000808aUL), SHA3_CONST(0x8000000080008000UL),
SHA3_CONST(0x000000000000808bUL), SHA3_CONST(0x0000000080000001UL),
SHA3_CONST(0x8000000080008081UL), SHA3_CONST(0x8000000000008009UL),
SHA3_CONST(0x000000000000008aUL), SHA3_CONST(0x0000000000000088UL),
SHA3_CONST(0x0000000080008009UL), SHA3_CONST(0x000000008000000aUL),
SHA3_CONST(0x000000008000808bUL), SHA3_CONST(0x800000000000008bUL),
SHA3_CONST(0x8000000000008089UL), SHA3_CONST(0x8000000000008003UL),
SHA3_CONST(0x8000000000008002UL), SHA3_CONST(0x8000000000000080UL),
SHA3_CONST(0x000000000000800aUL), SHA3_CONST(0x800000008000000aUL),
SHA3_CONST(0x8000000080008081UL), SHA3_CONST(0x8000000000008080UL),
SHA3_CONST(0x0000000080000001UL), SHA3_CONST(0x8000000080008008UL)}
#define SHA3_CONST(x)
Definition: keccak.c:31

Definition at line 39 of file keccak.c.

const unsigned keccakf_rotc[24]
static
Initial value:
= {1, 3, 6, 10, 15, 21, 28, 36,
45, 55, 2, 14, 27, 41, 56, 8,
25, 43, 62, 18, 39, 61, 20, 44}

Definition at line 53 of file keccak.c.