/src/botan/build/include/botan/internal/sha160.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * SHA-160 |
3 | | * (C) 1999-2007,2016 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_SHA_160_H_ |
9 | | #define BOTAN_SHA_160_H_ |
10 | | |
11 | | #include <botan/internal/mdx_hash.h> |
12 | | |
13 | | namespace Botan { |
14 | | |
15 | | /** |
16 | | * NIST's SHA-160 |
17 | | */ |
18 | | class SHA_160 final : public MDx_HashFunction |
19 | | { |
20 | | public: |
21 | 580 | std::string name() const override { return "SHA-160"; } |
22 | 54.1k | size_t output_length() const override { return 20; } |
23 | 0 | std::unique_ptr<HashFunction> new_object() const override { return std::make_unique<SHA_160>(); } |
24 | | std::unique_ptr<HashFunction> copy_state() const override; |
25 | | |
26 | | void clear() override; |
27 | | |
28 | | SHA_160() : MDx_HashFunction(64, true, true), m_digest(5) |
29 | 17.9k | { |
30 | 17.9k | clear(); |
31 | 17.9k | } |
32 | | |
33 | | private: |
34 | | void compress_n(const uint8_t[], size_t blocks) override; |
35 | | |
36 | | #if defined(BOTAN_HAS_SHA1_ARMV8) |
37 | | static void sha1_armv8_compress_n(secure_vector<uint32_t>& digest, |
38 | | const uint8_t blocks[], |
39 | | size_t block_count); |
40 | | #endif |
41 | | |
42 | | #if defined(BOTAN_HAS_SHA1_SSE2) |
43 | | static void sse2_compress_n(secure_vector<uint32_t>& digest, |
44 | | const uint8_t blocks[], |
45 | | size_t block_count); |
46 | | #endif |
47 | | |
48 | | #if defined(BOTAN_HAS_SHA1_X86_SHA_NI) |
49 | | // Using x86 SHA instructions in Intel Goldmont and Cannonlake |
50 | | static void sha1_compress_x86(secure_vector<uint32_t>& digest, |
51 | | const uint8_t blocks[], |
52 | | size_t block_count); |
53 | | #endif |
54 | | |
55 | | |
56 | | void copy_out(uint8_t[]) override; |
57 | | |
58 | | /** |
59 | | * The digest value |
60 | | */ |
61 | | secure_vector<uint32_t> m_digest; |
62 | | |
63 | | /** |
64 | | * The message buffer |
65 | | */ |
66 | | secure_vector<uint32_t> m_W; |
67 | | }; |
68 | | |
69 | | typedef SHA_160 SHA_1; |
70 | | |
71 | | } |
72 | | |
73 | | #endif |