Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

cubehash.c File Reference
#include <stddef.h>
#include <string.h>
#include <limits.h>
#include "sph_cubehash.h"
+ Include dependency graph for cubehash.c:

Go to the source code of this file.

Macros

#define SPH_CUBEHASH_UNROLL   0
 
#define SPH_CUBEHASH_NOCOPY   0
 
#define T32   SPH_T32
 
#define ROTL32   SPH_ROTL32
 
#define DECL_STATE
 
#define READ_STATE(cc)
 
#define WRITE_STATE(cc)
 
#define INPUT_BLOCK
 
#define ROUND_EVEN
 
#define ROUND_ODD
 
#define SIXTEEN_ROUNDS
 

Functions

static void cubehash_init (sph_cubehash_context *sc, const sph_u32 *iv)
 
static void cubehash_core (sph_cubehash_context *sc, const void *data, size_t len)
 
static void cubehash_close (sph_cubehash_context *sc, unsigned ub, unsigned n, void *dst, size_t out_size_w32)
 
void sph_cubehash224_init (void *cc)
 Initialize a CubeHash-224 context. More...
 
void sph_cubehash224 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_cubehash224_close (void *cc, void *dst)
 Terminate the current CubeHash-224 computation and output the result into the provided buffer. More...
 
void sph_cubehash224_addbits_and_close (void *cc, unsigned ub, unsigned n, void *dst)
 Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (28 bytes). More...
 
void sph_cubehash256_init (void *cc)
 Initialize a CubeHash-256 context. More...
 
void sph_cubehash256 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_cubehash256_close (void *cc, void *dst)
 Terminate the current CubeHash-256 computation and output the result into the provided buffer. More...
 
void sph_cubehash256_addbits_and_close (void *cc, unsigned ub, unsigned n, void *dst)
 Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (32 bytes). More...
 
void sph_cubehash384_init (void *cc)
 Initialize a CubeHash-384 context. More...
 
void sph_cubehash384 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_cubehash384_close (void *cc, void *dst)
 Terminate the current CubeHash-384 computation and output the result into the provided buffer. More...
 
void sph_cubehash384_addbits_and_close (void *cc, unsigned ub, unsigned n, void *dst)
 Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (48 bytes). More...
 
void sph_cubehash512_init (void *cc)
 Initialize a CubeHash-512 context. More...
 
void sph_cubehash512 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_cubehash512_close (void *cc, void *dst)
 Terminate the current CubeHash-512 computation and output the result into the provided buffer. More...
 
void sph_cubehash512_addbits_and_close (void *cc, unsigned ub, unsigned n, void *dst)
 Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (64 bytes). More...
 

Variables

static const sph_u32 IV224 []
 
static const sph_u32 IV256 []
 
static const sph_u32 IV384 []
 
static const sph_u32 IV512 []
 

Macro Definition Documentation

◆ DECL_STATE

#define DECL_STATE
Value:
sph_u32 x0, x1, x2, x3, x4, x5, x6, x7; \
sph_u32 x8, x9, xa, xb, xc, xd, xe, xf; \
sph_u32 xg, xh, xi, xj, xk, xl, xm, xn; \
sph_u32 xo, xp, xq, xr, xs, xt, xu, xv;
unsigned long sph_u32
Definition: sph_types.h:870

Definition at line 178 of file cubehash.c.

Referenced by cubehash_close(), and cubehash_core().

◆ INPUT_BLOCK

#define INPUT_BLOCK
Value:
do { \
x0 ^= sph_dec32le_aligned(buf + 0); \
x1 ^= sph_dec32le_aligned(buf + 4); \
x2 ^= sph_dec32le_aligned(buf + 8); \
x3 ^= sph_dec32le_aligned(buf + 12); \
x4 ^= sph_dec32le_aligned(buf + 16); \
x5 ^= sph_dec32le_aligned(buf + 20); \
x6 ^= sph_dec32le_aligned(buf + 24); \
x7 ^= sph_dec32le_aligned(buf + 28); \
} while (0)
static SPH_INLINE sph_u32 sph_dec32le_aligned(const void *src)
Decode a 32-bit value from the provided buffer (little endian convention).
Definition: sph_types.h:1615

Definition at line 256 of file cubehash.c.

Referenced by cubehash_close(), and cubehash_core().

◆ READ_STATE

#define READ_STATE (   cc)

Definition at line 184 of file cubehash.c.

Referenced by cubehash_close(), and cubehash_core().

◆ ROTL32

#define ROTL32   SPH_ROTL32

Definition at line 135 of file cubehash.c.

◆ ROUND_EVEN

#define ROUND_EVEN

Definition at line 267 of file cubehash.c.

◆ ROUND_ODD

#define ROUND_ODD

Definition at line 366 of file cubehash.c.

◆ SIXTEEN_ROUNDS

#define SIXTEEN_ROUNDS
Value:
do { \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
ROUND_EVEN; \
ROUND_ODD; \
} while (0)

Definition at line 513 of file cubehash.c.

Referenced by cubehash_close(), and cubehash_core().

◆ SPH_CUBEHASH_NOCOPY

#define SPH_CUBEHASH_NOCOPY   0

Definition at line 69 of file cubehash.c.

◆ SPH_CUBEHASH_UNROLL

#define SPH_CUBEHASH_UNROLL   0

Definition at line 66 of file cubehash.c.

◆ T32

#define T32   SPH_T32

Definition at line 134 of file cubehash.c.

◆ WRITE_STATE

#define WRITE_STATE (   cc)

Definition at line 219 of file cubehash.c.

Referenced by cubehash_close(), and cubehash_core().

Function Documentation

◆ cubehash_close()

◆ cubehash_core()

static void cubehash_core ( sph_cubehash_context sc,
const void *  data,
size_t  len 
)
static

◆ cubehash_init()

static void cubehash_init ( sph_cubehash_context sc,
const sph_u32 iv 
)
static

◆ sph_cubehash224()

void sph_cubehash224 ( void *  cc,
const void *  data,
size_t  len 
)

Process some data bytes.

It is acceptable that len is zero (in which case this function does nothing).

Parameters
ccthe CubeHash-224 context
datathe input data
lenthe input data length (in bytes)

Definition at line 615 of file cubehash.c.

References cubehash_core().

◆ sph_cubehash224_addbits_and_close()

void sph_cubehash224_addbits_and_close ( void *  cc,
unsigned  ub,
unsigned  n,
void *  dst 
)

Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (28 bytes).

If bit number i in ub has value 2^i, then the extra bits are those numbered 7 downto 8-n (this is the big-endian convention at the byte level). The context is automatically reinitialized.

Parameters
ccthe CubeHash-224 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 629 of file cubehash.c.

References cubehash_close(), and sph_cubehash224_init().

Referenced by sph_cubehash224_close().

◆ sph_cubehash224_close()

void sph_cubehash224_close ( void *  cc,
void *  dst 
)

Terminate the current CubeHash-224 computation and output the result into the provided buffer.

The destination buffer must be wide enough to accomodate the result (28 bytes). The context is automatically reinitialized.

Parameters
ccthe CubeHash-224 context
dstthe destination buffer

Definition at line 622 of file cubehash.c.

References sph_cubehash224_addbits_and_close().

◆ sph_cubehash224_init()

void sph_cubehash224_init ( void *  cc)

Initialize a CubeHash-224 context.

This process performs no memory allocation.

Parameters
ccthe CubeHash-224 context (pointer to a sph_cubehash224_context)

Definition at line 608 of file cubehash.c.

References cubehash_init(), and IV224.

Referenced by sph_cubehash224_addbits_and_close().

◆ sph_cubehash256()

void sph_cubehash256 ( void *  cc,
const void *  data,
size_t  len 
)

Process some data bytes.

It is acceptable that len is zero (in which case this function does nothing).

Parameters
ccthe CubeHash-256 context
datathe input data
lenthe input data length (in bytes)

Definition at line 644 of file cubehash.c.

References cubehash_core().

◆ sph_cubehash256_addbits_and_close()

void sph_cubehash256_addbits_and_close ( void *  cc,
unsigned  ub,
unsigned  n,
void *  dst 
)

Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (32 bytes).

If bit number i in ub has value 2^i, then the extra bits are those numbered 7 downto 8-n (this is the big-endian convention at the byte level). The context is automatically reinitialized.

Parameters
ccthe CubeHash-256 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 658 of file cubehash.c.

References cubehash_close(), and sph_cubehash256_init().

Referenced by sph_cubehash256_close().

◆ sph_cubehash256_close()

void sph_cubehash256_close ( void *  cc,
void *  dst 
)

Terminate the current CubeHash-256 computation and output the result into the provided buffer.

The destination buffer must be wide enough to accomodate the result (32 bytes). The context is automatically reinitialized.

Parameters
ccthe CubeHash-256 context
dstthe destination buffer

Definition at line 651 of file cubehash.c.

References sph_cubehash256_addbits_and_close().

◆ sph_cubehash256_init()

void sph_cubehash256_init ( void *  cc)

Initialize a CubeHash-256 context.

This process performs no memory allocation.

Parameters
ccthe CubeHash-256 context (pointer to a sph_cubehash256_context)

Definition at line 637 of file cubehash.c.

References cubehash_init(), and IV256.

Referenced by sph_cubehash256_addbits_and_close().

◆ sph_cubehash384()

void sph_cubehash384 ( void *  cc,
const void *  data,
size_t  len 
)

Process some data bytes.

It is acceptable that len is zero (in which case this function does nothing).

Parameters
ccthe CubeHash-384 context
datathe input data
lenthe input data length (in bytes)

Definition at line 673 of file cubehash.c.

References cubehash_core().

◆ sph_cubehash384_addbits_and_close()

void sph_cubehash384_addbits_and_close ( void *  cc,
unsigned  ub,
unsigned  n,
void *  dst 
)

Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (48 bytes).

If bit number i in ub has value 2^i, then the extra bits are those numbered 7 downto 8-n (this is the big-endian convention at the byte level). The context is automatically reinitialized.

Parameters
ccthe CubeHash-384 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 687 of file cubehash.c.

References cubehash_close(), and sph_cubehash384_init().

Referenced by sph_cubehash384_close().

◆ sph_cubehash384_close()

void sph_cubehash384_close ( void *  cc,
void *  dst 
)

Terminate the current CubeHash-384 computation and output the result into the provided buffer.

The destination buffer must be wide enough to accomodate the result (48 bytes). The context is automatically reinitialized.

Parameters
ccthe CubeHash-384 context
dstthe destination buffer

Definition at line 680 of file cubehash.c.

References sph_cubehash384_addbits_and_close().

◆ sph_cubehash384_init()

void sph_cubehash384_init ( void *  cc)

Initialize a CubeHash-384 context.

This process performs no memory allocation.

Parameters
ccthe CubeHash-384 context (pointer to a sph_cubehash384_context)

Definition at line 666 of file cubehash.c.

References cubehash_init(), and IV384.

Referenced by sph_cubehash384_addbits_and_close().

◆ sph_cubehash512()

void sph_cubehash512 ( void *  cc,
const void *  data,
size_t  len 
)

Process some data bytes.

It is acceptable that len is zero (in which case this function does nothing).

Parameters
ccthe CubeHash-512 context
datathe input data
lenthe input data length (in bytes)

Definition at line 702 of file cubehash.c.

References cubehash_core().

Referenced by HashX11().

◆ sph_cubehash512_addbits_and_close()

void sph_cubehash512_addbits_and_close ( void *  cc,
unsigned  ub,
unsigned  n,
void *  dst 
)

Add a few additional bits (0 to 7) to the current computation, then terminate it and output the result in the provided buffer, which must be wide enough to accomodate the result (64 bytes).

If bit number i in ub has value 2^i, then the extra bits are those numbered 7 downto 8-n (this is the big-endian convention at the byte level). The context is automatically reinitialized.

Parameters
ccthe CubeHash-512 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 716 of file cubehash.c.

References cubehash_close(), and sph_cubehash512_init().

Referenced by sph_cubehash512_close().

◆ sph_cubehash512_close()

void sph_cubehash512_close ( void *  cc,
void *  dst 
)

Terminate the current CubeHash-512 computation and output the result into the provided buffer.

The destination buffer must be wide enough to accomodate the result (64 bytes). The context is automatically reinitialized.

Parameters
ccthe CubeHash-512 context
dstthe destination buffer

Definition at line 709 of file cubehash.c.

References sph_cubehash512_addbits_and_close().

Referenced by HashX11().

◆ sph_cubehash512_init()

void sph_cubehash512_init ( void *  cc)

Initialize a CubeHash-512 context.

This process performs no memory allocation.

Parameters
ccthe CubeHash-512 context (pointer to a sph_cubehash512_context)

Definition at line 695 of file cubehash.c.

References cubehash_init(), and IV512.

Referenced by HashX11(), and sph_cubehash512_addbits_and_close().

Variable Documentation

◆ IV224

const sph_u32 IV224[]
static
Initial value:
= {
SPH_C32(0xB0FC8217), SPH_C32(0x1BEE1A90), SPH_C32(0x829E1A22),
SPH_C32(0x6362C342), SPH_C32(0x24D91C30), SPH_C32(0x03A7AA24),
SPH_C32(0xA63721C8), SPH_C32(0x85B0E2EF), SPH_C32(0xF35D13F3),
SPH_C32(0x41DA807D), SPH_C32(0x21A70CA6), SPH_C32(0x1F4E9774),
SPH_C32(0xB3E1C932), SPH_C32(0xEB0A79A8), SPH_C32(0xCDDAAA66),
SPH_C32(0xE2F6ECAA), SPH_C32(0x0A713362), SPH_C32(0xAA3080E0),
SPH_C32(0xD8F23A32), SPH_C32(0xCEF15E28), SPH_C32(0xDB086314),
SPH_C32(0x7F709DF7), SPH_C32(0xACD228A4), SPH_C32(0x704D6ECE),
SPH_C32(0xAA3EC95F), SPH_C32(0xE387C214), SPH_C32(0x3A6445FF),
SPH_C32(0x9CAB81C3), SPH_C32(0xC73D4B98), SPH_C32(0xD277AEBE),
SPH_C32(0xFD20151C), SPH_C32(0x00CB573E)
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 78 of file cubehash.c.

Referenced by sph_cubehash224_init().

◆ IV256

const sph_u32 IV256[]
static
Initial value:
= {
SPH_C32(0xEA2BD4B4), SPH_C32(0xCCD6F29F), SPH_C32(0x63117E71),
SPH_C32(0x35481EAE), SPH_C32(0x22512D5B), SPH_C32(0xE5D94E63),
SPH_C32(0x7E624131), SPH_C32(0xF4CC12BE), SPH_C32(0xC2D0B696),
SPH_C32(0x42AF2070), SPH_C32(0xD0720C35), SPH_C32(0x3361DA8C),
SPH_C32(0x28CCECA4), SPH_C32(0x8EF8AD83), SPH_C32(0x4680AC00),
SPH_C32(0x40E5FBAB), SPH_C32(0xD89041C3), SPH_C32(0x6107FBD5),
SPH_C32(0x6C859D41), SPH_C32(0xF0B26679), SPH_C32(0x09392549),
SPH_C32(0x5FA25603), SPH_C32(0x65C892FD), SPH_C32(0x93CB6285),
SPH_C32(0x2AF2B5AE), SPH_C32(0x9E4B4E60), SPH_C32(0x774ABFDD),
SPH_C32(0x85254725), SPH_C32(0x15815AEB), SPH_C32(0x4AB6AAD6),
SPH_C32(0x9CDAF8AF), SPH_C32(0xD6032C0A)
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 92 of file cubehash.c.

Referenced by sph_cubehash256_init().

◆ IV384

const sph_u32 IV384[]
static
Initial value:
= {
SPH_C32(0xE623087E), SPH_C32(0x04C00C87), SPH_C32(0x5EF46453),
SPH_C32(0x69524B13), SPH_C32(0x1A05C7A9), SPH_C32(0x3528DF88),
SPH_C32(0x6BDD01B5), SPH_C32(0x5057B792), SPH_C32(0x6AA7A922),
SPH_C32(0x649C7EEE), SPH_C32(0xF426309F), SPH_C32(0xCB629052),
SPH_C32(0xFC8E20ED), SPH_C32(0xB3482BAB), SPH_C32(0xF89E5E7E),
SPH_C32(0xD83D4DE4), SPH_C32(0x44BFC10D), SPH_C32(0x5FC1E63D),
SPH_C32(0x2104E6CB), SPH_C32(0x17958F7F), SPH_C32(0xDBEAEF70),
SPH_C32(0xB4B97E1E), SPH_C32(0x32C195F6), SPH_C32(0x6184A8E4),
SPH_C32(0x796C2543), SPH_C32(0x23DE176D), SPH_C32(0xD33BBAEC),
SPH_C32(0x0C12E5D2), SPH_C32(0x4EB95A7B), SPH_C32(0x2D18BA01),
SPH_C32(0x04EE475F), SPH_C32(0x1FC5F22E)
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 106 of file cubehash.c.

Referenced by sph_cubehash384_init().

◆ IV512

const sph_u32 IV512[]
static
Initial value:
= {
SPH_C32(0x2AEA2A61), SPH_C32(0x50F494D4), SPH_C32(0x2D538B8B),
SPH_C32(0x4167D83E), SPH_C32(0x3FEE2313), SPH_C32(0xC701CF8C),
SPH_C32(0xCC39968E), SPH_C32(0x50AC5695), SPH_C32(0x4D42C787),
SPH_C32(0xA647A8B3), SPH_C32(0x97CF0BEF), SPH_C32(0x825B4537),
SPH_C32(0xEEF864D2), SPH_C32(0xF22090C4), SPH_C32(0xD0E5CD33),
SPH_C32(0xA23911AE), SPH_C32(0xFCD398D9), SPH_C32(0x148FE485),
SPH_C32(0x1B017BEF), SPH_C32(0xB6444532), SPH_C32(0x6A536159),
SPH_C32(0x2FF5781C), SPH_C32(0x91FA7934), SPH_C32(0x0DBADEA9),
SPH_C32(0xD65C8A2B), SPH_C32(0xA5A70E75), SPH_C32(0xB1C62456),
SPH_C32(0xBC796576), SPH_C32(0x1921C8F7), SPH_C32(0xE7989AF1),
SPH_C32(0x7795D246), SPH_C32(0xD43E3B44)
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 120 of file cubehash.c.

Referenced by sph_cubehash512_init().

Released under the MIT license