ucommon
7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
![]() ![]() |
Go to the source code of this file.
Macros | |
#define | rotl32(x, n) (((x) << n) | ((x) >> (32 - n))) |
#define | rotr32(x, n) (((x) >> n) | ((x) << (32 - n))) |
#define | bswap_32(x) ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00)) |
#define | ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
#define | maj(x, y, z) (((x) & (y)) | ((z) & ((x) ^ (y)))) |
#define | vf(n, i) v[(n - i) & 7] |
#define | hf(i) |
#define | v_cycle(i, j) |
#define | SHA256_MASK (SHA256_BLOCK_SIZE - 1) |
#define | bsw_32(p, n) |
#define | s_0(x) (rotr32((x), 2) ^ rotr32((x), 13) ^ rotr32((x), 22)) |
#define | s_1(x) (rotr32((x), 6) ^ rotr32((x), 11) ^ rotr32((x), 25)) |
#define | g_0(x) (rotr32((x), 7) ^ rotr32((x), 18) ^ ((x) >> 3)) |
#define | g_1(x) (rotr32((x), 17) ^ rotr32((x), 19) ^ ((x) >> 10)) |
#define | k_0 k256 |
#define | q(n) v##n |
#define | one_cycle(a, b, c, d, e, f, g, h, k, w) |
#define | SHA512_MASK (SHA512_BLOCK_SIZE - 1) |
#define | rotr64(x, n) (((x) >> n) | ((x) << (64 - n))) |
#define | bswap_64(x) (((uint_64t)(bswap_32((uint_32t)(x)))) << 32 | bswap_32((uint_32t)((x) >> 32))) |
#define | bsw_64(p, n) |
#define | s_0(x) (rotr64((x), 28) ^ rotr64((x), 34) ^ rotr64((x), 39)) |
#define | s_1(x) (rotr64((x), 14) ^ rotr64((x), 18) ^ rotr64((x), 41)) |
#define | g_0(x) (rotr64((x), 1) ^ rotr64((x), 8) ^ ((x) >> 7)) |
#define | g_1(x) (rotr64((x), 19) ^ rotr64((x), 61) ^ ((x) >> 6)) |
#define | k_0 k512 |
#define | CTX_224(x) ((x)->uu->ctx256) |
#define | CTX_256(x) ((x)->uu->ctx256) |
#define | CTX_384(x) ((x)->uu->ctx512) |
#define | CTX_512(x) ((x)->uu->ctx512) |
Functions | |
void | sha256_compile (sha256_ctx ctx[1]) |
void | sha256_hash (const unsigned char data[], unsigned long len, sha256_ctx ctx[1]) |
static void | sha_end1 (unsigned char hval[], sha256_ctx ctx[1], const unsigned int hlen) |
void | sha224_begin (sha224_ctx ctx[1]) |
void | sha224_end (unsigned char hval[], sha224_ctx ctx[1]) |
void | sha224 (unsigned char hval[], const unsigned char data[], unsigned long len) |
void | sha256_begin (sha256_ctx ctx[1]) |
void | sha256_end (unsigned char hval[], sha256_ctx ctx[1]) |
void | sha256 (unsigned char hval[], const unsigned char data[], unsigned long len) |
void | sha512_compile (sha512_ctx ctx[1]) |
void | sha512_hash (const unsigned char data[], unsigned long len, sha512_ctx ctx[1]) |
static void | sha_end2 (unsigned char hval[], sha512_ctx ctx[1], const unsigned int hlen) |
void | sha384_begin (sha384_ctx ctx[1]) |
void | sha384_end (unsigned char hval[], sha384_ctx ctx[1]) |
void | sha384 (unsigned char hval[], const unsigned char data[], unsigned long len) |
void | sha512_begin (sha512_ctx ctx[1]) |
void | sha512_end (unsigned char hval[], sha512_ctx ctx[1]) |
void | sha512 (unsigned char hval[], const unsigned char data[], unsigned long len) |
int | sha2_begin (unsigned long len, sha2_ctx ctx[1]) |
void | sha2_hash (const unsigned char data[], unsigned long len, sha2_ctx ctx[1]) |
void | sha2_end (unsigned char hval[], sha2_ctx ctx[1]) |
int | sha2 (unsigned char hval[], unsigned long size, const unsigned char data[], unsigned long len) |
Variables | |
const uint_32t | k256 [64] |
const uint_32t | i224 [8] |
const uint_32t | i256 [8] |
const uint_64t | k512 [80] |
const uint_64t | i384 [80] |
const uint_64t | i512 [80] |
#define bswap_32 | ( | x | ) | ((rotr32((x), 24) & 0x00ff00ff) | (rotr32((x), 8) & 0xff00ff00)) |
#define hf | ( | i | ) |
#define maj | ( | x, | |
y, | |||
z | |||
) | (((x) & (y)) | ((z) & ((x) ^ (y)))) |
#define one_cycle | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
k, | |||
w | |||
) |
#define SHA256_MASK (SHA256_BLOCK_SIZE - 1) |
#define SHA512_MASK (SHA512_BLOCK_SIZE - 1) |
#define v_cycle | ( | i, | |
j | |||
) |
int sha2 | ( | unsigned char | hval[], |
unsigned long | size, | ||
const unsigned char | data[], | ||
unsigned long | len | ||
) |
Definition at line 757 of file sha2.cpp.
References sha2_begin(), sha2_end(), and sha2_hash().
void sha224 | ( | unsigned char | hval[], |
const unsigned char | data[], | ||
unsigned long | len | ||
) |
Definition at line 390 of file sha2.cpp.
References sha224_begin(), SHA224_DIGEST_SIZE, sha224_hash, and sha_end1().
void sha224_begin | ( | sha224_ctx | ctx[1] | ) |
Definition at line 379 of file sha2.cpp.
References sha256_ctx::count, sha256_ctx::hash, and i224.
Referenced by sha224().
void sha224_end | ( | unsigned char | hval[], |
sha224_ctx | ctx[1] | ||
) |
Definition at line 385 of file sha2.cpp.
References SHA224_DIGEST_SIZE, and sha_end1().
void sha256 | ( | unsigned char | hval[], |
const unsigned char | data[], | ||
unsigned long | len | ||
) |
Definition at line 419 of file sha2.cpp.
References sha256_begin(), SHA256_DIGEST_SIZE, sha256_hash(), and sha_end1().
void sha256_begin | ( | sha256_ctx | ctx[1] | ) |
Definition at line 408 of file sha2.cpp.
References sha256_ctx::count, sha256_ctx::hash, and i256.
Referenced by hmacSha256Init(), and sha256().
void sha256_compile | ( | sha256_ctx | ctx[1] | ) |
Definition at line 192 of file sha2.cpp.
References sha256_ctx::hash, hf, k256, one_cycle, v_cycle, and sha256_ctx::wbuf.
Referenced by sha256_hash(), and sha_end1().
void sha256_end | ( | unsigned char | hval[], |
sha256_ctx | ctx[1] | ||
) |
Definition at line 414 of file sha2.cpp.
References SHA256_DIGEST_SIZE, and sha_end1().
Referenced by hmacSha256Final(), and hmacSha256Init().
void sha256_hash | ( | const unsigned char | data[], |
unsigned long | len, | ||
sha256_ctx | ctx[1] | ||
) |
Definition at line 304 of file sha2.cpp.
References bsw_32, sha256_ctx::count, SHA256_BLOCK_SIZE, sha256_compile(), SHA256_MASK, and sha256_ctx::wbuf.
Referenced by hmacSha256Final(), hmacSha256Init(), hmacSha256Update(), sha256(), and sha2_hash().
int sha2_begin | ( | unsigned long | len, |
sha2_ctx | ctx[1] | ||
) |
void sha2_end | ( | unsigned char | hval[], |
sha2_ctx | ctx[1] | ||
) |
Definition at line 738 of file sha2.cpp.
References CTX_224, CTX_256, CTX_384, CTX_512, SHA224_DIGEST_SIZE, SHA256_DIGEST_SIZE, sha2_ctx::sha2_len, SHA384_DIGEST_SIZE, SHA512_DIGEST_SIZE, sha_end1(), and sha_end2().
Referenced by sha2().
void sha2_hash | ( | const unsigned char | data[], |
unsigned long | len, | ||
sha2_ctx | ctx[1] | ||
) |
Definition at line 719 of file sha2.cpp.
References CTX_224, CTX_256, CTX_384, CTX_512, sha224_hash, sha256_hash(), sha2_ctx::sha2_len, sha384_hash, and sha512_hash().
Referenced by sha2().
void sha384 | ( | unsigned char | hval[], |
const unsigned char | data[], | ||
unsigned long | len | ||
) |
Definition at line 635 of file sha2.cpp.
References sha384_begin(), SHA384_DIGEST_SIZE, sha384_hash, and sha_end2().
void sha384_begin | ( | sha384_ctx | ctx[1] | ) |
Definition at line 624 of file sha2.cpp.
References sha512_ctx::count, sha512_ctx::hash, and i384.
Referenced by hmacSha384Init(), and sha384().
void sha384_end | ( | unsigned char | hval[], |
sha384_ctx | ctx[1] | ||
) |
Definition at line 630 of file sha2.cpp.
References SHA384_DIGEST_SIZE, and sha_end2().
Referenced by hmacSha384Final(), and hmacSha384Init().
void sha512 | ( | unsigned char | hval[], |
const unsigned char | data[], | ||
unsigned long | len | ||
) |
Definition at line 668 of file sha2.cpp.
References sha512_begin(), SHA512_DIGEST_SIZE, sha512_hash(), and sha_end2().
void sha512_begin | ( | sha512_ctx | ctx[1] | ) |
Definition at line 657 of file sha2.cpp.
References sha512_ctx::count, sha512_ctx::hash, and i512.
Referenced by sha512().
void sha512_compile | ( | sha512_ctx | ctx[1] | ) |
Definition at line 514 of file sha2.cpp.
References sha512_ctx::hash, v_cycle, and sha512_ctx::wbuf.
Referenced by sha512_hash(), and sha_end2().
void sha512_end | ( | unsigned char | hval[], |
sha512_ctx | ctx[1] | ||
) |
Definition at line 663 of file sha2.cpp.
References SHA512_DIGEST_SIZE, and sha_end2().
void sha512_hash | ( | const unsigned char | data[], |
unsigned long | len, | ||
sha512_ctx | ctx[1] | ||
) |
Definition at line 545 of file sha2.cpp.
References bsw_64, sha512_ctx::count, SHA512_BLOCK_SIZE, sha512_compile(), SHA512_MASK, and sha512_ctx::wbuf.
Referenced by sha2_hash(), and sha512().
|
static |
Definition at line 325 of file sha2.cpp.
References bsw_32, sha256_ctx::count, sha256_ctx::hash, SHA256_BLOCK_SIZE, sha256_compile(), SHA256_MASK, and sha256_ctx::wbuf.
Referenced by sha224(), sha224_end(), sha256(), sha256_end(), and sha2_end().
|
static |
Definition at line 566 of file sha2.cpp.
References bsw_64, sha512_ctx::count, sha512_ctx::hash, SHA512_BLOCK_SIZE, sha512_compile(), SHA512_MASK, and sha512_ctx::wbuf.
Referenced by sha2_end(), sha384(), sha384_end(), sha512(), and sha512_end().
const uint_32t i224[8] |
Definition at line 373 of file sha2.cpp.
Referenced by sha224_begin(), and sha2_begin().
const uint_32t i256[8] |
Definition at line 402 of file sha2.cpp.
Referenced by sha256_begin(), and sha2_begin().
const uint_64t i384[80] |
Definition at line 616 of file sha2.cpp.
Referenced by sha2_begin(), and sha384_begin().
const uint_64t i512[80] |
Definition at line 649 of file sha2.cpp.
Referenced by sha2_begin(), and sha512_begin().
const uint_32t k256[64] |
Definition at line 167 of file sha2.cpp.
Referenced by sha256_compile().