5MP Motion Camera  1.1.1.1
A waterproof, low power, battery operated, motion activated, 5 mega-pixel, WiFi camera.
sha1.h
Go to the documentation of this file.
1 #ifndef Sha1_h
2 #define Sha1_h
3 
4 #include <inttypes.h>
5 #include "Print.h"
6 
7 #define HASH_LENGTH 20
8 #define BLOCK_LENGTH 64
9 
10 union _buffer {
11  uint8_t b[BLOCK_LENGTH];
12  uint32_t w[BLOCK_LENGTH/4];
13 };
14 union _state {
15  uint8_t b[HASH_LENGTH];
16  uint32_t w[HASH_LENGTH/4];
17 };
18 
19 class Sha1Class : public Print
20 {
21  public:
22  void init(void);
23  void initHmac(const uint8_t* secret, int secretLength);
24  uint8_t* result(void);
25  uint8_t* resultHmac(void);
26  virtual size_t write(uint8_t);
27  using Print::write;
28  private:
29  void pad();
30  void addUncounted(uint8_t data);
31  void hashBlock();
32  uint32_t rol32(uint32_t number, uint8_t bits);
34  uint8_t bufferOffset;
36  uint32_t byteCount;
37  uint8_t keyBuffer[BLOCK_LENGTH];
38  uint8_t innerHash[HASH_LENGTH];
39 
40 };
41 extern Sha1Class Sha1;
42 
43 #endif
Sha1Class Sha1
Definition: sha1.cpp:153
#define HASH_LENGTH
Definition: sha1.h:7
Definition: sha1.h:19
uint8_t bufferOffset
Definition: sha1.h:34
uint32_t byteCount
Definition: sha1.h:36
uint8_t b[BLOCK_LENGTH]
Definition: sha1.h:11
_buffer buffer
Definition: sha1.h:33
Definition: sha1.h:14
#define BLOCK_LENGTH
Definition: sha1.h:8
_state state
Definition: sha1.h:35
Definition: sha1.h:10
uint32_t w[BLOCK_LENGTH/4]
Definition: sha1.h:12