Botan  2.11.0
Crypto and TLS for C++11
streebog.h
Go to the documentation of this file.
1 /*
2 * Streebog
3 * (C) 2017 Ribose Inc.
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_STREEBOG_H_
9 #define BOTAN_STREEBOG_H_
10 
11 #include <botan/hash.h>
12 
13 namespace Botan {
14 
15 /**
16 * Streebog (GOST R 34.11-2012)
17 * RFC 6986
18 */
20  {
21  public:
22  size_t output_length() const override { return m_output_bits / 8; }
23 
24  HashFunction* clone() const override { return new Streebog(m_output_bits); }
25  void clear() override;
26  std::string name() const override;
27  size_t hash_block_size() const override { return 64; }
28 
29  std::unique_ptr<HashFunction> copy_state() const override;
30 
31  explicit Streebog(size_t output_bits);
32  protected:
33  void add_data(const uint8_t input[], size_t length) override;
34  void final_result(uint8_t out[]) override;
35 
36  void compress(const uint8_t input[], bool lastblock = false);
37 
38  void compress_64(const uint64_t input[], bool lastblock = false);
39 
40  private:
41  const size_t m_output_bits;
42  uint64_t m_count;
43  size_t m_position;
44  secure_vector<uint8_t> m_buffer;
47  };
48 
49 
50 /**
51 * Streebog-256
52 */
54  {
55  public:
56  Streebog_256() : Streebog(256) {}
57  };
58 
59 /**
60 * Streebog-512
61 */
63  {
64  public:
65  Streebog_512() : Streebog(512) {}
66  };
67 
68 }
69 
70 #endif
HashFunction * clone() const override
Definition: streebog.h:24
size_t output_length() const override
Definition: streebog.h:22
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
std::string name
size_t hash_block_size() const override
Definition: streebog.h:27
Definition: alg_id.cpp:13
std::vector< T, secure_allocator< T > > secure_vector
Definition: secmem.h:65