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

Go to the source code of this file.

Macros

#define C32e(x)   SPH_C32(x)
 
#define dec32e_aligned   sph_dec32be_aligned
 
#define enc32e   sph_enc32be
 
#define Sb(x0, x1, x2, x3, c)
 
#define Lb(x0, x1, x2, x3, x4, x5, x6, x7)
 
#define Ceven_w3(r)   (C[((r) << 3) + 0])
 
#define Ceven_w2(r)   (C[((r) << 3) + 1])
 
#define Ceven_w1(r)   (C[((r) << 3) + 2])
 
#define Ceven_w0(r)   (C[((r) << 3) + 3])
 
#define Codd_w3(r)   (C[((r) << 3) + 4])
 
#define Codd_w2(r)   (C[((r) << 3) + 5])
 
#define Codd_w1(r)   (C[((r) << 3) + 6])
 
#define Codd_w0(r)   (C[((r) << 3) + 7])
 
#define S(x0, x1, x2, x3, cb, r)
 
#define L(x0, x1, x2, x3, x4, x5, x6, x7)
 
#define Wz(x, c, n)
 
#define W0(x)   Wz(x, SPH_C32(0x55555555), 1)
 
#define W1(x)   Wz(x, SPH_C32(0x33333333), 2)
 
#define W2(x)   Wz(x, SPH_C32(0x0F0F0F0F), 4)
 
#define W3(x)   Wz(x, SPH_C32(0x00FF00FF), 8)
 
#define W4(x)   Wz(x, SPH_C32(0x0000FFFF), 16)
 
#define W5(x)
 
#define W6(x)
 
#define DECL_STATE
 
#define READ_STATE(state)
 
#define WRITE_STATE(state)
 
#define INPUT_BUF1
 
#define INPUT_BUF2
 
#define SL(ro)   SLu(r + ro, ro)
 
#define SLu(r, ro)
 
#define E8
 

Functions

void sph_jh224_init (void *cc)
 Initialize a JH-224 context. More...
 
void sph_jh224 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_jh224_close (void *cc, void *dst)
 Terminate the current JH-224 computation and output the result into the provided buffer. More...
 
void sph_jh224_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_jh256_init (void *cc)
 Initialize a JH-256 context. More...
 
void sph_jh256 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_jh256_close (void *cc, void *dst)
 Terminate the current JH-256 computation and output the result into the provided buffer. More...
 
void sph_jh256_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_jh384_init (void *cc)
 Initialize a JH-384 context. More...
 
void sph_jh384 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_jh384_close (void *cc, void *dst)
 Terminate the current JH-384 computation and output the result into the provided buffer. More...
 
void sph_jh384_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_jh512_init (void *cc)
 Initialize a JH-512 context. More...
 
void sph_jh512 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_jh512_close (void *cc, void *dst)
 Terminate the current JH-512 computation and output the result into the provided buffer. More...
 
void sph_jh512_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

◆ C32e

#define C32e (   x)    SPH_C32(x)

Definition at line 92 of file jh.c.

◆ Ceven_w0

#define Ceven_w0 (   r)    (C[((r) << 3) + 3])

Definition at line 488 of file jh.c.

◆ Ceven_w1

#define Ceven_w1 (   r)    (C[((r) << 3) + 2])

Definition at line 487 of file jh.c.

◆ Ceven_w2

#define Ceven_w2 (   r)    (C[((r) << 3) + 1])

Definition at line 486 of file jh.c.

◆ Ceven_w3

#define Ceven_w3 (   r)    (C[((r) << 3) + 0])

Definition at line 485 of file jh.c.

◆ Codd_w0

#define Codd_w0 (   r)    (C[((r) << 3) + 7])

Definition at line 492 of file jh.c.

◆ Codd_w1

#define Codd_w1 (   r)    (C[((r) << 3) + 6])

Definition at line 491 of file jh.c.

◆ Codd_w2

#define Codd_w2 (   r)    (C[((r) << 3) + 5])

Definition at line 490 of file jh.c.

◆ Codd_w3

#define Codd_w3 (   r)    (C[((r) << 3) + 4])

Definition at line 489 of file jh.c.

◆ dec32e_aligned

#define dec32e_aligned   sph_dec32be_aligned

Definition at line 93 of file jh.c.

◆ DECL_STATE

#define DECL_STATE
Value:
sph_u32 h03, h02, h01, h00, h13, h12, h11, h10; \
sph_u32 h23, h22, h21, h20, h33, h32, h31, h30; \
sph_u32 h43, h42, h41, h40, h53, h52, h51, h50; \
sph_u32 h63, h62, h61, h60, h73, h72, h71, h70; \
sph_u32 tmp;
unsigned long sph_u32
Definition: sph_types.h:870

Definition at line 545 of file jh.c.

◆ E8

#define E8
Value:
do { \
unsigned r; \
for (r = 0; r < 42; r += 7) { \
SL(0); \
SL(1); \
SL(2); \
SL(3); \
SL(4); \
SL(5); \
SL(6); \
} \
} while (0)

Definition at line 874 of file jh.c.

◆ enc32e

#define enc32e   sph_enc32be

Definition at line 94 of file jh.c.

◆ INPUT_BUF1

#define INPUT_BUF1

Definition at line 622 of file jh.c.

◆ INPUT_BUF2

#define INPUT_BUF2
Value:
h43 ^= m03; \
h42 ^= m02; \
h41 ^= m01; \
h40 ^= m00; \
h53 ^= m13; \
h52 ^= m12; \
h51 ^= m11; \
h50 ^= m10; \
h63 ^= m23; \
h62 ^= m22; \
h61 ^= m21; \
h60 ^= m20; \
h73 ^= m33; \
h72 ^= m32; \
h71 ^= m31; \
h70 ^= m30;

Definition at line 656 of file jh.c.

◆ L

#define L (   x0,
  x1,
  x2,
  x3,
  x4,
  x5,
  x6,
  x7 
)
Value:
do { \
Lb(x0 ## 3, x1 ## 3, x2 ## 3, x3 ## 3, \
x4 ## 3, x5 ## 3, x6 ## 3, x7 ## 3); \
Lb(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, \
x4 ## 2, x5 ## 2, x6 ## 2, x7 ## 2); \
Lb(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, \
x4 ## 1, x5 ## 1, x6 ## 1, x7 ## 1); \
Lb(x0 ## 0, x1 ## 0, x2 ## 0, x3 ## 0, \
x4 ## 0, x5 ## 0, x6 ## 0, x7 ## 0); \
} while (0)

Definition at line 501 of file jh.c.

◆ Lb

#define Lb (   x0,
  x1,
  x2,
  x3,
  x4,
  x5,
  x6,
  x7 
)
Value:
do { \
x4 ^= x1; \
x5 ^= x2; \
x6 ^= x3 ^ x0; \
x7 ^= x0; \
x0 ^= x5; \
x1 ^= x6; \
x2 ^= x7 ^ x4; \
x3 ^= x4; \
} while (0)

Definition at line 117 of file jh.c.

◆ READ_STATE

#define READ_STATE (   state)

Definition at line 552 of file jh.c.

◆ S

#define S (   x0,
  x1,
  x2,
  x3,
  cb,
 
)
Value:
do { \
Sb(x0 ## 3, x1 ## 3, x2 ## 3, x3 ## 3, cb ## w3(r)); \
Sb(x0 ## 2, x1 ## 2, x2 ## 2, x3 ## 2, cb ## w2(r)); \
Sb(x0 ## 1, x1 ## 1, x2 ## 1, x3 ## 1, cb ## w1(r)); \
Sb(x0 ## 0, x1 ## 0, x2 ## 0, x3 ## 0, cb ## w0(r)); \
} while (0)

Definition at line 494 of file jh.c.

◆ Sb

#define Sb (   x0,
  x1,
  x2,
  x3,
 
)
Value:
do { \
x3 = ~x3; \
x0 ^= (c) & ~x2; \
tmp = (c) ^ (x0 & x1); \
x0 ^= x2 & x3; \
x3 ^= ~x1 & x2; \
x1 ^= x0 & x2; \
x2 ^= x0 & ~x3; \
x0 ^= x1 | x3; \
x3 ^= x1 & x2; \
x1 ^= tmp & x0; \
x2 ^= tmp; \
} while (0)

Definition at line 103 of file jh.c.

◆ SL

#define SL (   ro)    SLu(r + ro, ro)

Definition at line 720 of file jh.c.

◆ SLu

#define SLu (   r,
  ro 
)
Value:
do { \
S(h0, h2, h4, h6, Ceven_, r); \
S(h1, h3, h5, h7, Codd_, r); \
L(h0, h2, h4, h6, h1, h3, h5, h7); \
W ## ro(h1); \
W ## ro(h3); \
W ## ro(h5); \
W ## ro(h7); \
} while (0)

Definition at line 722 of file jh.c.

◆ W0

#define W0 (   x)    Wz(x, SPH_C32(0x55555555), 1)

Definition at line 523 of file jh.c.

◆ W1

#define W1 (   x)    Wz(x, SPH_C32(0x33333333), 2)

Definition at line 524 of file jh.c.

◆ W2

#define W2 (   x)    Wz(x, SPH_C32(0x0F0F0F0F), 4)

Definition at line 525 of file jh.c.

◆ W3

#define W3 (   x)    Wz(x, SPH_C32(0x00FF00FF), 8)

Definition at line 526 of file jh.c.

◆ W4

#define W4 (   x)    Wz(x, SPH_C32(0x0000FFFF), 16)

Definition at line 527 of file jh.c.

◆ W5

#define W5 (   x)
Value:
do { \
sph_u32 t = x ## 3; \
x ## 3 = x ## 2; \
x ## 2 = t; \
t = x ## 1; \
x ## 1 = x ## 0; \
x ## 0 = t; \
} while (0)

Definition at line 528 of file jh.c.

◆ W6

#define W6 (   x)
Value:
do { \
sph_u32 t = x ## 3; \
x ## 3 = x ## 1; \
x ## 1 = t; \
t = x ## 2; \
x ## 2 = x ## 0; \
x ## 0 = t; \
} while (0)

Definition at line 536 of file jh.c.

◆ WRITE_STATE

#define WRITE_STATE (   state)

Definition at line 587 of file jh.c.

◆ Wz

#define Wz (   x,
  c,
 
)
Value:
do { \
sph_u32 t = (x ## 3 & (c)) << (n); \
x ## 3 = ((x ## 3 >> (n)) & (c)) | t; \
t = (x ## 2 & (c)) << (n); \
x ## 2 = ((x ## 2 >> (n)) & (c)) | t; \
t = (x ## 1 & (c)) << (n); \
x ## 1 = ((x ## 1 >> (n)) & (c)) | t; \
t = (x ## 0 & (c)) << (n); \
x ## 0 = ((x ## 0 >> (n)) & (c)) | t; \
} while (0)

Definition at line 512 of file jh.c.

Function Documentation

◆ sph_jh224()

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

Definition at line 1011 of file jh.c.

◆ sph_jh224_addbits_and_close()

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

Definition at line 1025 of file jh.c.

◆ sph_jh224_close()

void sph_jh224_close ( void *  cc,
void *  dst 
)

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

Definition at line 1018 of file jh.c.

◆ sph_jh224_init()

void sph_jh224_init ( void *  cc)

Initialize a JH-224 context.

This process performs no memory allocation.

Parameters
ccthe JH-224 context (pointer to a sph_jh224_context)

Definition at line 1004 of file jh.c.

◆ sph_jh256()

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

Definition at line 1039 of file jh.c.

◆ sph_jh256_addbits_and_close()

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

Definition at line 1053 of file jh.c.

◆ sph_jh256_close()

void sph_jh256_close ( void *  cc,
void *  dst 
)

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

Definition at line 1046 of file jh.c.

◆ sph_jh256_init()

void sph_jh256_init ( void *  cc)

Initialize a JH-256 context.

This process performs no memory allocation.

Parameters
ccthe JH-256 context (pointer to a sph_jh256_context)

Definition at line 1032 of file jh.c.

◆ sph_jh384()

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

Definition at line 1067 of file jh.c.

◆ sph_jh384_addbits_and_close()

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

Definition at line 1081 of file jh.c.

◆ sph_jh384_close()

void sph_jh384_close ( void *  cc,
void *  dst 
)

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

Definition at line 1074 of file jh.c.

◆ sph_jh384_init()

void sph_jh384_init ( void *  cc)

Initialize a JH-384 context.

This process performs no memory allocation.

Parameters
ccthe JH-384 context (pointer to a sph_jh384_context)

Definition at line 1060 of file jh.c.

◆ sph_jh512()

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

Definition at line 1095 of file jh.c.

Here is the caller graph for this function:

◆ sph_jh512_addbits_and_close()

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

Definition at line 1109 of file jh.c.

◆ sph_jh512_close()

void sph_jh512_close ( void *  cc,
void *  dst 
)

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

Definition at line 1102 of file jh.c.

Here is the caller graph for this function:

◆ sph_jh512_init()

void sph_jh512_init ( void *  cc)

Initialize a JH-512 context.

This process performs no memory allocation.

Parameters
ccthe JH-512 context (pointer to a sph_jh512_context)

Definition at line 1088 of file jh.c.

Here is the caller graph for this function: