Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

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

Go to the source code of this file.

Macros

#define XCAT(x, y)   XCAT_(x, y)
 
#define XCAT_(x, y)   x ## y
 
#define LPAR   (
 
#define I16_16   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
 
#define I16_17   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
 
#define I16_18   2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17
 
#define I16_19   3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
 
#define I16_20   4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
 
#define I16_21   5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
 
#define I16_22   6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21
 
#define I16_23   7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
 
#define I16_24   8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23
 
#define I16_25   9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
 
#define I16_26   10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
 
#define I16_27   11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26
 
#define I16_28   12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27
 
#define I16_29   13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
 
#define I16_30   14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
 
#define I16_31   15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
 
#define M16_16   0, 1, 3, 4, 7, 10, 11
 
#define M16_17   1, 2, 4, 5, 8, 11, 12
 
#define M16_18   2, 3, 5, 6, 9, 12, 13
 
#define M16_19   3, 4, 6, 7, 10, 13, 14
 
#define M16_20   4, 5, 7, 8, 11, 14, 15
 
#define M16_21   5, 6, 8, 9, 12, 15, 16
 
#define M16_22   6, 7, 9, 10, 13, 0, 1
 
#define M16_23   7, 8, 10, 11, 14, 1, 2
 
#define M16_24   8, 9, 11, 12, 15, 2, 3
 
#define M16_25   9, 10, 12, 13, 0, 3, 4
 
#define M16_26   10, 11, 13, 14, 1, 4, 5
 
#define M16_27   11, 12, 14, 15, 2, 5, 6
 
#define M16_28   12, 13, 15, 16, 3, 6, 7
 
#define M16_29   13, 14, 0, 1, 4, 7, 8
 
#define M16_30   14, 15, 1, 2, 5, 8, 9
 
#define M16_31   15, 16, 2, 3, 6, 9, 10
 
#define ss0(x)
 
#define ss1(x)
 
#define ss2(x)
 
#define ss3(x)
 
#define ss4(x)   (((x) >> 1) ^ (x))
 
#define ss5(x)   (((x) >> 2) ^ (x))
 
#define rs1(x)   SPH_ROTL32(x, 3)
 
#define rs2(x)   SPH_ROTL32(x, 7)
 
#define rs3(x)   SPH_ROTL32(x, 13)
 
#define rs4(x)   SPH_ROTL32(x, 16)
 
#define rs5(x)   SPH_ROTL32(x, 19)
 
#define rs6(x)   SPH_ROTL32(x, 23)
 
#define rs7(x)   SPH_ROTL32(x, 27)
 
#define Ks(j)   SPH_T32((sph_u32)(j) * SPH_C32(0x05555555))
 
#define add_elt_s(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16)
 
#define expand1s_inner(qf, mf, hf, i16, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i0m, i1m, i3m, i4m, i7m, i10m, i11m)
 
#define expand1s(qf, mf, hf, i16)   expand1s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)
 
#define expand1s_(qf, mf, hf, i16, ix, iy)   expand1s_inner LPAR qf, mf, hf, i16, ix, iy)
 
#define expand2s_inner(qf, mf, hf, i16, i0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i0m, i1m, i3m, i4m, i7m, i10m, i11m)
 
#define expand2s(qf, mf, hf, i16)   expand2s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)
 
#define expand2s_(qf, mf, hf, i16, ix, iy)   expand2s_inner LPAR qf, mf, hf, i16, ix, iy)
 
#define MAKE_W(tt, i0, op01, i1, op12, i2, op23, i3, op34, i4)
 
#define Ws0   MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14)
 
#define Ws1   MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15)
 
#define Ws2   MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15)
 
#define Ws3   MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13)
 
#define Ws4   MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14)
 
#define Ws5   MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15)
 
#define Ws6   MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13)
 
#define Ws7   MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14)
 
#define Ws8   MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15)
 
#define Ws9   MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14)
 
#define Ws10   MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15)
 
#define Ws11   MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9)
 
#define Ws12   MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10)
 
#define Ws13   MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11)
 
#define Ws14   MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12)
 
#define Ws15   MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13)
 
#define MAKE_Qas
 
#define MAKE_Qbs
 
#define MAKE_Qs
 
#define Qs(j)   (qt[j])
 
#define FOLD(type, mkQ, tt, rol, mf, qf, dhf)
 
#define FOLDs   FOLD(sph_u32, MAKE_Qs, SPH_T32, SPH_ROTL32, M, Qs, dH)
 
#define M(x)   (mv[x])
 
#define H(x)   (h[x])
 
#define dH(x)   (dh[x])
 

Functions

static void compress_small (const unsigned char *data, const sph_u32 h[16], sph_u32 dh[16])
 
static void bmw32_init (sph_bmw_small_context *sc, const sph_u32 *iv)
 
static void bmw32 (sph_bmw_small_context *sc, const void *data, size_t len)
 
static void bmw32_close (sph_bmw_small_context *sc, unsigned ub, unsigned n, void *dst, size_t out_size_w32)
 
void sph_bmw224_init (void *cc)
 Initialize a BMW-224 context. More...
 
void sph_bmw224 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_bmw224_close (void *cc, void *dst)
 Terminate the current BMW-224 computation and output the result into the provided buffer. More...
 
void sph_bmw224_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_bmw256_init (void *cc)
 Initialize a BMW-256 context. More...
 
void sph_bmw256 (void *cc, const void *data, size_t len)
 Process some data bytes. More...
 
void sph_bmw256_close (void *cc, void *dst)
 Terminate the current BMW-256 computation and output the result into the provided buffer. More...
 
void sph_bmw256_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...
 

Variables

static const sph_u32 IV224 []
 
static const sph_u32 IV256 []
 
static const sph_u32 final_s [16]
 

Macro Definition Documentation

◆ add_elt_s

#define add_elt_s (   mf,
  hf,
  j0m,
  j1m,
  j3m,
  j4m,
  j7m,
  j10m,
  j11m,
  j16 
)
Value:
(SPH_T32(SPH_ROTL32(mf(j0m), j1m) + SPH_ROTL32(mf(j3m), j4m) \
- SPH_ROTL32(mf(j10m), j11m) + Ks(j16)) ^ hf(j7m))
#define Ks(j)
Definition: bmw.c:156
#define SPH_T32(x)
Definition: sph_types.h:932
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 158 of file bmw.c.

◆ dH

#define dH (   x)    (dh[x])

◆ expand1s

#define expand1s (   qf,
  mf,
  hf,
  i16 
)    expand1s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)

Definition at line 172 of file bmw.c.

◆ expand1s_

#define expand1s_ (   qf,
  mf,
  hf,
  i16,
  ix,
  iy 
)    expand1s_inner LPAR qf, mf, hf, i16, ix, iy)

Definition at line 174 of file bmw.c.

◆ expand1s_inner

#define expand1s_inner (   qf,
  mf,
  hf,
  i16,
  i0,
  i1,
  i2,
  i3,
  i4,
  i5,
  i6,
  i7,
  i8,
  i9,
  i10,
  i11,
  i12,
  i13,
  i14,
  i15,
  i0m,
  i1m,
  i3m,
  i4m,
  i7m,
  i10m,
  i11m 
)
Value:
SPH_T32(ss1(qf(i0)) + ss2(qf(i1)) + ss3(qf(i2)) + ss0(qf(i3)) \
+ ss1(qf(i4)) + ss2(qf(i5)) + ss3(qf(i6)) + ss0(qf(i7)) \
+ ss1(qf(i8)) + ss2(qf(i9)) + ss3(qf(i10)) + ss0(qf(i11)) \
+ ss1(qf(i12)) + ss2(qf(i13)) + ss3(qf(i14)) + ss0(qf(i15)) \
+ add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16))
#define add_elt_s(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16)
Definition: bmw.c:158
#define SPH_T32(x)
Definition: sph_types.h:932
#define ss3(x)
Definition: bmw.c:144
#define ss0(x)
Definition: bmw.c:138
#define ss1(x)
Definition: bmw.c:140
#define ss2(x)
Definition: bmw.c:142

Definition at line 162 of file bmw.c.

◆ expand2s

#define expand2s (   qf,
  mf,
  hf,
  i16 
)    expand2s_(qf, mf, hf, i16, I16_ ## i16, M16_ ## i16)

Definition at line 187 of file bmw.c.

◆ expand2s_

#define expand2s_ (   qf,
  mf,
  hf,
  i16,
  ix,
  iy 
)    expand2s_inner LPAR qf, mf, hf, i16, ix, iy)

Definition at line 189 of file bmw.c.

◆ expand2s_inner

#define expand2s_inner (   qf,
  mf,
  hf,
  i16,
  i0,
  i1,
  i2,
  i3,
  i4,
  i5,
  i6,
  i7,
  i8,
  i9,
  i10,
  i11,
  i12,
  i13,
  i14,
  i15,
  i0m,
  i1m,
  i3m,
  i4m,
  i7m,
  i10m,
  i11m 
)
Value:
SPH_T32(qf(i0) + rs1(qf(i1)) + qf(i2) + rs2(qf(i3)) \
+ qf(i4) + rs3(qf(i5)) + qf(i6) + rs4(qf(i7)) \
+ qf(i8) + rs5(qf(i9)) + qf(i10) + rs6(qf(i11)) \
+ qf(i12) + rs7(qf(i13)) + ss4(qf(i14)) + ss5(qf(i15)) \
+ add_elt_s(mf, hf, i0m, i1m, i3m, i4m, i7m, i10m, i11m, i16))
#define rs3(x)
Definition: bmw.c:150
#define add_elt_s(mf, hf, j0m, j1m, j3m, j4m, j7m, j10m, j11m, j16)
Definition: bmw.c:158
#define rs2(x)
Definition: bmw.c:149
#define rs5(x)
Definition: bmw.c:152
#define SPH_T32(x)
Definition: sph_types.h:932
#define rs1(x)
Definition: bmw.c:148
#define rs6(x)
Definition: bmw.c:153
#define ss4(x)
Definition: bmw.c:146
#define rs7(x)
Definition: bmw.c:154
#define ss5(x)
Definition: bmw.c:147
#define rs4(x)
Definition: bmw.c:151

Definition at line 177 of file bmw.c.

◆ FOLD

#define FOLD (   type,
  mkQ,
  tt,
  rol,
  mf,
  qf,
  dhf 
)

Definition at line 519 of file bmw.c.

◆ FOLDs

#define FOLDs   FOLD(sph_u32, MAKE_Qs, SPH_T32, SPH_ROTL32, M, Qs, dH)

Definition at line 560 of file bmw.c.

Referenced by compress_small().

◆ H

#define H (   x)    (h[x])

◆ I16_16

#define I16_16   0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

Definition at line 104 of file bmw.c.

◆ I16_17

#define I16_17   1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16

Definition at line 105 of file bmw.c.

◆ I16_18

#define I16_18   2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17

Definition at line 106 of file bmw.c.

◆ I16_19

#define I16_19   3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18

Definition at line 107 of file bmw.c.

◆ I16_20

#define I16_20   4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19

Definition at line 108 of file bmw.c.

◆ I16_21

#define I16_21   5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20

Definition at line 109 of file bmw.c.

◆ I16_22

#define I16_22   6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21

Definition at line 110 of file bmw.c.

◆ I16_23

#define I16_23   7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22

Definition at line 111 of file bmw.c.

◆ I16_24

#define I16_24   8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23

Definition at line 112 of file bmw.c.

◆ I16_25

#define I16_25   9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24

Definition at line 113 of file bmw.c.

◆ I16_26

#define I16_26   10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25

Definition at line 114 of file bmw.c.

◆ I16_27

#define I16_27   11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26

Definition at line 115 of file bmw.c.

◆ I16_28

#define I16_28   12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27

Definition at line 116 of file bmw.c.

◆ I16_29

#define I16_29   13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28

Definition at line 117 of file bmw.c.

◆ I16_30

#define I16_30   14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29

Definition at line 118 of file bmw.c.

◆ I16_31

#define I16_31   15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30

Definition at line 119 of file bmw.c.

◆ Ks

#define Ks (   j)    SPH_T32((sph_u32)(j) * SPH_C32(0x05555555))

Definition at line 156 of file bmw.c.

◆ LPAR

#define LPAR   (

Definition at line 102 of file bmw.c.

◆ M

#define M (   x)    (mv[x])

◆ M16_16

#define M16_16   0, 1, 3, 4, 7, 10, 11

Definition at line 121 of file bmw.c.

◆ M16_17

#define M16_17   1, 2, 4, 5, 8, 11, 12

Definition at line 122 of file bmw.c.

◆ M16_18

#define M16_18   2, 3, 5, 6, 9, 12, 13

Definition at line 123 of file bmw.c.

◆ M16_19

#define M16_19   3, 4, 6, 7, 10, 13, 14

Definition at line 124 of file bmw.c.

◆ M16_20

#define M16_20   4, 5, 7, 8, 11, 14, 15

Definition at line 125 of file bmw.c.

◆ M16_21

#define M16_21   5, 6, 8, 9, 12, 15, 16

Definition at line 126 of file bmw.c.

◆ M16_22

#define M16_22   6, 7, 9, 10, 13, 0, 1

Definition at line 127 of file bmw.c.

◆ M16_23

#define M16_23   7, 8, 10, 11, 14, 1, 2

Definition at line 128 of file bmw.c.

◆ M16_24

#define M16_24   8, 9, 11, 12, 15, 2, 3

Definition at line 129 of file bmw.c.

◆ M16_25

#define M16_25   9, 10, 12, 13, 0, 3, 4

Definition at line 130 of file bmw.c.

◆ M16_26

#define M16_26   10, 11, 13, 14, 1, 4, 5

Definition at line 131 of file bmw.c.

◆ M16_27

#define M16_27   11, 12, 14, 15, 2, 5, 6

Definition at line 132 of file bmw.c.

◆ M16_28

#define M16_28   12, 13, 15, 16, 3, 6, 7

Definition at line 133 of file bmw.c.

◆ M16_29

#define M16_29   13, 14, 0, 1, 4, 7, 8

Definition at line 134 of file bmw.c.

◆ M16_30

#define M16_30   14, 15, 1, 2, 5, 8, 9

Definition at line 135 of file bmw.c.

◆ M16_31

#define M16_31   15, 16, 2, 3, 6, 9, 10

Definition at line 136 of file bmw.c.

◆ MAKE_Qas

#define MAKE_Qas
Value:
do { \
qt[ 0] = SPH_T32(ss0(Ws0 ) + H( 1)); \
qt[ 1] = SPH_T32(ss1(Ws1 ) + H( 2)); \
qt[ 2] = SPH_T32(ss2(Ws2 ) + H( 3)); \
qt[ 3] = SPH_T32(ss3(Ws3 ) + H( 4)); \
qt[ 4] = SPH_T32(ss4(Ws4 ) + H( 5)); \
qt[ 5] = SPH_T32(ss0(Ws5 ) + H( 6)); \
qt[ 6] = SPH_T32(ss1(Ws6 ) + H( 7)); \
qt[ 7] = SPH_T32(ss2(Ws7 ) + H( 8)); \
qt[ 8] = SPH_T32(ss3(Ws8 ) + H( 9)); \
qt[ 9] = SPH_T32(ss4(Ws9 ) + H(10)); \
qt[10] = SPH_T32(ss0(Ws10) + H(11)); \
qt[11] = SPH_T32(ss1(Ws11) + H(12)); \
qt[12] = SPH_T32(ss2(Ws12) + H(13)); \
qt[13] = SPH_T32(ss3(Ws13) + H(14)); \
qt[14] = SPH_T32(ss4(Ws14) + H(15)); \
qt[15] = SPH_T32(ss0(Ws15) + H( 0)); \
} while (0)
#define Ws13
Definition: bmw.c:307
#define Ws9
Definition: bmw.c:303
#define Ws11
Definition: bmw.c:305
#define H(x)
#define Ws10
Definition: bmw.c:304
#define SPH_T32(x)
Definition: sph_types.h:932
#define Ws3
Definition: bmw.c:297
#define Ws6
Definition: bmw.c:300
#define Ws15
Definition: bmw.c:309
#define ss3(x)
Definition: bmw.c:144
#define Ws1
Definition: bmw.c:295
#define ss4(x)
Definition: bmw.c:146
#define ss0(x)
Definition: bmw.c:138
#define Ws2
Definition: bmw.c:296
#define Ws0
Definition: bmw.c:294
#define Ws8
Definition: bmw.c:302
#define ss1(x)
Definition: bmw.c:140
#define Ws14
Definition: bmw.c:308
#define ss2(x)
Definition: bmw.c:142
#define Ws7
Definition: bmw.c:301
#define Ws5
Definition: bmw.c:299
#define Ws12
Definition: bmw.c:306
#define Ws4
Definition: bmw.c:298

Definition at line 363 of file bmw.c.

◆ MAKE_Qbs

#define MAKE_Qbs
Value:
do { \
qt[16] = expand1s(Qs, M, H, 16); \
qt[17] = expand1s(Qs, M, H, 17); \
qt[18] = expand2s(Qs, M, H, 18); \
qt[19] = expand2s(Qs, M, H, 19); \
qt[20] = expand2s(Qs, M, H, 20); \
qt[21] = expand2s(Qs, M, H, 21); \
qt[22] = expand2s(Qs, M, H, 22); \
qt[23] = expand2s(Qs, M, H, 23); \
qt[24] = expand2s(Qs, M, H, 24); \
qt[25] = expand2s(Qs, M, H, 25); \
qt[26] = expand2s(Qs, M, H, 26); \
qt[27] = expand2s(Qs, M, H, 27); \
qt[28] = expand2s(Qs, M, H, 28); \
qt[29] = expand2s(Qs, M, H, 29); \
qt[30] = expand2s(Qs, M, H, 30); \
qt[31] = expand2s(Qs, M, H, 31); \
} while (0)
#define H(x)
#define Qs(j)
Definition: bmw.c:408
#define expand2s(qf, mf, hf, i16)
Definition: bmw.c:187
#define expand1s(qf, mf, hf, i16)
Definition: bmw.c:172
#define M(x)

Definition at line 382 of file bmw.c.

◆ MAKE_Qs

#define MAKE_Qs
Value:
do { \
MAKE_Qas; \
MAKE_Qbs; \
} while (0)

Definition at line 403 of file bmw.c.

◆ MAKE_W

#define MAKE_W (   tt,
  i0,
  op01,
  i1,
  op12,
  i2,
  op23,
  i3,
  op34,
  i4 
)
Value:
tt((M(i0) ^ H(i0)) op01 (M(i1) ^ H(i1)) op12 (M(i2) ^ H(i2)) \
op23 (M(i3) ^ H(i3)) op34 (M(i4) ^ H(i4)))
#define H(x)
#define M(x)

Definition at line 290 of file bmw.c.

◆ Qs

#define Qs (   j)    (qt[j])

Definition at line 408 of file bmw.c.

◆ rs1

#define rs1 (   x)    SPH_ROTL32(x, 3)

Definition at line 148 of file bmw.c.

◆ rs2

#define rs2 (   x)    SPH_ROTL32(x, 7)

Definition at line 149 of file bmw.c.

◆ rs3

#define rs3 (   x)    SPH_ROTL32(x, 13)

Definition at line 150 of file bmw.c.

◆ rs4

#define rs4 (   x)    SPH_ROTL32(x, 16)

Definition at line 151 of file bmw.c.

◆ rs5

#define rs5 (   x)    SPH_ROTL32(x, 19)

Definition at line 152 of file bmw.c.

◆ rs6

#define rs6 (   x)    SPH_ROTL32(x, 23)

Definition at line 153 of file bmw.c.

◆ rs7

#define rs7 (   x)    SPH_ROTL32(x, 27)

Definition at line 154 of file bmw.c.

◆ ss0

#define ss0 (   x)
Value:
(((x) >> 1) ^ SPH_T32((x) << 3) \
^ SPH_ROTL32(x, 4) ^ SPH_ROTL32(x, 19))
#define SPH_T32(x)
Definition: sph_types.h:932
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 138 of file bmw.c.

◆ ss1

#define ss1 (   x)
Value:
(((x) >> 1) ^ SPH_T32((x) << 2) \
^ SPH_ROTL32(x, 8) ^ SPH_ROTL32(x, 23))
#define SPH_T32(x)
Definition: sph_types.h:932
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 140 of file bmw.c.

◆ ss2

#define ss2 (   x)
Value:
(((x) >> 2) ^ SPH_T32((x) << 1) \
^ SPH_ROTL32(x, 12) ^ SPH_ROTL32(x, 25))
#define SPH_T32(x)
Definition: sph_types.h:932
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 142 of file bmw.c.

◆ ss3

#define ss3 (   x)
Value:
(((x) >> 2) ^ SPH_T32((x) << 2) \
^ SPH_ROTL32(x, 15) ^ SPH_ROTL32(x, 29))
#define SPH_T32(x)
Definition: sph_types.h:932
#define SPH_ROTL32(x, n)
Definition: sph_types.h:933

Definition at line 144 of file bmw.c.

◆ ss4

#define ss4 (   x)    (((x) >> 1) ^ (x))

Definition at line 146 of file bmw.c.

◆ ss5

#define ss5 (   x)    (((x) >> 2) ^ (x))

Definition at line 147 of file bmw.c.

◆ Ws0

#define Ws0   MAKE_W(SPH_T32, 5, -, 7, +, 10, +, 13, +, 14)

Definition at line 294 of file bmw.c.

◆ Ws1

#define Ws1   MAKE_W(SPH_T32, 6, -, 8, +, 11, +, 14, -, 15)

Definition at line 295 of file bmw.c.

◆ Ws10

#define Ws10   MAKE_W(SPH_T32, 8, -, 1, -, 4, -, 7, +, 15)

Definition at line 304 of file bmw.c.

◆ Ws11

#define Ws11   MAKE_W(SPH_T32, 8, -, 0, -, 2, -, 5, +, 9)

Definition at line 305 of file bmw.c.

◆ Ws12

#define Ws12   MAKE_W(SPH_T32, 1, +, 3, -, 6, -, 9, +, 10)

Definition at line 306 of file bmw.c.

◆ Ws13

#define Ws13   MAKE_W(SPH_T32, 2, +, 4, +, 7, +, 10, +, 11)

Definition at line 307 of file bmw.c.

◆ Ws14

#define Ws14   MAKE_W(SPH_T32, 3, -, 5, +, 8, -, 11, -, 12)

Definition at line 308 of file bmw.c.

◆ Ws15

#define Ws15   MAKE_W(SPH_T32, 12, -, 4, -, 6, -, 9, +, 13)

Definition at line 309 of file bmw.c.

◆ Ws2

#define Ws2   MAKE_W(SPH_T32, 0, +, 7, +, 9, -, 12, +, 15)

Definition at line 296 of file bmw.c.

◆ Ws3

#define Ws3   MAKE_W(SPH_T32, 0, -, 1, +, 8, -, 10, +, 13)

Definition at line 297 of file bmw.c.

◆ Ws4

#define Ws4   MAKE_W(SPH_T32, 1, +, 2, +, 9, -, 11, -, 14)

Definition at line 298 of file bmw.c.

◆ Ws5

#define Ws5   MAKE_W(SPH_T32, 3, -, 2, +, 10, -, 12, +, 15)

Definition at line 299 of file bmw.c.

◆ Ws6

#define Ws6   MAKE_W(SPH_T32, 4, -, 0, -, 3, -, 11, +, 13)

Definition at line 300 of file bmw.c.

◆ Ws7

#define Ws7   MAKE_W(SPH_T32, 1, -, 4, -, 5, -, 12, -, 14)

Definition at line 301 of file bmw.c.

◆ Ws8

#define Ws8   MAKE_W(SPH_T32, 2, -, 5, -, 6, +, 13, -, 15)

Definition at line 302 of file bmw.c.

◆ Ws9

#define Ws9   MAKE_W(SPH_T32, 0, -, 3, +, 6, -, 7, +, 14)

Definition at line 303 of file bmw.c.

◆ XCAT

#define XCAT (   x,
 
)    XCAT_(x, y)

Definition at line 99 of file bmw.c.

◆ XCAT_

#define XCAT_ (   x,
 
)    x ## y

Definition at line 100 of file bmw.c.

Function Documentation

◆ bmw32()

static void bmw32 ( sph_bmw_small_context sc,
const void *  data,
size_t  len 
)
static

◆ bmw32_close()

◆ bmw32_init()

static void bmw32_init ( sph_bmw_small_context sc,
const sph_u32 iv 
)
static

◆ compress_small()

static void compress_small ( const unsigned char *  data,
const sph_u32  h[16],
sph_u32  dh[16] 
)
static

Definition at line 569 of file bmw.c.

References FOLDs, and sph_dec32le_aligned().

Referenced by bmw32(), and bmw32_close().

◆ sph_bmw224()

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

Definition at line 852 of file bmw.c.

References bmw32().

◆ sph_bmw224_addbits_and_close()

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

Definition at line 866 of file bmw.c.

References bmw32_close(), and sph_bmw224_init().

Referenced by sph_bmw224_close().

◆ sph_bmw224_close()

void sph_bmw224_close ( void *  cc,
void *  dst 
)

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

Definition at line 859 of file bmw.c.

References sph_bmw224_addbits_and_close().

◆ sph_bmw224_init()

void sph_bmw224_init ( void *  cc)

Initialize a BMW-224 context.

This process performs no memory allocation.

Parameters
ccthe BMW-224 context (pointer to a sph_bmw224_context)

Definition at line 845 of file bmw.c.

References bmw32_init(), and IV224.

Referenced by sph_bmw224_addbits_and_close().

◆ sph_bmw256()

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

Definition at line 881 of file bmw.c.

References bmw32().

◆ sph_bmw256_addbits_and_close()

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

Definition at line 895 of file bmw.c.

References bmw32_close(), and sph_bmw256_init().

Referenced by sph_bmw256_close().

◆ sph_bmw256_close()

void sph_bmw256_close ( void *  cc,
void *  dst 
)

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

Definition at line 888 of file bmw.c.

References sph_bmw256_addbits_and_close().

◆ sph_bmw256_init()

void sph_bmw256_init ( void *  cc)

Initialize a BMW-256 context.

This process performs no memory allocation.

Parameters
ccthe BMW-256 context (pointer to a sph_bmw256_context)

Definition at line 874 of file bmw.c.

References bmw32_init(), and IV256.

Referenced by sph_bmw256_addbits_and_close().

Variable Documentation

◆ final_s

const sph_u32 final_s[16]
static
Initial value:
= {
SPH_C32(0xaaaaaaa0), SPH_C32(0xaaaaaaa1), SPH_C32(0xaaaaaaa2),
SPH_C32(0xaaaaaaa3), SPH_C32(0xaaaaaaa4), SPH_C32(0xaaaaaaa5),
SPH_C32(0xaaaaaaa6), SPH_C32(0xaaaaaaa7), SPH_C32(0xaaaaaaa8),
SPH_C32(0xaaaaaaa9), SPH_C32(0xaaaaaaaa), SPH_C32(0xaaaaaaab),
SPH_C32(0xaaaaaaac), SPH_C32(0xaaaaaaad), SPH_C32(0xaaaaaaae),
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 604 of file bmw.c.

Referenced by bmw32_close().

◆ IV224

const sph_u32 IV224[]
static
Initial value:
= {
SPH_C32(0x00010203), SPH_C32(0x04050607),
SPH_C32(0x08090A0B), SPH_C32(0x0C0D0E0F),
SPH_C32(0x10111213), SPH_C32(0x14151617),
SPH_C32(0x18191A1B), SPH_C32(0x1C1D1E1F),
SPH_C32(0x20212223), SPH_C32(0x24252627),
SPH_C32(0x28292A2B), SPH_C32(0x2C2D2E2F),
SPH_C32(0x30313233), SPH_C32(0x34353637),
SPH_C32(0x38393A3B), SPH_C32(0x3C3D3E3F)
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 51 of file bmw.c.

Referenced by sph_bmw224_init().

◆ IV256

const sph_u32 IV256[]
static
Initial value:
= {
SPH_C32(0x40414243), SPH_C32(0x44454647),
SPH_C32(0x48494A4B), SPH_C32(0x4C4D4E4F),
SPH_C32(0x50515253), SPH_C32(0x54555657),
SPH_C32(0x58595A5B), SPH_C32(0x5C5D5E5F),
SPH_C32(0x60616263), SPH_C32(0x64656667),
SPH_C32(0x68696A6B), SPH_C32(0x6C6D6E6F),
SPH_C32(0x70717273), SPH_C32(0x74757677),
SPH_C32(0x78797A7B), SPH_C32(0x7C7D7E7F)
}
#define SPH_C32(x)
Definition: sph_types.h:873

Definition at line 62 of file bmw.c.

Referenced by sph_bmw256_init().

Released under the MIT license