blob: 5451dfbfe5d6fd8754602c4a5ed54f02df4c12c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* Streebog
* (C) 2017 Ribose Inc.
*
* Botan is released under the Simplified BSD License (see license.txt)
*/
#ifndef BOTAN_STREEBOG_H__
#define BOTAN_STREEBOG_H__
#include <botan/hash.h>
namespace Botan {
/**
* Streebog (GOST R 34.11-2012)
* RFC 6986
*/
class BOTAN_DLL Streebog: public HashFunction
{
public:
size_t output_length() const override { return m_output_bits / 8; }
HashFunction* clone() const override { return new Streebog(m_output_bits); }
void clear() override;
std::string name() const override;
size_t hash_block_size() const override { return 64; };
std::unique_ptr<HashFunction> copy_state() const override;
Streebog(size_t output_bits);
protected:
void add_data(const uint8_t input[], size_t length) override;
void final_result(uint8_t out[]) override;
void compress(const uint8_t input[], bool lastblock = false);
private:
const size_t m_output_bits;
uint64_t m_count;
size_t m_position;
secure_vector<uint8_t> m_buffer;
secure_vector<uint64_t> m_h;
secure_vector<uint64_t> m_S;
};
/**
* Streebog-256
*/
class BOTAN_DLL Streebog_256 final : public Streebog
{
public:
Streebog_256() : Streebog(256) {}
};
/**
* Streebog-512
*/
class BOTAN_DLL Streebog_512 final : public Streebog
{
public:
Streebog_512() : Streebog(512) {}
};
}
#endif
|