Dynalib Utils
Classes | Macros | Functions
SHA256.h File Reference
#include <string>
#include <cstddef>
#include "../TypeDefs.h"
Include dependency graph for SHA256.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SHA256
 

Macros

#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)
 

Functions

uint8_t * sha256 (unsigned char *input, uint inputLen, uint8_t *digest)
 
uint8_t * sha256 (std::string input, uint8_t *digest)
 

Macro Definition Documentation

◆ SHA256_F1

#define SHA256_F1 (   x)    (SHA2_ROTR(x, 2) ^ SHA2_ROTR(x, 13) ^ SHA2_ROTR(x, 22))

◆ SHA256_F2

#define SHA256_F2 (   x)    (SHA2_ROTR(x, 6) ^ SHA2_ROTR(x, 11) ^ SHA2_ROTR(x, 25))

◆ SHA256_F3

#define SHA256_F3 (   x)    (SHA2_ROTR(x, 7) ^ SHA2_ROTR(x, 18) ^ SHA2_SHFR(x, 3))

◆ SHA256_F4

#define SHA256_F4 (   x)    (SHA2_ROTR(x, 17) ^ SHA2_ROTR(x, 19) ^ SHA2_SHFR(x, 10))

◆ SHA2_CH

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

◆ SHA2_MAJ

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

◆ SHA2_PACK32

#define SHA2_PACK32 (   str,
 
)
Value:
{ \
*(x) = ((uint32_t) *((str) + 3) ) \
| ((uint32_t) *((str) + 2) << 8) \
| ((uint32_t) *((str) + 1) << 16) \
| ((uint32_t) *((str) + 0) << 24); \
}
return os str()

◆ SHA2_ROTL

#define SHA2_ROTL (   x,
 
)    (((x) << (n)) | ((x) >> ((sizeof(x) << 3) - (n))))

◆ SHA2_ROTR

#define SHA2_ROTR (   x,
 
)    (((x) >> (n)) | ((x) << ((sizeof(x) << 3) - (n))))

◆ SHA2_SHFR

#define SHA2_SHFR (   x,
 
)    ((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); \
}
return os str()

Function Documentation

◆ 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 
)