Next Previous Table Of Contents

The SHA1 Class

#include <chnhash/sha1.hpp>

Overview

The SHA1 class provides an implementation of the Secure Hash Algorithm as specified in FIPS 180-1
[FIPSb]. As the SHA1 class is a subclass of the ChainHash and the SHA classes, the variables and methods presented there are not redescribed here.

Public Methods

Constructor

SHA1();
Creates a SHA1 instance. Initializes the chain variables to values specified in FIPS 180-1
[FIPSb].

Destructor

~SHA1();
Nothing special is done by the desctructor.

Compress

static void Compress(const u32* iv, const u32* block, u32* result);
Calculates the value of the SHA-1 compression function at the point determined by the starting chain variable values pointed to by iv and the block pointed to by block. The result is written into the dwords pointed to by result.

More speficially, iv[i] should equal Hi before the updating. Within block[i], the jth most significant byte should be equal to the 4*i+jth byte of the block. On return, result[i] will equal the updated value of Hi.

Compress

static void Compress(const void* iv, const void* block, void* result);
This method writes into the memory pointed to by result a high endian byte string giving the concatenation of the new values of the chain variables when the compression function is evaluated at the point determined by the block pointed to by block and concatenation of the chain variables pointed to by iv.

iv is to point to a high endian byte string giving the concatenation of the chain variables, while block is to point to a byte string giving the value of the block in the order

b[0]b[1]b[2]b[3]...b[63].

Next Previous Table Of Contents