RINASim  October 2016
Documentation of framework for OMNeT++
SHA256.h File Reference
#include <cstring>
#include <string>
#include <cstdio>

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

std::string sha256 (std::string input)
 

Macro Definition Documentation

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

Definition at line 65 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 66 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 67 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 68 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 63 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 64 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 76 of file SHA256.h.

Referenced by SHA256::transform().

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

Definition at line 62 of file SHA256.h.

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

Definition at line 61 of file SHA256.h.

#define SHA2_SHFR (   x,
 
)    (x >> n)

Definition at line 60 of file SHA256.h.

#define SHA2_UNPACK32 (   x,
  str 
)
Value:
{ \
*((str) + 3) = (uint8) ((x) ); \
*((str) + 2) = (uint8) ((x) >> 8); \
*((str) + 1) = (uint8) ((x) >> 16); \
*((str) + 0) = (uint8) ((x) >> 24); \
}

Definition at line 69 of file SHA256.h.

Referenced by SHA256::final().

Function Documentation

std::string sha256 ( std::string  input)

Definition at line 146 of file SHA256.cc.