EHS Embedded HTTP Server  1.5.1.0
sha1.h
1 /* $Id: sha1.h 85 2012-03-22 12:17:32Z felfert $
2  *
3  * sha1.h
4  *
5  * Copyright (C) 1998, 2009
6  * Paul E. Jones <paulej@packetizer.com>
7  * All Rights Reserved.
8  *
9  *****************************************************************************
10  * $Id: sha1.h 85 2012-03-22 12:17:32Z felfert $
11  *****************************************************************************
12  *
13  * Description:
14  * This class implements the Secure Hashing Standard as defined
15  * in FIPS PUB 180-1 published April 17, 1995.
16  *
17  * Many of the variable names in this class, especially the single
18  * character names, were used because those were the names used
19  * in the publication.
20  *
21  * Please read the file sha1.cpp for more information.
22  *
23  */
24 
25 #ifndef _SHA1_H_
26 #define _SHA1_H_
27 
54 class SHA1
55 {
56 
57  public:
58 
59  SHA1();
60  virtual ~SHA1();
61 
66  void Reset();
67 
74  bool Result(unsigned *message_digest_array);
75 
81  void Input( const unsigned char *message_array,
82  unsigned length);
88  void Input( const char *message_array,
89  unsigned length);
94  void Input(unsigned char message_element);
99  void Input(char message_element);
105  SHA1& operator<<(const char *message_array);
111  SHA1& operator<<(const unsigned char *message_array);
117  SHA1& operator<<(const char message_element);
123  SHA1& operator<<(const unsigned char message_element);
124 
125  private:
126 
127  /*
128  * Process the next 512 bits of the message
129  */
130  void ProcessMessageBlock();
131 
132  /*
133  * Pads the current message block to 512 bits
134  */
135  void PadMessage();
136 
137  /*
138  * Performs a circular left shift operation
139  */
140  inline unsigned CircularShift(int bits, unsigned word);
141 
142  unsigned H[5]; // Message digest buffers
143 
144  unsigned Length_Low; // Message length in bits
145  unsigned Length_High; // Message length in bits
146 
147  unsigned char Message_Block[64]; // 512-bit message blocks
148  int Message_Block_Index; // Index into message block array
149 
150  bool Computed; // Is the digest computed?
151  bool Corrupted; // Is the message digest corruped?
152 
153 };
154 
155 #endif
SHA1::Input
void Input(const unsigned char *message_array, unsigned length)
Append data to the the message.
SHA1::Reset
void Reset()
Initializes the class member variables in preparation for computing a new message digest.
SHA1::operator<<
SHA1 & operator<<(const char *message_array)
Convenience operator for appending string data to the the message.
SHA1::Result
bool Result(unsigned *message_digest_array)
Retrieves the 160-bit message digest.
SHA1
Definition: sha1.h:54