Electroneum
Classes | Macros | Functions | Variables
slow-hash.c File Reference
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "common/int-util.h"
#include "hash-ops.h"
#include "oaes_lib.h"
Include dependency graph for slow-hash.c:

Classes

union  cn_slow_hash_state
 

Macros

#define MEMORY   (1 << 21)
 
#define ITER   (1 << 20)
 
#define AES_BLOCK_SIZE   16
 
#define AES_KEY_SIZE   32
 
#define INIT_SIZE_BLK   8
 
#define INIT_SIZE_BYTE   (INIT_SIZE_BLK * AES_BLOCK_SIZE)
 
#define VARIANT1_1(p)
 
#define VARIANT1_2(p)
 
#define VARIANT1_CHECK()
 
#define NONCE_POINTER   (((const uint8_t*)data)+35)
 
#define VARIANT1_PORTABLE_INIT()
 
#define VARIANT1_INIT64()
 
#define U64(x)   ((uint64_t *) (x))
 

Functions

int aesb_single_round (const uint8_t *in, uint8_t *out, const uint8_t *expandedKey)
 
int aesb_pseudo_round (const uint8_t *in, uint8_t *out, const uint8_t *expandedKey)
 
void slow_hash_allocate_state (void)
 
void slow_hash_free_state (void)
 
static size_t e2i (const uint8_t *a, size_t count)
 
static void mul (const uint8_t *a, const uint8_t *b, uint8_t *res)
 
static void sum_half_blocks (uint8_t *a, const uint8_t *b)
 
static void copy_block (uint8_t *dst, const uint8_t *src)
 
static void swap_blocks (uint8_t *a, uint8_t *b)
 
static void xor_blocks (uint8_t *a, const uint8_t *b)
 
static void xor64 (uint8_t *left, const uint8_t *right)
 
void cn_slow_hash (const void *data, size_t length, char *hash, int variant)
 

Variables

static void(*const extra_hashes [4])(const void *, size_t, char *)
 

Macro Definition Documentation

◆ AES_BLOCK_SIZE

#define AES_BLOCK_SIZE   16

◆ AES_KEY_SIZE

#define AES_KEY_SIZE   32

◆ INIT_SIZE_BLK

#define INIT_SIZE_BLK   8

◆ INIT_SIZE_BYTE

#define INIT_SIZE_BYTE   (INIT_SIZE_BLK * AES_BLOCK_SIZE)

◆ ITER

#define ITER   (1 << 20)

◆ MEMORY

#define MEMORY   (1 << 21)

◆ NONCE_POINTER

#define NONCE_POINTER   (((const uint8_t*)data)+35)

◆ U64

#define U64 (   x)    ((uint64_t *) (x))

◆ VARIANT1_1

#define VARIANT1_1 (   p)
Value:
do if (variant > 0) \
{ \
const uint8_t tmp = ((const uint8_t*)(p))[11]; \
static const uint32_t table = 0x75310; \
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \
((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \
} while(0)

◆ VARIANT1_2

#define VARIANT1_2 (   p)
Value:
do if (variant > 0) \
{ \
xor64(p, tweak1_2); \
} while(0)

◆ VARIANT1_CHECK

#define VARIANT1_CHECK ( )
Value:
do if (length < 43) \
{ \
fprintf(stderr, "Cryptonight variants need at least 43 bytes of data"); \
_exit(1); \
} while(0)

◆ VARIANT1_INIT64

#define VARIANT1_INIT64 ( )
Value:
if (variant > 0) \
{ \
VARIANT1_CHECK(); \
} \
const uint64_t tweak1_2 = variant > 0 ? (state.hs.w[24] ^ (*((const uint64_t*)NONCE_POINTER))) : 0
Definition: blake256.h:37
#define NONCE_POINTER
Definition: slow-hash.c:75

◆ VARIANT1_PORTABLE_INIT

#define VARIANT1_PORTABLE_INIT ( )
Value:
uint8_t tweak1_2[8]; \
do if (variant > 0) \
{ \
VARIANT1_CHECK(); \
memcpy(&tweak1_2, &state.hs.b[192], sizeof(tweak1_2)); \
xor64(tweak1_2, NONCE_POINTER); \
} while(0)
Definition: blake256.h:37
#define NONCE_POINTER
Definition: slow-hash.c:75

Function Documentation

◆ aesb_pseudo_round()

int aesb_pseudo_round ( const uint8_t *  in,
uint8_t *  out,
const uint8_t *  expandedKey 
)

◆ aesb_single_round()

int aesb_single_round ( const uint8_t *  in,
uint8_t *  out,
const uint8_t *  expandedKey 
)

◆ cn_slow_hash()

void cn_slow_hash ( const void *  data,
size_t  length,
char *  hash,
int  variant 
)

◆ copy_block()

static void copy_block ( uint8_t *  dst,
const uint8_t *  src 
)
static

◆ e2i()

static size_t e2i ( const uint8_t *  a,
size_t  count 
)
static

◆ mul()

static void mul ( const uint8_t *  a,
const uint8_t *  b,
uint8_t *  res 
)
static

◆ slow_hash_allocate_state()

void slow_hash_allocate_state ( void  )

◆ slow_hash_free_state()

void slow_hash_free_state ( void  )

◆ sum_half_blocks()

static void sum_half_blocks ( uint8_t *  a,
const uint8_t *  b 
)
static

◆ swap_blocks()

static void swap_blocks ( uint8_t *  a,
uint8_t *  b 
)
static

◆ xor64()

static void xor64 ( uint8_t *  left,
const uint8_t *  right 
)
static

◆ xor_blocks()

static void xor_blocks ( uint8_t *  a,
const uint8_t *  b 
)
static

Variable Documentation

◆ extra_hashes

void(*const extra_hashes[4])(const void *, size_t, char *)
static
Initial value:
= {
}
void hash_extra_jh(const void *data, size_t length, char *hash)
Definition: hash-extra-jh.c:40
void hash_extra_blake(const void *data, size_t length, char *hash)
Definition: hash-extra-blake.c:37
void hash_extra_skein(const void *data, size_t length, char *hash)
Definition: hash-extra-skein.c:38
void hash_extra_groestl(const void *data, size_t length, char *hash)
Definition: hash-extra-groestl.c:37