# SHA1.h File Reference

SHA-1 computation class. More...

`#include <stdio.h>`
`#include <memory.h>`
`#include <string.h>`
`#include "Types.h"`

## Defines

#define | MAX_FILE_READ_BUFFER 8000
#define | SHA1_LENGTH 20
#define | SHABLK0(i) (block->l[i])
#define | SHABLK(i)
#define | R0(v, w, x, y, z, i) { z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }
#define | R1(v, w, x, y, z, i) { z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }
#define | R2(v, w, x, y, z, i) { z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v,5); w=ROL32(w,30); }
#define | R3(v, w, x, y, z, i) { z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5); w=ROL32(w,30); }
#define | R4(v, w, x, y, z, i) { z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5); w=ROL32(w,30); }

## Detailed Description

SHA-1 computation class.

100% free public domain implementation of the SHA-1 algorithm by Dominik Reichl <Dominik.Reichl@tiscali.de>

=== Test Vectors (from FIPS PUB 180-1) ===

"abc" A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D

"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1

A million repetitions of "a" 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F

## Define Documentation

#define MAX_FILE_READ_BUFFER 8000

| Size of the read buffer when computing SHA-1 sum on a file

#define R0 | ( | v,
|  | w,
|  | x,
|  | y,
|  | z,
|  | i |  | ) | { z+=((w&(x^y))^y)+SHABLK0(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }

#define R1 | ( | v,
|  | w,
|  | x,
|  | y,
|  | z,
|  | i |  | ) | { z+=((w&(x^y))^y)+SHABLK(i)+0x5A827999+ROL32(v,5); w=ROL32(w,30); }

#define R2 | ( | v,
|  | w,
|  | x,
|  | y,
|  | z,
|  | i |  | ) | { z+=(w^x^y)+SHABLK(i)+0x6ED9EBA1+ROL32(v,5); w=ROL32(w,30); }

#define R3 | ( | v,
|  | w,
|  | x,
|  | y,
|  | z,
|  | i |  | ) | { z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5); w=ROL32(w,30); }

#define R4 | ( | v,
|  | w,
|  | x,
|  | y,
|  | z,
|  | i |  | ) | { z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5); w=ROL32(w,30); }

#define SHA1_LENGTH 20

| Size of an SHA-1 key in byte

#define SHABLK | ( | i |  | ) |

Value:

    (block->l[i&15] = ROL32(block->l[(i+13)&15] ^ block->l[(i+8)&15] \
                                        ^ block->l[(i+2)&15] ^ block->l[i&15],1))

#define SHABLK0 | ( | i |  | ) | (block->l[i])