sha1.h
Go to the documentation of this file.
1 /*
2  * sha1.h
3  *
4  * Copyright (C) 1998, 2009
5  * Paul E. Jones <paulej@packetizer.com>
6  * All Rights Reserved.
7  *
8  *****************************************************************************
9  * $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
10  *****************************************************************************
11  *
12  * Description:
13  * This class implements the Secure Hashing Standard as defined
14  * in FIPS PUB 180-1 published April 17, 1995.
15  *
16  * Many of the variable names in this class, especially the single
17  * character names, were used because those were the names used
18  * in the publication.
19  *
20  * Please read the file sha1.cpp for more information.
21  *
22  */
23 
24 #ifndef cetlib_test_sha1_h
25 #define cetlib_test_sha1_h
26 
27 namespace fhicl {
28 
29  class SHA1 {
30 
31  public:
32  SHA1();
33 
34  /*
35  * Re-initialize the class
36  */
37  void Reset();
38 
39  /*
40  * Returns the message digest
41  */
42  bool Result(unsigned* message_digest_array);
43 
44  /*
45  * Provide input to SHA1
46  */
47  void Input(const unsigned char* message_array, unsigned length);
48  void Input(const char* message_array, unsigned length);
49  void Input(unsigned char message_element);
50  void Input(char message_element);
51  SHA1& operator<<(const char* message_array);
52  SHA1& operator<<(const unsigned char* message_array);
53  SHA1& operator<<(const char message_element);
54  SHA1& operator<<(const unsigned char message_element);
55 
56  private:
57  /*
58  * Process the next 512 bits of the message
59  */
60  void ProcessMessageBlock();
61 
62  /*
63  * Pads the current message block to 512 bits
64  */
65  void PadMessage();
66 
67  /*
68  * Performs a circular left shift operation
69  */
70  inline unsigned CircularShift(int bits, unsigned word);
71 
72  unsigned H[5]; // Message digest buffers
73 
74  unsigned Length_Low; // Message length in bits
75  unsigned Length_High; // Message length in bits
76 
77  unsigned char Message_Block[64]; // 512-bit message blocks
78  int Message_Block_Index; // Index into message block array
79 
80  bool Computed; // Is the digest computed?
81  bool Corrupted; // Is the message digest corruped?
82  };
83 
84 } // end of namespace mf
85 
86 #endif /* cetlib_test_sha1_h */
87 
88 // Local Variables:
89 // mode: c++
90 // End:
unsigned Length_Low
Definition: sha1.h:74
unsigned Length_High
Definition: sha1.h:75
int Message_Block_Index
Definition: sha1.h:78
void Reset()
Definition: sha1.cpp:78
unsigned char Message_Block[64]
Definition: sha1.h:77
unsigned H[5]
Definition: sha1.h:72
void PadMessage()
Definition: sha1.cpp:490
unsigned CircularShift(int bits, unsigned word)
Definition: sha1.cpp:549
bool Computed
Definition: sha1.h:80
bool Corrupted
Definition: sha1.h:81
void Input(const unsigned char *message_array, unsigned length)
Definition: sha1.cpp:152
bool Result(unsigned *message_digest_array)
Definition: sha1.cpp:113
void ProcessMessageBlock()
Definition: sha1.cpp:386
SHA1 & operator<<(const char *message_array)
Definition: sha1.cpp:273
union ptb::content::word::word word