22 #ifndef _TINY_SHA1_HPP_ 23 #define _TINY_SHA1_HPP_ 35 inline static uint32_t
LeftRotate(uint32_t value,
size_t count) {
36 return (value << count) ^ (value >> (32-count));
42 memcpy(
m_digest,
s.m_digest, 5 *
sizeof(uint32_t));
68 const uint8_t* begin =
static_cast<const uint8_t*
>(start);
69 const uint8_t* finish =
static_cast<const uint8_t*
>(end);
70 while(begin != finish) {
77 const uint8_t* block =
static_cast<const uint8_t*
>(data);
100 processByte( static_cast<unsigned char>((bitCount>>24) & 0xFF));
101 processByte( static_cast<unsigned char>((bitCount>>16) & 0xFF));
102 processByte( static_cast<unsigned char>((bitCount>>8 ) & 0xFF));
103 processByte( static_cast<unsigned char>((bitCount) & 0xFF));
105 memcpy(digest,
m_digest, 5 *
sizeof(uint32_t));
112 digest[di++] = ((d32[0] >> 24) & 0xFF);
113 digest[di++] = ((d32[0] >> 16) & 0xFF);
114 digest[di++] = ((d32[0] >> 8) & 0xFF);
115 digest[di++] = ((d32[0]) & 0xFF);
117 digest[di++] = ((d32[1] >> 24) & 0xFF);
118 digest[di++] = ((d32[1] >> 16) & 0xFF);
119 digest[di++] = ((d32[1] >> 8) & 0xFF);
120 digest[di++] = ((d32[1]) & 0xFF);
122 digest[di++] = ((d32[2] >> 24) & 0xFF);
123 digest[di++] = ((d32[2] >> 16) & 0xFF);
124 digest[di++] = ((d32[2] >> 8) & 0xFF);
125 digest[di++] = ((d32[2]) & 0xFF);
127 digest[di++] = ((d32[3] >> 24) & 0xFF);
128 digest[di++] = ((d32[3] >> 16) & 0xFF);
129 digest[di++] = ((d32[3] >> 8) & 0xFF);
130 digest[di++] = ((d32[3]) & 0xFF);
132 digest[di++] = ((d32[4] >> 24) & 0xFF);
133 digest[di++] = ((d32[4] >> 16) & 0xFF);
134 digest[di++] = ((d32[4] >> 8) & 0xFF);
135 digest[di++] = ((d32[4]) & 0xFF);
142 for (
size_t i = 0; i < 16; i++) {
143 w[i] = (
m_block[i*4 + 0] << 24);
144 w[i] |= (
m_block[i*4 + 1] << 16);
145 w[i] |= (
m_block[i*4 + 2] << 8);
148 for (
size_t i = 16; i < 80; i++) {
149 w[i] =
LeftRotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1);
158 for (std::size_t i=0; i<80; ++i) {
163 f = (
b & c) | (~
b &
d);
169 f = (
b & c) | (
b &
d) | (c &
d);
175 uint32_t temp =
LeftRotate(
a, 5) + f + e + k + w[i];
Definition: TinySHA1.hpp:30
int d
Definition: base.py:14
SHA1 & processBlock(const void *const start, const void *const end)
Definition: TinySHA1.hpp:67
Definition: TinySHA1.hpp:28
SHA1()
Definition: TinySHA1.hpp:38
const SHA1 & operator=(const SHA1 &s)
Definition: TinySHA1.hpp:41
SHA1 & reset()
Definition: TinySHA1.hpp:48
SHA1(const SHA1 &s)
Definition: TinySHA1.hpp:40
const uint32_t * getDigest(digest32_t digest)
Definition: TinySHA1.hpp:81
SHA1 & processBytes(const void *const data, size_t len)
Definition: TinySHA1.hpp:76
digest32_t m_digest
Definition: TinySHA1.hpp:190
int b
Definition: base.py:1
static uint32_t LeftRotate(uint32_t value, size_t count)
Definition: TinySHA1.hpp:35
SHA1 & processByte(uint8_t octet)
Definition: TinySHA1.hpp:58
size_t m_byteCount
Definition: TinySHA1.hpp:193
uint8_t digest8_t[20]
Definition: TinySHA1.hpp:34
string a
Definition: MakeCryptoOps.py:15
uint32_t digest32_t[5]
Definition: TinySHA1.hpp:33
size_t m_blockByteIndex
Definition: TinySHA1.hpp:192
void processBlock()
Definition: TinySHA1.hpp:140
virtual ~SHA1()
Definition: TinySHA1.hpp:39
const uint8_t * getDigestBytes(digest8_t digest)
Definition: TinySHA1.hpp:108
#define s(x, c)
Definition: aesb.c:46
uint8_t m_block[64]
Definition: TinySHA1.hpp:191