61#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8)
62#define SHA384_SHORT_BLOCK_LENGTH (SHA384_BLOCK_LENGTH - 16)
63#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16)
65#define SHA2_WORD64_CONST(dw1, dw2) (((sha2_word64)(dw1) << 32) | (dw2))
68#ifndef WORDS_BIGENDIAN
69#define REVERSE32(w,x) { \
70 sha2_word32 tmp = (w); \
71 tmp = (tmp >> 16) | (tmp << 16); \
72 (x) = ((tmp & 0xff00ff00) >> 8) | ((tmp & 0x00ff00ff) << 8); \
74#define REVERSE64(w,x) { \
75 sha2_word64 tmp = (w); \
76 tmp = (tmp >> 32) | (tmp << 32); \
77 tmp = ((tmp & SHA2_WORD64_CONST(0xff00ff00, 0xff00ff00)) >> 8) | \
78 ((tmp & SHA2_WORD64_CONST(0x00ff00ff, 0x00ff00ff)) << 8); \
79 (x) = ((tmp & SHA2_WORD64_CONST(0xffff0000, 0xffff0000)) >> 16) | \
80 ((tmp & SHA2_WORD64_CONST(0x0000ffff, 0x0000ffff)) << 16); \
89#define ADDINC128(w,n) { \
90 (w)[0] += (sha2_word64)(n); \
105#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY)
107#define SHA2_USE_MEMSET_MEMCPY 1
109#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY)
111#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both!
114#ifdef SHA2_USE_MEMSET_MEMCPY
115#define MEMSET_BZERO(p,l) memset((p), 0, (l))
116#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l))
118#ifdef SHA2_USE_BZERO_BCOPY
119#define MEMSET_BZERO(p,l) bzero((p), (l))
120#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l))
134#define R(b,x) ((x) >> (b))
136#define S32(b,x) (((x) >> (b)) | ((x) << (32 - (b))))
138#define S64(b,x) (((x) >> (b)) | ((x) << (64 - (b))))
141#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
142#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
145#define Sigma0_256(x) (S32(2, (x)) ^ S32(13, (x)) ^ S32(22, (x)))
146#define Sigma1_256(x) (S32(6, (x)) ^ S32(11, (x)) ^ S32(25, (x)))
147#define sigma0_256(x) (S32(7, (x)) ^ S32(18, (x)) ^ R(3 , (x)))
148#define sigma1_256(x) (S32(17, (x)) ^ S32(19, (x)) ^ R(10, (x)))
151#define Sigma0_512(x) (S64(28, (x)) ^ S64(34, (x)) ^ S64(39, (x)))
152#define Sigma1_512(x) (S64(14, (x)) ^ S64(18, (x)) ^ S64(41, (x)))
153#define sigma0_512(x) (S64( 1, (x)) ^ S64( 8, (x)) ^ R( 7, (x)))
154#define sigma1_512(x) (S64(19, (x)) ^ S64(61, (x)) ^ R( 6, (x)))
169 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
170 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
171 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
172 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
173 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
174 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
175 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
176 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
177 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
178 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
179 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
180 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
181 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
182 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
183 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
184 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
284#ifdef SHA2_UNROLL_TRANSFORM
288#ifndef WORDS_BIGENDIAN
290#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
291 REVERSE32(*data++, W256[j]); \
292 T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
295 (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
301#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \
302 T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \
303 K256[j] + (W256[j] = *data++); \
305 (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
310#define ROUND256(a,b,c,d,e,f,g,h) \
311 s0 = W256[(j+1)&0x0f]; \
312 s0 = sigma0_256(s0); \
313 s1 = W256[(j+14)&0x0f]; \
314 s1 = sigma1_256(s1); \
315 T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \
316 (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \
318 (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
374 a =
b =
c =
d =
e =
f =
g =
h = T1 = 0;
398#ifndef WORDS_BIGENDIAN
422 s0 = W256[(
j+1)&0x0f];
424 s1 = W256[(
j+14)&0x0f];
429 (W256[
j&0x0f] +=
s1 + W256[(
j+9)&0x0f] + s0);
454 a =
b =
c =
d =
e =
f =
g =
h = T1 = T2 = 0;
460 unsigned int freespace, usedspace;
475 if (
len >= freespace) {
478 context->bitcount += freespace << 3;
487 usedspace = freespace = 0;
504 usedspace = freespace = 0;
509 unsigned int usedspace;
515 if (digest !=
NULL) {
517#ifndef WORDS_BIGENDIAN
523 context->buffer[usedspace++] = 0x80;
551#ifndef WORDS_BIGENDIAN
555 for (
j = 0;
j < 8;
j++) {
612#ifdef SHA2_UNROLL_TRANSFORM
615#ifndef WORDS_BIGENDIAN
617#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
618 REVERSE64(*data++, W512[j]); \
619 T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
622 (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \
628#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \
629 T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \
630 K512[j] + (W512[j] = *data++); \
632 (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
637#define ROUND512(a,b,c,d,e,f,g,h) \
638 s0 = W512[(j+1)&0x0f]; \
639 s0 = sigma0_512(s0); \
640 s1 = W512[(j+14)&0x0f]; \
641 s1 = sigma1_512(s1); \
642 T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \
643 (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \
645 (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
698 a =
b =
c =
d =
e =
f =
g =
h = T1 = 0;
720#ifndef WORDS_BIGENDIAN
744 s0 = W512[(
j+1)&0x0f];
746 s1 = W512[(
j+14)&0x0f];
751 (W512[
j&0x0f] +=
s1 + W512[(
j+9)&0x0f] + s0);
776 a =
b =
c =
d =
e =
f =
g =
h = T1 = T2 = 0;
782 unsigned int freespace, usedspace;
797 if (
len >= freespace) {
809 usedspace = freespace = 0;
826 usedspace = freespace = 0;
830 unsigned int usedspace;
833#ifndef WORDS_BIGENDIAN
840 context->buffer[usedspace++] = 0x80;
877 if (digest !=
NULL) {
881#ifndef WORDS_BIGENDIAN
885 for (
j = 0;
j < 8;
j++) {
952 if (digest !=
NULL) {
956#ifndef WORDS_BIGENDIAN
960 for (
j = 0;
j < 6;
j++) {
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
static const sha2_word64 sha384_initial_hash_value[8]
char * SHA384_End(SHA384_CTX *context, char buffer[])
void SHA384_Init(SHA384_CTX *context)
void SHA256_Init(SHA256_CTX *context)
void SHA256_Final(sha2_byte digest[], SHA256_CTX *context)
static const sha2_word64 sha512_initial_hash_value[8]
void SHA384_Update(SHA384_CTX *context, const sha2_byte *data, size_t len)
char * SHA512_End(SHA512_CTX *context, char buffer[])
void SHA256_Update(SHA256_CTX *context, const sha2_byte *data, size_t len)
char * SHA256_Data(const sha2_byte *data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH])
static const sha2_word64 K512[80]
char * SHA256_End(SHA256_CTX *context, char buffer[])
static const sha2_word32 sha256_initial_hash_value[8]
void SHA512_Last(SHA512_CTX *)
void SHA512_Transform(SHA512_CTX *, const sha2_word64 *)
void SHA384_Final(sha2_byte digest[], SHA384_CTX *context)
#define MEMSET_BZERO(p, l)
#define SHA2_WORD64_CONST(dw1, dw2)
#define MEMCPY_BCOPY(d, s, l)
#define SHA512_SHORT_BLOCK_LENGTH
char * SHA384_Data(const sha2_byte *data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH])
char * SHA512_Data(const sha2_byte *data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH])
#define SHA256_SHORT_BLOCK_LENGTH
void SHA512_Update(SHA512_CTX *context, const sha2_byte *data, size_t len)
void SHA256_Transform(SHA256_CTX *, const sha2_word32 *)
void SHA512_Final(sha2_byte digest[], SHA512_CTX *context)
static const char sha2_hex_digits[]
static const sha2_word32 K256[64]
void SHA512_Init(SHA512_CTX *context)
#define SHA256_DIGEST_STRING_LENGTH
#define SHA512_DIGEST_LENGTH
#define SHA384_DIGEST_STRING_LENGTH
#define SHA384_DIGEST_LENGTH
#define SHA384_BLOCK_LENGTH
#define SHA512_BLOCK_LENGTH
#define SHA512_DIGEST_STRING_LENGTH
#define SHA256_DIGEST_LENGTH
#define SHA256_BLOCK_LENGTH