Sirikata
Namespaces | Defines
libcore/src/util/internal_sha2.cpp File Reference
#include <sirikata/core/util/Standard.hh>
#include <string.h>
#include <assert.h>
#include "internal_sha2.hpp"
Include dependency graph for internal_sha2.cpp:

Namespaces

namespace  Sirikata
 

Note: All the classes provided in this file are thin wrappers around the corresponding classes in ASIO.


Defines

#define SHA2_UNROLL_TRANSFORM
#define SHA256_SHORT_BLOCK_LENGTH   (SHA256_BLOCK_LENGTH - 8)
#define SHA384_SHORT_BLOCK_LENGTH   (SHA384_BLOCK_LENGTH - 16)
#define SHA512_SHORT_BLOCK_LENGTH   (SHA512_BLOCK_LENGTH - 16)
#define REVERSE32(w, x)
#define REVERSE64(w, x)
#define ADDINC128(w, n)
#define SHA2_USE_MEMSET_MEMCPY   1
#define MEMSET_BZERO(p, l)   memset((p), 0, (l))
#define MEMCPY_BCOPY(d, s, l)   memcpy((d), (s), (l))
#define R(b, x)   ((x) >> (b))
#define S32(b, x)   (((x) >> (b)) | ((x) << (32 - (b))))
#define S64(b, x)   (((x) >> (b)) | ((x) << (64 - (b))))
#define Ch(x, y, z)   (((x) & (y)) ^ ((~(x)) & (z)))
#define Maj(x, y, z)   (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define Sigma0_256(x)   (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x)))
#define Sigma1_256(x)   (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x)))
#define sigma0_256(x)   (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x)))
#define sigma1_256(x)   (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x)))
#define Sigma0_512(x)   (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x)))
#define Sigma1_512(x)   (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x)))
#define sigma0_512(x)   (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x)))
#define sigma1_512(x)   (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x)))
#define ROUND256_0_TO_15(a, b, c, d, e, f, g, h)
#define ROUND256(a, b, c, d, e, f, g, h)
#define ROUND512_0_TO_15(a, b, c, d, e, f, g, h)
#define ROUND512(a, b, c, d, e, f, g, h)

Define Documentation

#define ADDINC128 (   w,
 
)
Value:
{ \
    (w)[0] += (sha2_word64)(n); \
    if ((w)[0] < (n)) { \
        (w)[1]++; \
    } \
}
#define Ch (   x,
  y,
 
)    (((x) & (y)) ^ ((~(x)) & (z)))
#define Maj (   x,
  y,
 
)    (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
#define MEMCPY_BCOPY (   d,
  s,
 
)    memcpy((d), (s), (l))
#define MEMSET_BZERO (   p,
 
)    memset((p), 0, (l))
#define R (   b,
 
)    ((x) >> (b))
#define REVERSE32 (   w,
 
)
Value:
{ \
    sha2_word32 tmp = (w); \
    tmp = (tmp >> 16) | (tmp << 16); \
    (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \
}
#define REVERSE64 (   w,
 
)
Value:
{ \
    sha2_word64 tmp = (w); \
    tmp = (tmp >> 32) | (tmp << 32); \
    tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \
          ((tmp & 0x00ff00ff00ff00ffULL) << 8); \
    (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
          ((tmp & 0x0000ffff0000ffffULL) << 16); \
}
#define ROUND256 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
s0 = W256[(j+1)&0x0f]; \
    s0 = sigma0_256(s0); \
    s1 = W256[(j+14)&0x0f]; \
    s1 = sigma1_256(s1); \
    T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
         (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \
    (d) += T1; \
    (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
    j++
#define ROUND256_0_TO_15 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
REVERSE32(*data++, W256[j]); \
    T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
             K256[j] + W256[j]; \
    (d) += T1; \
    (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
    j++
#define ROUND512 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
s0 = W512[(j+1)&0x0f]; \
    s0 = sigma0_512(s0); \
    s1 = W512[(j+14)&0x0f]; \
    s1 = sigma1_512(s1); \
    T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
             (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \
    (d) += T1; \
    (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
    j++
#define ROUND512_0_TO_15 (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
REVERSE64(*data++, W512[j]); \
    T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
             K512[j] + W512[j]; \
    (d) += T1, \
    (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \
    j++
#define S32 (   b,
 
)    (((x) >> (b)) | ((x) << (32 - (b))))
#define S64 (   b,
 
)    (((x) >> (b)) | ((x) << (64 - (b))))
#define SHA256_SHORT_BLOCK_LENGTH   (SHA256_BLOCK_LENGTH - 8)
#define SHA2_UNROLL_TRANSFORM
#define SHA2_USE_MEMSET_MEMCPY   1
#define SHA384_SHORT_BLOCK_LENGTH   (SHA384_BLOCK_LENGTH - 16)
#define SHA512_SHORT_BLOCK_LENGTH   (SHA512_BLOCK_LENGTH - 16)
#define Sigma0_256 (   x)    (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x)))
#define sigma0_256 (   x)    (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x)))
#define Sigma0_512 (   x)    (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x)))
#define sigma0_512 (   x)    (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x)))
#define Sigma1_256 (   x)    (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x)))
#define sigma1_256 (   x)    (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x)))
#define sigma1_512 (   x)    (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x)))
#define Sigma1_512 (   x)    (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x)))