OpenSSL  1.0.1c
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Macros | Functions | Variables
sha256.c File Reference
#include <openssl/opensslconf.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/crypto.h>
#include <openssl/sha.h>
#include <openssl/opensslv.h>
#include "md32_common.h"

Go to the source code of this file.

Macros

#define DATA_ORDER_IS_BIG_ENDIAN
 
#define HASH_LONG   SHA_LONG
 
#define HASH_CTX   SHA256_CTX
 
#define HASH_CBLOCK   SHA_CBLOCK
 
#define HASH_MAKE_STRING(c, s)
 
#define HASH_UPDATE   SHA256_Update
 
#define HASH_TRANSFORM   SHA256_Transform
 
#define HASH_FINAL   SHA256_Final
 
#define HASH_BLOCK_DATA_ORDER   sha256_block_data_order
 
#define Sigma0(x)   (ROTATE((x),30) ^ ROTATE((x),19) ^ ROTATE((x),10))
 
#define Sigma1(x)   (ROTATE((x),26) ^ ROTATE((x),21) ^ ROTATE((x),7))
 
#define sigma0(x)   (ROTATE((x),25) ^ ROTATE((x),14) ^ ((x)>>3))
 
#define sigma1(x)   (ROTATE((x),15) ^ ROTATE((x),13) ^ ((x)>>10))
 
#define Ch(x, y, z)   (((x) & (y)) ^ ((~(x)) & (z)))
 
#define Maj(x, y, z)   (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
 
#define ROUND_00_15(i, a, b, c, d, e, f, g, h)
 
#define ROUND_16_63(i, a, b, c, d, e, f, g, h, X)
 

Functions

 fips_md_init_ctx (SHA224, SHA256)
 
 fips_md_init (SHA256)
 
unsigned char * SHA224 (const unsigned char *d, size_t n, unsigned char *md)
 
unsigned char * SHA256 (const unsigned char *d, size_t n, unsigned char *md)
 
int SHA224_Update (SHA256_CTX *c, const void *data, size_t len)
 
int SHA224_Final (unsigned char *md, SHA256_CTX *c)
 

Variables

const char SHA256_version [] ="SHA-256" OPENSSL_VERSION_PTEXT
 

Macro Definition Documentation

#define Ch (   x,
  y,
 
)    (((x) & (y)) ^ ((~(x)) & (z)))

Definition at line 146 of file sha256.c.

#define DATA_ORDER_IS_BIG_ENDIAN

Definition at line 72 of file sha256.c.

#define HASH_BLOCK_DATA_ORDER   sha256_block_data_order

Definition at line 109 of file sha256.c.

#define HASH_CBLOCK   SHA_CBLOCK

Definition at line 76 of file sha256.c.

#define HASH_CTX   SHA256_CTX

Definition at line 75 of file sha256.c.

#define HASH_FINAL   SHA256_Final

Definition at line 108 of file sha256.c.

#define HASH_LONG   SHA_LONG

Definition at line 74 of file sha256.c.

#define HASH_MAKE_STRING (   c,
 
)
Value:
do { \
unsigned long ll; \
unsigned int nn; \
switch ((c)->md_len) \
for (nn=0;nn<SHA224_DIGEST_LENGTH/4;nn++) \
{ ll=(c)->h[nn]; HOST_l2c(ll,(s)); } \
break; \
for (nn=0;nn<SHA256_DIGEST_LENGTH/4;nn++) \
{ ll=(c)->h[nn]; HOST_l2c(ll,(s)); } \
break; \
default: \
if ((c)->md_len > SHA256_DIGEST_LENGTH) \
return 0; \
for (nn=0;nn<(c)->md_len/4;nn++) \
{ ll=(c)->h[nn]; HOST_l2c(ll,(s)); } \
break; \
} \
} while (0)

Definition at line 85 of file sha256.c.

#define HASH_TRANSFORM   SHA256_Transform

Definition at line 107 of file sha256.c.

#define HASH_UPDATE   SHA256_Update

Definition at line 106 of file sha256.c.

#define Maj (   x,
  y,
 
)    (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))

Definition at line 147 of file sha256.c.

#define ROUND_00_15 (   i,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h 
)
Value:
do { \
T1 += h + Sigma1(e) + Ch(e,f,g) + K256[i]; \
h = Sigma0(a) + Maj(a,b,c); \
d += T1; h += T1; } while (0)

Definition at line 192 of file sha256.c.

#define ROUND_16_63 (   i,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  X 
)
Value:
do { \
s0 = X[(i+1)&0x0f]; s0 = sigma0(s0); \
s1 = X[(i+14)&0x0f]; s1 = sigma1(s1); \
T1 = X[(i)&0x0f] += s0 + s1 + X[(i+9)&0x0f]; \
ROUND_00_15(i,a,b,c,d,e,f,g,h); } while (0)

Definition at line 197 of file sha256.c.

#define Sigma0 (   x)    (ROTATE((x),30) ^ ROTATE((x),19) ^ ROTATE((x),10))

Definition at line 141 of file sha256.c.

#define sigma0 (   x)    (ROTATE((x),25) ^ ROTATE((x),14) ^ ((x)>>3))

Definition at line 143 of file sha256.c.

#define Sigma1 (   x)    (ROTATE((x),26) ^ ROTATE((x),21) ^ ROTATE((x),7))

Definition at line 142 of file sha256.c.

#define sigma1 (   x)    (ROTATE((x),15) ^ ROTATE((x),13) ^ ((x)>>10))

Definition at line 144 of file sha256.c.

Function Documentation

fips_md_init ( SHA256  )

Definition at line 30 of file sha256.c.

fips_md_init_ctx ( SHA224  ,
SHA256   
)

Definition at line 19 of file sha256.c.

unsigned char* SHA224 ( const unsigned char *  d,
size_t  n,
unsigned char *  md 
)

Definition at line 41 of file sha256.c.

int SHA224_Final ( unsigned char *  md,
SHA256_CTX c 
)

Definition at line 69 of file sha256.c.

int SHA224_Update ( SHA256_CTX c,
const void data,
size_t  len 
)

Definition at line 67 of file sha256.c.

unsigned char* SHA256 ( const unsigned char *  d,
size_t  n,
unsigned char *  md 
)

Definition at line 54 of file sha256.c.

Variable Documentation

const char SHA256_version[] ="SHA-256" OPENSSL_VERSION_PTEXT

Definition at line 17 of file sha256.c.