ice40: split out cells_map.v into ff_map.v
[yosys.git] / libs / sha1 / sha1.h
1 /*
2 sha1.h - header of
3
4 ============
5 SHA-1 in C++
6 ============
7
8 100% Public Domain.
9
10 Original C Code
11 -- Steve Reid <steve@edmweb.com>
12 Small changes to fit into bglibs
13 -- Bruce Guenter <bruce@untroubled.org>
14 Translation to simpler C++ Code
15 -- Volker Grabsch <vog@notjusthosting.com>
16 Fixing bugs and improving style
17 -- Eugene Hopkinson <slowriot at voxelstorm dot com>
18 */
19
20 #ifndef SHA1_HPP
21 #define SHA1_HPP
22
23
24 #include <iostream>
25 #include <string>
26 #include <stdint.h>
27
28 class SHA1
29 {
30 public:
31 SHA1();
32 void update(const std::string &s);
33 void update(std::istream &is);
34 std::string final();
35 static std::string from_file(const std::string &filename);
36
37 private:
38 static constexpr unsigned int DIGEST_INTS = 5; /* number of 32bit integers per SHA1 digest */
39 static constexpr unsigned int BLOCK_INTS = 16; /* number of 32bit integers per SHA1 block */
40 static constexpr unsigned int BLOCK_BYTES = BLOCK_INTS * 4;
41
42 uint32_t digest[DIGEST_INTS];
43 std::string buffer;
44 uint64_t transforms;
45
46 void reset();
47 void transform(uint32_t block[BLOCK_BYTES]);
48
49 static void read(std::istream &is, std::string &s, size_t max);
50 static void buffer_to_block(const std::string &buffer, uint32_t block[BLOCK_INTS]);
51 };
52
53 std::string sha1(const std::string &string);
54
55
56
57 #endif /* SHA1_HPP */