Raven Core  3.0.0
P2P Digital Currency
Macros | Functions
sph_shabal.c File Reference
#include <stddef.h>
#include <string.h>
#include "sph_shabal.h"
Include dependency graph for sph_shabal.c:

Go to the source code of this file.

Macros

#define sM   16
 
#define C32   SPH_C32
 
#define T32   SPH_T32
 
#define O1   13
 
#define O2   9
 
#define O3   6
 
#define DECL_STATE
 
#define READ_STATE(state)
 
#define WRITE_STATE(state)
 
#define DECODE_BLOCK
 
#define INPUT_BLOCK_ADD
 
#define INPUT_BLOCK_SUB
 
#define XOR_W
 
#define SWAP(v1, v2)
 
#define SWAP_BC
 
#define PERM_ELT(xa0, xa1, xb0, xb1, xb2, xb3, xc, xm)
 
#define PERM_STEP_0
 
#define PERM_STEP_1
 
#define PERM_STEP_2
 
#define APPLY_P
 
#define INCR_W
 

Functions

void sph_shabal256_init (void *cc)
 Initialize a Shabal-256 context. More...
 
void sph_shabal256 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_shabal256_close (void *cc, void *dst)
 Terminate the current Shabal-256 computation and output the result into the provided buffer. More...
 
void sph_shabal256_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_shabal512_init (void *cc)
 Initialize a Shabal-512 context. More...
 
void sph_shabal512 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_shabal512_close (void *cc, void *dst)
 Terminate the current Shabal-512 computation and output the result into the provided buffer. More...
 
void sph_shabal512_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...
 

Macro Definition Documentation

◆ APPLY_P

#define APPLY_P

Definition at line 327 of file sph_shabal.c.

◆ C32

#define C32   SPH_C32

Definition at line 52 of file sph_shabal.c.

◆ DECL_STATE

#define DECL_STATE
Value:
sph_u32 A00, A01, A02, A03, A04, A05, A06, A07, \
A08, A09, A0A, A0B; \
sph_u32 B0, B1, B2, B3, B4, B5, B6, B7, \
B8, B9, BA, BB, BC, BD, BE, BF; \
sph_u32 C0, C1, C2, C3, C4, C5, C6, C7, \
C8, C9, CA, CB, CC, CD, CE, CF; \
sph_u32 M0, M1, M2, M3, M4, M5, M6, M7, \
M8, M9, MA, MB, MC, MD, ME, MF; \
sph_u32 Wlow, Whigh;
#define M2(d, s)
Definition: luffa.c:190
unsigned long sph_u32
Definition: sph_types.h:870

Definition at line 66 of file sph_shabal.c.

◆ DECODE_BLOCK

#define DECODE_BLOCK
Value:
do { \
M0 = sph_dec32le_aligned(buf + 0); \
M1 = sph_dec32le_aligned(buf + 4); \
M2 = sph_dec32le_aligned(buf + 8); \
M3 = sph_dec32le_aligned(buf + 12); \
M4 = sph_dec32le_aligned(buf + 16); \
M5 = sph_dec32le_aligned(buf + 20); \
M6 = sph_dec32le_aligned(buf + 24); \
M7 = sph_dec32le_aligned(buf + 28); \
M8 = sph_dec32le_aligned(buf + 32); \
M9 = sph_dec32le_aligned(buf + 36); \
MA = sph_dec32le_aligned(buf + 40); \
MB = sph_dec32le_aligned(buf + 44); \
MC = sph_dec32le_aligned(buf + 48); \
MD = sph_dec32le_aligned(buf + 52); \
ME = sph_dec32le_aligned(buf + 56); \
MF = sph_dec32le_aligned(buf + 60); \
} while (0)

Definition at line 175 of file sph_shabal.c.

◆ INCR_W

#define INCR_W
Value:
do { \
if ((Wlow = T32(Wlow + 1)) == 0) \
Whigh = T32(Whigh + 1); \
} while (0)
#define T32
Definition: sph_shabal.c:53

Definition at line 385 of file sph_shabal.c.

◆ INPUT_BLOCK_ADD

#define INPUT_BLOCK_ADD
Value:
do { \
B0 = T32(B0 + M0); \
B1 = T32(B1 + M1); \
B2 = T32(B2 + M2); \
B3 = T32(B3 + M3); \
B4 = T32(B4 + M4); \
B5 = T32(B5 + M5); \
B6 = T32(B6 + M6); \
B7 = T32(B7 + M7); \
B8 = T32(B8 + M8); \
B9 = T32(B9 + M9); \
BA = T32(BA + MA); \
BB = T32(BB + MB); \
BC = T32(BC + MC); \
BD = T32(BD + MD); \
BE = T32(BE + ME); \
BF = T32(BF + MF); \
} while (0)
#define M2(d, s)
Definition: luffa.c:190
#define T32
Definition: sph_shabal.c:53

Definition at line 194 of file sph_shabal.c.

◆ INPUT_BLOCK_SUB

#define INPUT_BLOCK_SUB
Value:
do { \
C0 = T32(C0 - M0); \
C1 = T32(C1 - M1); \
C2 = T32(C2 - M2); \
C3 = T32(C3 - M3); \
C4 = T32(C4 - M4); \
C5 = T32(C5 - M5); \
C6 = T32(C6 - M6); \
C7 = T32(C7 - M7); \
C8 = T32(C8 - M8); \
C9 = T32(C9 - M9); \
CA = T32(CA - MA); \
CB = T32(CB - MB); \
CC = T32(CC - MC); \
CD = T32(CD - MD); \
CE = T32(CE - ME); \
CF = T32(CF - MF); \
} while (0)
#define M2(d, s)
Definition: luffa.c:190
#define T32
Definition: sph_shabal.c:53

Definition at line 213 of file sph_shabal.c.

◆ O1

#define O1   13

Definition at line 55 of file sph_shabal.c.

◆ O2

#define O2   9

Definition at line 56 of file sph_shabal.c.

◆ O3

#define O3   6

Definition at line 57 of file sph_shabal.c.

◆ PERM_ELT

#define PERM_ELT (   xa0,
  xa1,
  xb0,
  xb1,
  xb2,
  xb3,
  xc,
  xm 
)
Value:
do { \
xa0 = T32((xa0 \
^ (((xa1 << 15) | (xa1 >> 17)) * 5U) \
^ xc) * 3U) \
^ xb1 ^ (xb2 & ~xb3) ^ xm; \
xb0 = T32(~(((xb0 << 1) | (xb0 >> 31)) ^ xa0)); \
} while (0)
#define T32
Definition: sph_shabal.c:53

Definition at line 262 of file sph_shabal.c.

◆ PERM_STEP_0

#define PERM_STEP_0
Value:
do { \
PERM_ELT(A00, A0B, B0, BD, B9, B6, C8, M0); \
PERM_ELT(A01, A00, B1, BE, BA, B7, C7, M1); \
PERM_ELT(A02, A01, B2, BF, BB, B8, C6, M2); \
PERM_ELT(A03, A02, B3, B0, BC, B9, C5, M3); \
PERM_ELT(A04, A03, B4, B1, BD, BA, C4, M4); \
PERM_ELT(A05, A04, B5, B2, BE, BB, C3, M5); \
PERM_ELT(A06, A05, B6, B3, BF, BC, C2, M6); \
PERM_ELT(A07, A06, B7, B4, B0, BD, C1, M7); \
PERM_ELT(A08, A07, B8, B5, B1, BE, C0, M8); \
PERM_ELT(A09, A08, B9, B6, B2, BF, CF, M9); \
PERM_ELT(A0A, A09, BA, B7, B3, B0, CE, MA); \
PERM_ELT(A0B, A0A, BB, B8, B4, B1, CD, MB); \
PERM_ELT(A00, A0B, BC, B9, B5, B2, CC, MC); \
PERM_ELT(A01, A00, BD, BA, B6, B3, CB, MD); \
PERM_ELT(A02, A01, BE, BB, B7, B4, CA, ME); \
PERM_ELT(A03, A02, BF, BC, B8, B5, C9, MF); \
} while (0)
#define M2(d, s)
Definition: luffa.c:190

Definition at line 270 of file sph_shabal.c.

◆ PERM_STEP_1

#define PERM_STEP_1
Value:
do { \
PERM_ELT(A04, A03, B0, BD, B9, B6, C8, M0); \
PERM_ELT(A05, A04, B1, BE, BA, B7, C7, M1); \
PERM_ELT(A06, A05, B2, BF, BB, B8, C6, M2); \
PERM_ELT(A07, A06, B3, B0, BC, B9, C5, M3); \
PERM_ELT(A08, A07, B4, B1, BD, BA, C4, M4); \
PERM_ELT(A09, A08, B5, B2, BE, BB, C3, M5); \
PERM_ELT(A0A, A09, B6, B3, BF, BC, C2, M6); \
PERM_ELT(A0B, A0A, B7, B4, B0, BD, C1, M7); \
PERM_ELT(A00, A0B, B8, B5, B1, BE, C0, M8); \
PERM_ELT(A01, A00, B9, B6, B2, BF, CF, M9); \
PERM_ELT(A02, A01, BA, B7, B3, B0, CE, MA); \
PERM_ELT(A03, A02, BB, B8, B4, B1, CD, MB); \
PERM_ELT(A04, A03, BC, B9, B5, B2, CC, MC); \
PERM_ELT(A05, A04, BD, BA, B6, B3, CB, MD); \
PERM_ELT(A06, A05, BE, BB, B7, B4, CA, ME); \
PERM_ELT(A07, A06, BF, BC, B8, B5, C9, MF); \
} while (0)
#define M2(d, s)
Definition: luffa.c:190

Definition at line 289 of file sph_shabal.c.

◆ PERM_STEP_2

#define PERM_STEP_2
Value:
do { \
PERM_ELT(A08, A07, B0, BD, B9, B6, C8, M0); \
PERM_ELT(A09, A08, B1, BE, BA, B7, C7, M1); \
PERM_ELT(A0A, A09, B2, BF, BB, B8, C6, M2); \
PERM_ELT(A0B, A0A, B3, B0, BC, B9, C5, M3); \
PERM_ELT(A00, A0B, B4, B1, BD, BA, C4, M4); \
PERM_ELT(A01, A00, B5, B2, BE, BB, C3, M5); \
PERM_ELT(A02, A01, B6, B3, BF, BC, C2, M6); \
PERM_ELT(A03, A02, B7, B4, B0, BD, C1, M7); \
PERM_ELT(A04, A03, B8, B5, B1, BE, C0, M8); \
PERM_ELT(A05, A04, B9, B6, B2, BF, CF, M9); \
PERM_ELT(A06, A05, BA, B7, B3, B0, CE, MA); \
PERM_ELT(A07, A06, BB, B8, B4, B1, CD, MB); \
PERM_ELT(A08, A07, BC, B9, B5, B2, CC, MC); \
PERM_ELT(A09, A08, BD, BA, B6, B3, CB, MD); \
PERM_ELT(A0A, A09, BE, BB, B7, B4, CA, ME); \
PERM_ELT(A0B, A0A, BF, BC, B8, B5, C9, MF); \
} while (0)
#define M2(d, s)
Definition: luffa.c:190

Definition at line 308 of file sph_shabal.c.

◆ READ_STATE

#define READ_STATE (   state)

Definition at line 77 of file sph_shabal.c.

◆ sM

#define sM   16

Definition at line 50 of file sph_shabal.c.

◆ SWAP

#define SWAP (   v1,
  v2 
)
Value:
do { \
sph_u32 tmp = (v1); \
(v1) = (v2); \
(v2) = tmp; \
} while (0)

Definition at line 237 of file sph_shabal.c.

◆ SWAP_BC

#define SWAP_BC
Value:
do { \
SWAP(B0, C0); \
SWAP(B1, C1); \
SWAP(B2, C2); \
SWAP(B3, C3); \
SWAP(B4, C4); \
SWAP(B5, C5); \
SWAP(B6, C6); \
SWAP(B7, C7); \
SWAP(B8, C8); \
SWAP(B9, C9); \
SWAP(BA, CA); \
SWAP(BB, CB); \
SWAP(BC, CC); \
SWAP(BD, CD); \
SWAP(BE, CE); \
SWAP(BF, CF); \
} while (0)

Definition at line 243 of file sph_shabal.c.

◆ T32

#define T32   SPH_T32

Definition at line 53 of file sph_shabal.c.

◆ WRITE_STATE

#define WRITE_STATE (   state)

Definition at line 126 of file sph_shabal.c.

◆ XOR_W

#define XOR_W
Value:
do { \
A00 ^= Wlow; \
A01 ^= Whigh; \
} while (0)

Definition at line 232 of file sph_shabal.c.

Function Documentation

◆ sph_shabal256()

void sph_shabal256 ( 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 Shabal-256 context
datathe input data
lenthe input data length (in bytes)

Definition at line 730 of file sph_shabal.c.

◆ sph_shabal256_addbits_and_close()

void sph_shabal256_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 Shabal-256 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 744 of file sph_shabal.c.

◆ sph_shabal256_close()

void sph_shabal256_close ( void *  cc,
void *  dst 
)

Terminate the current Shabal-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 Shabal-256 context
dstthe destination buffer

Definition at line 737 of file sph_shabal.c.

◆ sph_shabal256_init()

void sph_shabal256_init ( void *  cc)

Initialize a Shabal-256 context.

This process performs no memory allocation.

Parameters
ccthe Shabal-256 context (pointer to a sph_shabal256_context)

Definition at line 723 of file sph_shabal.c.

◆ sph_shabal512()

void sph_shabal512 ( 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 Shabal-512 context
datathe input data
lenthe input data length (in bytes)

Definition at line 788 of file sph_shabal.c.

Here is the caller graph for this function:

◆ sph_shabal512_addbits_and_close()

void sph_shabal512_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 Shabal-512 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 802 of file sph_shabal.c.

◆ sph_shabal512_close()

void sph_shabal512_close ( void *  cc,
void *  dst 
)

Terminate the current Shabal-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 Shabal-512 context
dstthe destination buffer

Definition at line 795 of file sph_shabal.c.

Here is the caller graph for this function:

◆ sph_shabal512_init()

void sph_shabal512_init ( void *  cc)

Initialize a Shabal-512 context.

This process performs no memory allocation.

Parameters
ccthe Shabal-512 context (pointer to a sph_shabal512_context)

Definition at line 781 of file sph_shabal.c.

Here is the caller graph for this function: