Minetest  5.4.0
sha256.c File Reference
#include <stdlib.h>
#include <string.h>
#include <util/sha2.h>
#include "md32_common.h"
+ Include dependency graph for sha256.c:

Macros

#define OPENSSL_VERSION_TEXT   "OpenSSL 1.0.2a 19 Mar 2015"
 
#define OPENSSL_VERSION_PTEXT   " part of " OPENSSL_VERSION_TEXT
 
#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

static void OPENSSL_cleanse (void *ptr, size_t len)
 
 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)
 
static void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num)
 

Variables

const char SHA256_version [] = "SHA-256" OPENSSL_VERSION_PTEXT
 
static unsigned char cleanse_ctr = 0
 
static const SHA_LONG K256 [64]
 

Macro Definition Documentation

◆ Ch

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

◆ DATA_ORDER_IS_BIG_ENDIAN

#define DATA_ORDER_IS_BIG_ENDIAN

◆ HASH_BLOCK_DATA_ORDER

#define HASH_BLOCK_DATA_ORDER   sha256_block_data_order

◆ HASH_CBLOCK

#define HASH_CBLOCK   SHA_CBLOCK

◆ HASH_CTX

#define HASH_CTX   SHA256_CTX

◆ HASH_FINAL

#define HASH_FINAL   SHA256_Final

◆ HASH_LONG

#define HASH_LONG   SHA_LONG

◆ HASH_MAKE_STRING

#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]; (void)HOST_l2c(ll,(s)); } \
break; \
for (nn=0;nn<SHA256_DIGEST_LENGTH/4;nn++) \
{ ll=(c)->h[nn]; (void)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]; (void)HOST_l2c(ll,(s)); } \
break; \
} \
} while (0)
#define SHA256_DIGEST_LENGTH
Definition: sha2.h:119
#define SHA224_DIGEST_LENGTH
Definition: sha2.h:118

◆ HASH_TRANSFORM

#define HASH_TRANSFORM   SHA256_Transform

◆ HASH_UPDATE

#define HASH_UPDATE   SHA256_Update

◆ Maj

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

◆ OPENSSL_VERSION_PTEXT

#define OPENSSL_VERSION_PTEXT   " part of " OPENSSL_VERSION_TEXT

◆ OPENSSL_VERSION_TEXT

#define OPENSSL_VERSION_TEXT   "OpenSSL 1.0.2a 19 Mar 2015"

◆ ROUND_00_15

#define ROUND_00_15 (   i,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
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)
#define Maj(x, y, z)
Definition: sha256.c:177
#define Sigma0(x)
Definition: sha256.c:171
#define Sigma1(x)
Definition: sha256.c:172
#define Ch(x, y, z)
Definition: sha256.c:176
static const SHA_LONG K256[64]
Definition: sha256.c:147

◆ ROUND_16_63

#define ROUND_16_63 (   i,
  a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
 
)
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)
#define sigma1(x)
Definition: sha256.c:174
#define sigma0(x)
Definition: sha256.c:173

◆ Sigma0

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

◆ sigma0

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

◆ Sigma1

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

◆ sigma1

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

Function Documentation

◆ fips_md_init()

fips_md_init ( SHA256  )

References SHA256_DIGEST_LENGTH.

◆ fips_md_init_ctx()

fips_md_init_ctx ( SHA224  ,
SHA256   
)

References SHA224_DIGEST_LENGTH.

◆ OPENSSL_cleanse()

static void OPENSSL_cleanse ( void *  ptr,
size_t  len 
)
static

References cleanse_ctr, and p().

Referenced by SHA224(), and SHA256().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SHA224()

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

References OPENSSL_cleanse(), SHA224_DIGEST_LENGTH, SHA224_Init(), SHA256_Final(), and SHA256_Update().

+ Here is the call graph for this function:

◆ SHA224_Final()

int SHA224_Final ( unsigned char *  md,
SHA256_CTX c 
)

References SHA256_Final().

+ Here is the call graph for this function:

◆ SHA224_Update()

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

References SHA256_Update().

+ Here is the call graph for this function:

◆ SHA256()

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

References OPENSSL_cleanse(), SHA256_DIGEST_LENGTH, SHA256_Final(), SHA256_Init(), and SHA256_Update().

Referenced by hash().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sha256_block_data_order()

static void sha256_block_data_order ( SHA256_CTX ctx,
const void *  in,
size_t  num 
)
static

Variable Documentation

◆ cleanse_ctr

unsigned char cleanse_ctr = 0
static

Referenced by OPENSSL_cleanse().

◆ K256

const SHA_LONG K256[64]
static
Initial value:
= {
0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL,
0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL,
0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL,
0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL,
0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL,
0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL,
0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL,
0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL,
0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL,
0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL,
0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL,
0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL,
0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL,
0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL
}

◆ SHA256_version

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