Mercurial > hg > orthanc
comparison Resources/sha1/sha1.h @ 177:81b6f3013738
sha1
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Nov 2012 10:42:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
176:81f11fb357f2 | 177:81b6f3013738 |
---|---|
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 _SHA1_H_ | |
25 #define _SHA1_H_ | |
26 | |
27 class SHA1 | |
28 { | |
29 | |
30 public: | |
31 | |
32 SHA1(); | |
33 virtual ~SHA1(); | |
34 | |
35 /* | |
36 * Re-initialize the class | |
37 */ | |
38 void Reset(); | |
39 | |
40 /* | |
41 * Returns the message digest | |
42 */ | |
43 bool Result(unsigned *message_digest_array); | |
44 | |
45 /* | |
46 * Provide input to SHA1 | |
47 */ | |
48 void Input( const unsigned char *message_array, | |
49 unsigned length); | |
50 void Input( const char *message_array, | |
51 unsigned length); | |
52 void Input(unsigned char message_element); | |
53 void Input(char message_element); | |
54 SHA1& operator<<(const char *message_array); | |
55 SHA1& operator<<(const unsigned char *message_array); | |
56 SHA1& operator<<(const char message_element); | |
57 SHA1& operator<<(const unsigned char message_element); | |
58 | |
59 private: | |
60 | |
61 /* | |
62 * Process the next 512 bits of the message | |
63 */ | |
64 void ProcessMessageBlock(); | |
65 | |
66 /* | |
67 * Pads the current message block to 512 bits | |
68 */ | |
69 void PadMessage(); | |
70 | |
71 /* | |
72 * Performs a circular left shift operation | |
73 */ | |
74 inline unsigned CircularShift(int bits, unsigned word); | |
75 | |
76 unsigned H[5]; // Message digest buffers | |
77 | |
78 unsigned Length_Low; // Message length in bits | |
79 unsigned Length_High; // Message length in bits | |
80 | |
81 unsigned char Message_Block[64]; // 512-bit message blocks | |
82 int Message_Block_Index; // Index into message block array | |
83 | |
84 bool Computed; // Is the digest computed? | |
85 bool Corrupted; // Is the message digest corruped? | |
86 | |
87 }; | |
88 | |
89 #endif |