Pyrogenesis  trunk
Macros | Variables
sha.cpp File Reference
#include "precompiled.h"
#include "sha.h"
Include dependency graph for sha.cpp:

Macros

#define GET_uint32(n, b, i)
 FIPS-180-2 compliant SHA-256 implementation. More...
 
#define PUT_uint32(n, b, i)
 
#define SHR(x, n)   ((x & 0xFFFFFFFF) >> n)
 
#define ROTR(x, n)   (SHR(x,n) | (x << (32 - n)))
 
#define S0(x)   (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
 
#define S1(x)   (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
 
#define S2(x)   (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
 
#define S3(x)   (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
 
#define F0(x, y, z)   ((x & y) | (z & (x | y)))
 
#define F1(x, y, z)   (z ^ (x & (y ^ z)))
 
#define R(t)
 
#define P(a, b, c, d, e, f, g, h, x, K)
 

Variables

static unsigned char sha256_padding [64]
 

Macro Definition Documentation

#define F0 (   x,
  y,
 
)    ((x & y) | (z & (x | y)))
#define F1 (   x,
  y,
 
)    (z ^ (x & (y ^ z)))
#define GET_uint32 (   n,
  b,
 
)
Value:
{ \
(n) = ( (unsigned int) (b)[(i) ] << 24 ) \
| ( (unsigned int) (b)[(i) + 1] << 16 ) \
| ( (unsigned int) (b)[(i) + 2] << 8 ) \
| ( (unsigned int) (b)[(i) + 3] ); \
}

FIPS-180-2 compliant SHA-256 implementation.

Copyright (C) 2001-2003 Christophe Devine

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

#define P (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  x,
 
)
Value:
{ \
temp1 = h + S3(e) + F1(e,f,g) + K + x; \
temp2 = S2(a) + F0(a,b,c); \
d += temp1; h = temp1 + temp2; \
}
#define S3(x)
#define F1(x, y, z)
#define F0(x, y, z)
#define S2(x)
#define PUT_uint32 (   n,
  b,
 
)
Value:
{ \
(b)[(i) ] = (unsigned char) ( ((n) >> 24) & 0xFF ); \
(b)[(i) + 1] = (unsigned char) ( ((n) >> 16) & 0xFF ); \
(b)[(i) + 2] = (unsigned char) ( ((n) >> 8) & 0xFF ); \
(b)[(i) + 3] = (unsigned char) ( ((n) ) & 0xFF ); \
}
#define R (   t)
Value:
( \
W[t] = S1(W[t - 2]) + W[t - 7] + \
S0(W[t - 15]) + W[t - 16] \
)
Definition: Decompose.h:22
#define S1(x)
#define S0(x)
#define ROTR (   x,
 
)    (SHR(x,n) | (x << (32 - n)))
#define S0 (   x)    (ROTR(x, 7) ^ ROTR(x,18) ^ SHR(x, 3))
#define S1 (   x)    (ROTR(x,17) ^ ROTR(x,19) ^ SHR(x,10))
#define S2 (   x)    (ROTR(x, 2) ^ ROTR(x,13) ^ ROTR(x,22))
#define S3 (   x)    (ROTR(x, 6) ^ ROTR(x,11) ^ ROTR(x,25))
#define SHR (   x,
 
)    ((x & 0xFFFFFFFF) >> n)

Variable Documentation

unsigned char sha256_padding[64]
static
Initial value:
=
{
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}