This class represents the implementation of the sha1 algorithm. More...
#include <hl_sha1.h>
Public Member Functions | |
int | SHA1Reset (HL_SHA1_CTX *context) |
Resets the sha1 context and starts a new hashprocess. | |
int | SHA1Input (HL_SHA1_CTX *context, const hl_uint8 *message_array, unsigned int length) |
Data input. | |
int | SHA1Result (HL_SHA1_CTX *context, hl_uint8 Message_Digest[SHA1HashSize]) |
This ends the sha operation, zeroizing the context and returning the computed hash. | |
Private Member Functions | |
void | SHA1PadMessage (HL_SHA1_CTX *context) |
Internal method to padd the message. | |
void | SHA1ProcessMessageBlock (HL_SHA1_CTX *context) |
This member-function will process the next 512 bits of the message stored in the Message_Block array. |
This class represents the implementation of the sha1 algorithm.
Basically the class provides three public member-functions to create a hash: SHA1Reset(), SHA1Input() and SHA1Result(). If you want to create a hash based on a string or file quickly you should use the sha1wrapper class instead of SHA1.
int SHA1::SHA1Input | ( | HL_SHA1_CTX * | context, | |
const hl_uint8 * | message_array, | |||
unsigned int | length | |||
) |
Data input.
This memberfunction add data to the specified context.
context | The context to add data to | |
message_array | The data to add | |
length | The length of the data to add |
void SHA1::SHA1PadMessage | ( | HL_SHA1_CTX * | context | ) | [private] |
Internal method to padd the message.
According to the standard, the message must be padded to an even 512 bits. The first padding bit must be a '1'. The last 64 bits represent the length of the original message. All bits in between should be 0. This function will pad the message according to those rules by filling the Message_Block array accordingly. It will also call the ProcessMessageBlock function provided appropriately. When it returns, it can be assumed that the message digest has been computed.
context | The context to padd |
void SHA1::SHA1ProcessMessageBlock | ( | HL_SHA1_CTX * | context | ) | [private] |
This member-function will process the next 512 bits of the message stored in the Message_Block array.
Many of the variable names in this code, especially the single character names, were used because those were the names used in the publication.
context | The context to process |
int SHA1::SHA1Reset | ( | HL_SHA1_CTX * | context | ) |
Resets the sha1 context and starts a new hashprocess.
context | The context to reset |
int SHA1::SHA1Result | ( | HL_SHA1_CTX * | context, | |
hl_uint8 | Message_Digest[SHA1HashSize] | |||
) |
This ends the sha operation, zeroizing the context and returning the computed hash.
context | The context to get the hash from | |
Message_Digest | This is an OUT parameter which contains the hash after the menberfunction returns |