Process Hacker
sha256.c File Reference
#include <string.h>
#include "sha256.h"

Go to the source code of this file.

Macros

#define GET_UINT32(n, b, i)
 
#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)
 

Functions

void sha256_starts (sha256_context *ctx)
 
void sha256_process (sha256_context *ctx, uint8 data[64])
 
void sha256_update (sha256_context *ctx, uint8 *input, uint32 length)
 
void sha256_finish (sha256_context *ctx, uint8 digest[32])
 

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) = ( (uint32) (b)[(i) ] << 24 ) \
| ( (uint32) (b)[(i) + 1] << 16 ) \
| ( (uint32) (b)[(i) + 2] << 8 ) \
| ( (uint32) (b)[(i) + 3] ); \
}

Definition at line 25 of file sha256.c.

#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 PUT_UINT32 (   n,
  b,
 
)
Value:
{ \
(b)[(i) ] = (uint8) ( (n) >> 24 ); \
(b)[(i) + 1] = (uint8) ( (n) >> 16 ); \
(b)[(i) + 2] = (uint8) ( (n) >> 8 ); \
(b)[(i) + 3] = (uint8) ( (n) ); \
}

Definition at line 33 of file sha256.c.

#define R (   t)
Value:
( \
W[t] = S1(W[t - 2]) + W[t - 7] + \
S0(W[t - 15]) + W[t - 16] \
)
#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)

Function Documentation

void sha256_finish ( sha256_context ctx,
uint8  digest[32] 
)

Definition at line 234 of file sha256.c.

void sha256_process ( sha256_context ctx,
uint8  data[64] 
)

Definition at line 56 of file sha256.c.

void sha256_starts ( sha256_context ctx)

Definition at line 41 of file sha256.c.

void sha256_update ( sha256_context ctx,
uint8 input,
uint32  length 
)

Definition at line 187 of file sha256.c.