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

Go to the source code of this file.

Macros

#define DECL_TMP8(w)   sph_u32 w ## 0, w ## 1, w ## 2, w ## 3, w ## 4, w ## 5, w ## 6, w ## 7;
 
#define M2(d, s)
 
#define XOR(d, s1, s2)
 
#define SUB_CRUMB(a0, a1, a2, a3)
 
#define MIX_WORD(u, v)
 
#define DECL_STATE3
 
#define READ_STATE3(state)
 
#define WRITE_STATE3(state)
 
#define MI3
 
#define TWEAK3
 
#define P3
 
#define DECL_STATE4
 
#define READ_STATE4(state)
 
#define WRITE_STATE4(state)
 
#define MI4
 
#define TWEAK4
 
#define P4
 
#define DECL_STATE5
 
#define READ_STATE5(state)
 
#define WRITE_STATE5(state)
 
#define MI5
 
#define TWEAK5
 
#define P5
 

Functions

void sph_luffa224_init (void *cc)
 Initialize a Luffa-224 context. More...
 
void sph_luffa224 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_luffa224_close (void *cc, void *dst)
 Terminate the current Luffa-224 computation and output the result into the provided buffer. More...
 
void sph_luffa224_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_luffa256_init (void *cc)
 Initialize a Luffa-256 context. More...
 
void sph_luffa256 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_luffa256_close (void *cc, void *dst)
 Terminate the current Luffa-256 computation and output the result into the provided buffer. More...
 
void sph_luffa256_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_luffa384_init (void *cc)
 Initialize a Luffa-384 context. More...
 
void sph_luffa384 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_luffa384_close (void *cc, void *dst)
 Terminate the current Luffa-384 computation and output the result into the provided buffer. More...
 
void sph_luffa384_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_luffa512_init (void *cc)
 Initialize a Luffa-512 context. More...
 
void sph_luffa512 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_luffa512_close (void *cc, void *dst)
 Terminate the current Luffa-512 computation and output the result into the provided buffer. More...
 
void sph_luffa512_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

◆ DECL_STATE3

#define DECL_STATE3
Value:
sph_u32 V00, V01, V02, V03, V04, V05, V06, V07; \
sph_u32 V10, V11, V12, V13, V14, V15, V16, V17; \
sph_u32 V20, V21, V22, V23, V24, V25, V26, V27;
unsigned long sph_u32
Definition: sph_types.h:870

Definition at line 310 of file luffa.c.

◆ DECL_STATE4

#define DECL_STATE4
Value:
sph_u32 V00, V01, V02, V03, V04, V05, V06, V07; \
sph_u32 V10, V11, V12, V13, V14, V15, V16, V17; \
sph_u32 V20, V21, V22, V23, V24, V25, V26, V27; \
sph_u32 V30, V31, V32, V33, V34, V35, V36, V37;
unsigned long sph_u32
Definition: sph_types.h:870

Definition at line 495 of file luffa.c.

◆ DECL_STATE5

#define DECL_STATE5
Value:
sph_u32 V00, V01, V02, V03, V04, V05, V06, V07; \
sph_u32 V10, V11, V12, V13, V14, V15, V16, V17; \
sph_u32 V20, V21, V22, V23, V24, V25, V26, V27; \
sph_u32 V30, V31, V32, V33, V34, V35, V36, V37; \
sph_u32 V40, V41, V42, V43, V44, V45, V46, V47;
unsigned long sph_u32
Definition: sph_types.h:870

Definition at line 748 of file luffa.c.

◆ DECL_TMP8

#define DECL_TMP8 (   w)    sph_u32 w ## 0, w ## 1, w ## 2, w ## 3, w ## 4, w ## 5, w ## 6, w ## 7;

Definition at line 187 of file luffa.c.

◆ M2

#define M2 (   d,
 
)
Value:
do { \
sph_u32 tmp = s ## 7; \
d ## 7 = s ## 6; \
d ## 6 = s ## 5; \
d ## 5 = s ## 4; \
d ## 4 = s ## 3 ^ tmp; \
d ## 3 = s ## 2 ^ tmp; \
d ## 2 = s ## 1; \
d ## 1 = s ## 0 ^ tmp; \
d ## 0 = tmp; \
} while (0)

Definition at line 190 of file luffa.c.

◆ MI3

#define MI3
Value:
do { \
DECL_TMP8(M) \
DECL_TMP8(a) \
M0 = sph_dec32be_aligned(buf + 0); \
M1 = sph_dec32be_aligned(buf + 4); \
M2 = sph_dec32be_aligned(buf + 8); \
M3 = sph_dec32be_aligned(buf + 12); \
M4 = sph_dec32be_aligned(buf + 16); \
M5 = sph_dec32be_aligned(buf + 20); \
M6 = sph_dec32be_aligned(buf + 24); \
M7 = sph_dec32be_aligned(buf + 28); \
XOR(a, V0, V1); \
XOR(a, a, V2); \
M2(a, a); \
XOR(V0, a, V0); \
XOR(V0, M, V0); \
M2(M, M); \
XOR(V1, a, V1); \
XOR(V1, M, V1); \
M2(M, M); \
XOR(V2, a, V2); \
XOR(V2, M, V2); \
} while (0)
#define M(x)

Definition at line 369 of file luffa.c.

◆ MI4

#define MI4

Definition at line 571 of file luffa.c.

◆ MI5

#define MI5

Definition at line 841 of file luffa.c.

◆ MIX_WORD

#define MIX_WORD (   u,
 
)
Value:
do { \
(v) ^= (u); \
(u) = SPH_ROTL32((u), 2) ^ (v); \
(v) = SPH_ROTL32((v), 14) ^ (u); \
(u) = SPH_ROTL32((u), 10) ^ (v); \
(v) = SPH_ROTL32((v), 1); \
} while (0)
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 302 of file luffa.c.

◆ P3

#define P3

Definition at line 458 of file luffa.c.

◆ P4

#define P4

Definition at line 701 of file luffa.c.

◆ P5

#define P5

Definition at line 1001 of file luffa.c.

◆ READ_STATE3

#define READ_STATE3 (   state)
Value:
do { \
V00 = (state)->V[0][0]; \
V01 = (state)->V[0][1]; \
V02 = (state)->V[0][2]; \
V03 = (state)->V[0][3]; \
V04 = (state)->V[0][4]; \
V05 = (state)->V[0][5]; \
V06 = (state)->V[0][6]; \
V07 = (state)->V[0][7]; \
V10 = (state)->V[1][0]; \
V11 = (state)->V[1][1]; \
V12 = (state)->V[1][2]; \
V13 = (state)->V[1][3]; \
V14 = (state)->V[1][4]; \
V15 = (state)->V[1][5]; \
V16 = (state)->V[1][6]; \
V17 = (state)->V[1][7]; \
V20 = (state)->V[2][0]; \
V21 = (state)->V[2][1]; \
V22 = (state)->V[2][2]; \
V23 = (state)->V[2][3]; \
V24 = (state)->V[2][4]; \
V25 = (state)->V[2][5]; \
V26 = (state)->V[2][6]; \
V27 = (state)->V[2][7]; \
} while (0)

Definition at line 315 of file luffa.c.

◆ READ_STATE4

#define READ_STATE4 (   state)

Definition at line 501 of file luffa.c.

◆ READ_STATE5

#define READ_STATE5 (   state)

Definition at line 755 of file luffa.c.

◆ SUB_CRUMB

#define SUB_CRUMB (   a0,
  a1,
  a2,
  a3 
)
Value:
do { \
sph_u32 tmp; \
tmp = (a0); \
(a0) |= (a1); \
(a2) ^= (a3); \
(a1) = SPH_T32(~(a1)); \
(a0) ^= (a3); \
(a3) &= tmp; \
(a1) ^= (a3); \
(a3) ^= (a2); \
(a2) &= (a0); \
(a0) = SPH_T32(~(a0)); \
(a2) ^= (a1); \
(a1) |= (a3); \
tmp ^= (a1); \
(a3) ^= (a2); \
(a2) &= (a1); \
(a1) ^= (a0); \
(a0) = tmp; \
} while (0)
#define SPH_T32(x)
Definition: sph_types.h:932

Definition at line 279 of file luffa.c.

◆ TWEAK3

#define TWEAK3
Value:
do { \
V14 = SPH_ROTL32(V14, 1); \
V15 = SPH_ROTL32(V15, 1); \
V16 = SPH_ROTL32(V16, 1); \
V17 = SPH_ROTL32(V17, 1); \
V24 = SPH_ROTL32(V24, 2); \
V25 = SPH_ROTL32(V25, 2); \
V26 = SPH_ROTL32(V26, 2); \
V27 = SPH_ROTL32(V27, 2); \
} while (0)
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 393 of file luffa.c.

◆ TWEAK4

#define TWEAK4
Value:
do { \
V14 = SPH_ROTL32(V14, 1); \
V15 = SPH_ROTL32(V15, 1); \
V16 = SPH_ROTL32(V16, 1); \
V17 = SPH_ROTL32(V17, 1); \
V24 = SPH_ROTL32(V24, 2); \
V25 = SPH_ROTL32(V25, 2); \
V26 = SPH_ROTL32(V26, 2); \
V27 = SPH_ROTL32(V27, 2); \
V34 = SPH_ROTL32(V34, 3); \
V35 = SPH_ROTL32(V35, 3); \
V36 = SPH_ROTL32(V36, 3); \
V37 = SPH_ROTL32(V37, 3); \
} while (0)
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 608 of file luffa.c.

◆ TWEAK5

#define TWEAK5
Value:
do { \
V14 = SPH_ROTL32(V14, 1); \
V15 = SPH_ROTL32(V15, 1); \
V16 = SPH_ROTL32(V16, 1); \
V17 = SPH_ROTL32(V17, 1); \
V24 = SPH_ROTL32(V24, 2); \
V25 = SPH_ROTL32(V25, 2); \
V26 = SPH_ROTL32(V26, 2); \
V27 = SPH_ROTL32(V27, 2); \
V34 = SPH_ROTL32(V34, 3); \
V35 = SPH_ROTL32(V35, 3); \
V36 = SPH_ROTL32(V36, 3); \
V37 = SPH_ROTL32(V37, 3); \
V44 = SPH_ROTL32(V44, 4); \
V45 = SPH_ROTL32(V45, 4); \
V46 = SPH_ROTL32(V46, 4); \
V47 = SPH_ROTL32(V47, 4); \
} while (0)
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 894 of file luffa.c.

◆ WRITE_STATE3

#define WRITE_STATE3 (   state)
Value:
do { \
(state)->V[0][0] = V00; \
(state)->V[0][1] = V01; \
(state)->V[0][2] = V02; \
(state)->V[0][3] = V03; \
(state)->V[0][4] = V04; \
(state)->V[0][5] = V05; \
(state)->V[0][6] = V06; \
(state)->V[0][7] = V07; \
(state)->V[1][0] = V10; \
(state)->V[1][1] = V11; \
(state)->V[1][2] = V12; \
(state)->V[1][3] = V13; \
(state)->V[1][4] = V14; \
(state)->V[1][5] = V15; \
(state)->V[1][6] = V16; \
(state)->V[1][7] = V17; \
(state)->V[2][0] = V20; \
(state)->V[2][1] = V21; \
(state)->V[2][2] = V22; \
(state)->V[2][3] = V23; \
(state)->V[2][4] = V24; \
(state)->V[2][5] = V25; \
(state)->V[2][6] = V26; \
(state)->V[2][7] = V27; \
} while (0)

Definition at line 342 of file luffa.c.

◆ WRITE_STATE4

#define WRITE_STATE4 (   state)

Definition at line 536 of file luffa.c.

◆ WRITE_STATE5

#define WRITE_STATE5 (   state)

Definition at line 798 of file luffa.c.

◆ XOR

#define XOR (   d,
  s1,
  s2 
)
Value:
do { \
d ## 0 = s1 ## 0 ^ s2 ## 0; \
d ## 1 = s1 ## 1 ^ s2 ## 1; \
d ## 2 = s1 ## 2 ^ s2 ## 2; \
d ## 3 = s1 ## 3 ^ s2 ## 3; \
d ## 4 = s1 ## 4 ^ s2 ## 4; \
d ## 5 = s1 ## 5 ^ s2 ## 5; \
d ## 6 = s1 ## 6 ^ s2 ## 6; \
d ## 7 = s1 ## 7 ^ s2 ## 7; \
} while (0)
#define s2
Definition: sph_hamsi.c:214
#define s1(x)
Definition: sha2.c:57

Definition at line 202 of file luffa.c.

Function Documentation

◆ sph_luffa224()

void sph_luffa224 ( 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 Luffa-224 context
datathe input data
lenthe input data length (in bytes)

Definition at line 1305 of file luffa.c.

◆ sph_luffa224_addbits_and_close()

void sph_luffa224_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 Luffa-224 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 1319 of file luffa.c.

Here is the caller graph for this function:

◆ sph_luffa224_close()

void sph_luffa224_close ( void *  cc,
void *  dst 
)

Terminate the current Luffa-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 Luffa-224 context
dstthe destination buffer

Definition at line 1312 of file luffa.c.

Here is the call graph for this function:

◆ sph_luffa224_init()

void sph_luffa224_init ( void *  cc)

Initialize a Luffa-224 context.

This process performs no memory allocation.

Parameters
ccthe Luffa-224 context (pointer to a sph_luffa224_context)

Definition at line 1294 of file luffa.c.

Here is the call graph for this function:

◆ sph_luffa256()

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

Definition at line 1338 of file luffa.c.

◆ sph_luffa256_addbits_and_close()

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

Definition at line 1352 of file luffa.c.

Here is the caller graph for this function:

◆ sph_luffa256_close()

void sph_luffa256_close ( void *  cc,
void *  dst 
)

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

Definition at line 1345 of file luffa.c.

Here is the call graph for this function:

◆ sph_luffa256_init()

void sph_luffa256_init ( void *  cc)

Initialize a Luffa-256 context.

This process performs no memory allocation.

Parameters
ccthe Luffa-256 context (pointer to a sph_luffa256_context)

Definition at line 1327 of file luffa.c.

Here is the call graph for this function:

◆ sph_luffa384()

void sph_luffa384 ( 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 Luffa-384 context
datathe input data
lenthe input data length (in bytes)

Definition at line 1371 of file luffa.c.

◆ sph_luffa384_addbits_and_close()

void sph_luffa384_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 Luffa-384 context
ubthe extra bits
nthe number of extra bits (0 to 7)
dstthe destination buffer

Definition at line 1385 of file luffa.c.

Here is the caller graph for this function:

◆ sph_luffa384_close()

void sph_luffa384_close ( void *  cc,
void *  dst 
)

Terminate the current Luffa-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 Luffa-384 context
dstthe destination buffer

Definition at line 1378 of file luffa.c.

Here is the call graph for this function:

◆ sph_luffa384_init()

void sph_luffa384_init ( void *  cc)

Initialize a Luffa-384 context.

This process performs no memory allocation.

Parameters
ccthe Luffa-384 context (pointer to a sph_luffa384_context)

Definition at line 1360 of file luffa.c.

Here is the call graph for this function:

◆ sph_luffa512()

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

Definition at line 1404 of file luffa.c.

Here is the caller graph for this function:

◆ sph_luffa512_addbits_and_close()

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

Definition at line 1418 of file luffa.c.

Here is the caller graph for this function:

◆ sph_luffa512_close()

void sph_luffa512_close ( void *  cc,
void *  dst 
)

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

Definition at line 1411 of file luffa.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sph_luffa512_init()

void sph_luffa512_init ( void *  cc)

Initialize a Luffa-512 context.

This process performs no memory allocation.

Parameters
ccthe Luffa-512 context (pointer to a sph_luffa512_context)

Definition at line 1393 of file luffa.c.

Here is the call graph for this function:
Here is the caller graph for this function: