#include <string>
#include <cstddef>
#include "../TypeDefs.h"
Go to the source code of this file.
|
| #define | SHA2_SHFR(x, n) ((x) >> (n)) |
| |
| #define | SHA2_ROTR(x, n) (((x) >> (n)) | ((x) << ((sizeof(x) << 3) - (n)))) |
| |
| #define | SHA2_ROTL(x, n) (((x) << (n)) | ((x) >> ((sizeof(x) << 3) - (n)))) |
| |
| #define | SHA2_CH(x, y, z) (((x) & (y)) ^ (~(x) & (z))) |
| |
| #define | SHA2_MAJ(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) |
| |
| #define | SHA256_F1(x) (SHA2_ROTR(x, 2) ^ SHA2_ROTR(x, 13) ^ SHA2_ROTR(x, 22)) |
| |
| #define | SHA256_F2(x) (SHA2_ROTR(x, 6) ^ SHA2_ROTR(x, 11) ^ SHA2_ROTR(x, 25)) |
| |
| #define | SHA256_F3(x) (SHA2_ROTR(x, 7) ^ SHA2_ROTR(x, 18) ^ SHA2_SHFR(x, 3)) |
| |
| #define | SHA256_F4(x) (SHA2_ROTR(x, 17) ^ SHA2_ROTR(x, 19) ^ SHA2_SHFR(x, 10)) |
| |
| #define | SHA2_UNPACK32(x, str) |
| |
| #define | SHA2_PACK32(str, x) |
| |
|
| uint8_t * | sha256 (unsigned char *input, uint inputLen, uint8_t *digest) |
| |
| uint8_t * | sha256 (std::string input, uint8_t *digest) |
| |
◆ SHA256_F1
◆ SHA256_F2
◆ SHA256_F3
◆ SHA256_F4
◆ SHA2_CH
| #define SHA2_CH |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| (((x) & (y)) ^ (~(x) & (z))) |
◆ SHA2_MAJ
| #define SHA2_MAJ |
( |
|
x, |
|
|
|
y, |
|
|
|
z |
|
) |
| (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) |
◆ SHA2_PACK32
| #define SHA2_PACK32 |
( |
|
str, |
|
|
|
x |
|
) |
| |
Value:{ \
*(x) = ((uint32_t) *((
str) + 3) ) \
| ((uint32_t) *((
str) + 2) << 8) \
| ((uint32_t) *((
str) + 1) << 16) \
| ((uint32_t) *((
str) + 0) << 24); \
}
◆ SHA2_ROTL
| #define SHA2_ROTL |
( |
|
x, |
|
|
|
n |
|
) |
| (((x) << (n)) | ((x) >> ((sizeof(x) << 3) - (n)))) |
◆ SHA2_ROTR
| #define SHA2_ROTR |
( |
|
x, |
|
|
|
n |
|
) |
| (((x) >> (n)) | ((x) << ((sizeof(x) << 3) - (n)))) |
◆ SHA2_SHFR
| #define SHA2_SHFR |
( |
|
x, |
|
|
|
n |
|
) |
| ((x) >> (n)) |
◆ SHA2_UNPACK32
| #define SHA2_UNPACK32 |
( |
|
x, |
|
|
|
str |
|
) |
| |
Value:{ \
*((
str) + 3) = (uint8_t) ((x) ); \
*((
str) + 2) = (uint8_t) ((x) >> 8); \
*((
str) + 1) = (uint8_t) ((x) >> 16); \
*((
str) + 0) = (uint8_t) ((x) >> 24); \
}
◆ sha256() [1/2]
| uint8_t* sha256 |
( |
unsigned char * |
input, |
|
|
uint |
inputLen, |
|
|
uint8_t * |
digest |
|
) |
| |
◆ sha256() [2/2]
| uint8_t* sha256 |
( |
std::string |
input, |
|
|
uint8_t * |
digest |
|
) |
| |