35 #define sha_rotl(n,x) ( ((x) << (n)) | ((x) >> (32-(n))) )
36 #define sha_ch(x,y,z) ( ((x) & (y)) | ((~(x)) & (z)) )
37 #define sha_parity(x,y,z) ( (x) ^ (y) ^ (z) )
38 #define sha_maj(x,y,z) ( ((x) & (y)) | ((x) & (z)) | ((y) & (z)) )
42 s << std::hex << std::setfill(
'0') << std::setw(8) <<
H0;
43 s << std::hex << std::setfill(
'0') << std::setw(8) <<
H1;
44 s << std::hex << std::setfill(
'0') << std::setw(8) <<
H2;
45 s << std::hex << std::setfill(
'0') << std::setw(8) <<
H3;
46 s << std::hex << std::setfill(
'0') << std::setw(8) <<
H4;
51 : H0(0x67452301), H1(0xefcdab89), H2(0x98badcfe), H3(0x10325476), H4(0xc3d2e1f0)
55 int bytes_left = str.size();
56 Uint32 ssz = bytes_left * 8;
60 while (bytes_left > 0) {
61 iss.read(reinterpret_cast<char*>(block), 64);
62 if (bytes_left <= 64) {
63 if (bytes_left < 64) {
64 block[bytes_left]= 0x80;
67 for (i = 63; i > bytes_left; i--) {
70 if (bytes_left < 56) {
72 block[60] = ssz >> 24;
74 #pragma warning (push)
75 #pragma warning (disable: 4244)
77 block[61] = ssz >> 16;
86 for (i = 0; i < 60 ; i++) {
89 if (bytes_left == 64) {
93 block[60] = ssz >> 24;
95 #pragma warning (push)
96 #pragma warning (disable: 4244)
98 block[61] = ssz >> 16;
102 #pragma warning (pop)
113 Uint32 A, B, C, D, E, T;
121 for (i = 0; i < 16; i++) {
122 W[
i]= (block[4 *
i] << 24) | (block[4 * i + 1] << 16) | (block[4 * i + 2] << 8) | block[4 * i + 3];
124 for (; i < 80; i++) {
125 W[
i]=
sha_rotl(1, W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16]);
127 for (i = 0; i < 20; i++) {
135 for (; i < 40; i++) {
143 for (; i < 60; i++) {
151 for (; i < 80; i++) {
#define sha_parity(x, y, z)
std::string display()
Display the hash.
void next(Uint8 block[64])
Process the next 512 bits block.
sha1_hash(const std::string &str)
Make a hash from a string.
static void block(LexState *ls)
GLsizei const GLcharARB ** string