wpa_supplicant / hostapd  2.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions
sha256-internal.c File Reference

SHA-256 hash implementation and interface functions. More...

#include "includes.h"
#include "common.h"
#include "sha256.h"
#include "sha256_i.h"
#include "crypto.h"

Macros

#define RORc(x, y)
 
#define Ch(x, y, z)   (z ^ (x & (y ^ z)))
 
#define Maj(x, y, z)   (((x | y) & z) | (x & y))
 
#define S(x, n)   RORc((x), (n))
 
#define R(x, n)   (((x)&0xFFFFFFFFUL)>>(n))
 
#define Sigma0(x)   (S(x, 2) ^ S(x, 13) ^ S(x, 22))
 
#define Sigma1(x)   (S(x, 6) ^ S(x, 11) ^ S(x, 25))
 
#define Gamma0(x)   (S(x, 7) ^ S(x, 18) ^ R(x, 3))
 
#define Gamma1(x)   (S(x, 17) ^ S(x, 19) ^ R(x, 10))
 
#define MIN(x, y)   (((x) < (y)) ? (x) : (y))
 
#define RND(a, b, c, d, e, f, g, h, i)
 

Functions

int sha256_vector (size_t num_elem, const u8 *addr[], const size_t *len, u8 *mac)
 SHA256 hash for data vector. More...
 
void sha256_init (struct sha256_state *md)
 
int sha256_process (struct sha256_state *md, const unsigned char *in, unsigned long inlen)
 
int sha256_done (struct sha256_state *md, unsigned char *out)
 

Detailed Description

SHA-256 hash implementation and interface functions.

Macro Definition Documentation

#define RND (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
 
)
Value:
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1;
#define RORc (   x,
 
)
Value:
( ((((unsigned long) (x) & 0xFFFFFFFFUL) >> (unsigned long) ((y) & 31)) | \
((unsigned long) (x) << (unsigned long) (32 - ((y) & 31)))) & 0xFFFFFFFFUL)

Function Documentation

int sha256_done ( struct sha256_state md,
unsigned char *  out 
)

Terminate the hash to get the digest

Parameters
mdThe hash state
out[out] The destination of the hash (32 bytes)
Returns
CRYPT_OK if successful
int sha256_process ( struct sha256_state md,
const unsigned char *  in,
unsigned long  inlen 
)

Process a block of memory though the hash

Parameters
mdThe hash state
inThe data to hash
inlenThe length of the data (octets)
Returns
CRYPT_OK if successful
int sha256_vector ( size_t  num_elem,
const u8 *  addr[],
const size_t *  len,
u8 *  mac 
)

SHA256 hash for data vector.

Parameters
num_elemNumber of elements in the data vector
addrPointers to the data areas
lenLengths of the data blocks
macBuffer for the hash
Returns
0 on success, -1 of failure