The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

m_sha256.cpp File Reference

#include "inspircd.h"
#include "m_hash.h"

Include dependency graph for m_sha256.cpp:

Go to the source code of this file.

Classes

class  SHA256Context
 An sha 256 context, used by m_opersha256. More...
class  ModuleSHA256

Defines

#define SHFR(x, n)   (x >> n)
#define ROTR(x, n)   ((x >> n) | (x << ((sizeof(x) << 3) - n)))
#define ROTL(x, n)   ((x << n) | (x >> ((sizeof(x) << 3) - n)))
#define CH(x, y, z)   ((x & y) ^ (~x & z))
#define MAJ(x, y, z)   ((x & y) ^ (x & z) ^ (y & z))
#define SHA256_F1(x)   (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22))
#define SHA256_F2(x)   (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25))
#define SHA256_F3(x)   (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
#define SHA256_F4(x)   (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
#define UNPACK32(x, str)
#define PACK32(str, x)
#define SHA256_SCR(i)

Typedefs

typedef unsigned int uint32_t

Variables

const unsigned int sha256_h0 [8]
uint32_t sha256_k [64]


Define Documentation

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

Definition at line 77 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().

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

Definition at line 78 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().

#define PACK32 str,
 ) 
 

Value:

{                                             \
        *(x) = ((uint32_t) *((str) + 3)      )     \
        | ((uint32_t) *((str) + 2) <<  8)     \
        | ((uint32_t) *((str) + 1) << 16)     \
        | ((uint32_t) *((str) + 0) << 24);    \
}

Definition at line 93 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().

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

Definition at line 76 of file m_sha256.cpp.

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

Definition at line 75 of file m_sha256.cpp.

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

Definition at line 80 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().

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

Definition at line 81 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().

#define SHA256_F3  )     (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3))
 

Definition at line 82 of file m_sha256.cpp.

#define SHA256_F4  )     (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10))
 

Definition at line 83 of file m_sha256.cpp.

#define SHA256_SCR  ) 
 

Value:

{                                             \
        w[i] =  SHA256_F4(w[i - 2]) + w[i - 7]     \
        + SHA256_F3(w[i - 15]) + w[i - 16];  \
}

Definition at line 103 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().

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

Definition at line 74 of file m_sha256.cpp.

#define 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);      \
}

Definition at line 85 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Final().


Typedef Documentation

typedef unsigned int uint32_t
 

Definition at line 60 of file m_sha256.cpp.


Variable Documentation

const unsigned int sha256_h0[8]
 

Initial value:

{
        0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
        0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
}

Definition at line 109 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Init().

uint32_t sha256_k[64]
 

Initial value:

{
        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
        0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
        0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
        0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
        0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
        0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
        0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
        0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
        0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
        0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
        0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
        0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
        0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
        0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
        0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
        0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
}

Definition at line 115 of file m_sha256.cpp.

Referenced by ModuleSHA256::SHA256Transform().