EHS Embedded HTTP Server  1.5.0.132
SHA1 Class Reference

This class implements the Secure Hashing Standard as defined in FIPS PUB 180-1 published April 17, 1995. More...

#include <sha1.h>

List of all members.

Public Member Functions

void Reset ()
 Initializes the class member variables in preparation for computing a new message digest.
bool Result (unsigned *message_digest_array)
 Retrieves the 160-bit message digest.
void Input (const unsigned char *message_array, unsigned length)
 Append data to the the message.
void Input (const char *message_array, unsigned length)
 Append data to the the message.
void Input (unsigned char message_element)
 Append data to the the message.
void Input (char message_element)
 Append data to the the message.
SHA1operator<< (const char *message_array)
 Convenience operator for appending string data to the the message.
SHA1operator<< (const unsigned char *message_array)
 Convenience operator for appending string data to the the message.
SHA1operator<< (const char message_element)
 Convenience operator for appending character data to the the message.
SHA1operator<< (const unsigned char message_element)
 Convenience operator for appending octet data to the the message.

Detailed Description

This class implements the Secure Hashing Standard as defined in FIPS PUB 180-1 published April 17, 1995.

The Secure Hashing Standard, which uses the Secure Hashing Algorithm (SHA), produces a 160-bit message digest for a given data stream. In theory, it is highly improbable that two messages will produce the same message digest. Therefore, this algorithm can serve as a means of providing a "fingerprint" for a message.

Portability Issues

SHA-1 is defined in terms of 32-bit "words". This code was written with the expectation that the processor has at least a 32-bit machine word size. If the machine word size is larger, the code should still function properly. One caveat to that is that the input functions taking characters and character arrays assume that only 8 bits of information are stored in each character.

Caveats

SHA-1 is designed to work with messages less than 2^64 bits long. Although SHA-1 allows a message digest to be generated for messages of any number of bits less than 2^64, this implementation only works with messages with a length that is a multiple of 8 bits.

Examples:

ehs_wsgate.cpp.


Member Function Documentation

void Input ( const unsigned char *  message_array,
unsigned  length 
)

Append data to the the message.

Parameters:
message_arrayArray of octets.
lengthThe amount of octets to add.
void Input ( const char *  message_array,
unsigned  length 
)

Append data to the the message.

Parameters:
message_arrayArray of octets.
lengthThe amount of octets to add.
void Input ( unsigned char  message_element)

Append data to the the message.

Parameters:
message_elementA single octet.
void Input ( char  message_element)

Append data to the the message.

Parameters:
message_elementA single octet.
SHA1& operator<< ( const char *  message_array)

Convenience operator for appending string data to the the message.

Parameters:
message_arrayA string.
Returns:
A reference to this instance.
SHA1& operator<< ( const unsigned char *  message_array)

Convenience operator for appending string data to the the message.

Parameters:
message_arrayA string.
Returns:
A reference to this instance.
SHA1& operator<< ( const char  message_element)

Convenience operator for appending character data to the the message.

Parameters:
message_elementA character.
Returns:
A reference to this instance.
SHA1& operator<< ( const unsigned char  message_element)

Convenience operator for appending octet data to the the message.

Parameters:
message_elementAn octet.
Returns:
A reference to this instance.
bool Result ( unsigned *  message_digest_array)

Retrieves the 160-bit message digest.

Parameters:
message_digest_arrayA pointer to an array, holding the digest. This array MUST hold 5 unsigned ints.
Returns:
true on success.
Examples:
ehs_wsgate.cpp.

The documentation for this class was generated from the following file: