Botan  2.7.0
Crypto and TLS for C++11
skein_512.h
Go to the documentation of this file.
1 /*
2 * The Skein-512 hash function
3 * (C) 2009,2014 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_SKEIN_512_H_
9 #define BOTAN_SKEIN_512_H_
10 
11 #include <botan/hash.h>
12 #include <botan/threefish_512.h>
13 #include <string>
14 #include <memory>
15 
16 namespace Botan {
17 
18 /**
19 * Skein-512, a SHA-3 candidate
20 */
21 class BOTAN_PUBLIC_API(2,0) Skein_512 final : public HashFunction
22  {
23  public:
24  /**
25  * @param output_bits the output size of Skein in bits
26  * @param personalization is a string that will parameterize the
27  * hash output
28  */
29  Skein_512(size_t output_bits = 512,
30  const std::string& personalization = "");
31 
32  size_t hash_block_size() const override { return 64; }
33  size_t output_length() const override { return m_output_bits / 8; }
34 
35  HashFunction* clone() const override;
36  std::unique_ptr<HashFunction> copy_state() const override;
37  std::string name() const override;
38  void clear() override;
39  private:
40  enum type_code {
41  SKEIN_KEY = 0,
42  SKEIN_CONFIG = 4,
43  SKEIN_PERSONALIZATION = 8,
44  SKEIN_PUBLIC_KEY = 12,
45  SKEIN_KEY_IDENTIFIER = 16,
46  SKEIN_NONCE = 20,
47  SKEIN_MSG = 48,
48  SKEIN_OUTPUT = 63
49  };
50 
51  void add_data(const uint8_t input[], size_t length) override;
52  void final_result(uint8_t out[]) override;
53 
54  void ubi_512(const uint8_t msg[], size_t msg_len);
55 
56  void initial_block();
57  void reset_tweak(type_code type, bool is_final);
58 
59  std::string m_personalization;
60  size_t m_output_bits;
61 
62  std::unique_ptr<Threefish_512> m_threefish;
63  secure_vector<uint64_t> m_T;
64  secure_vector<uint8_t> m_buffer;
65  size_t m_buf_pos;
66  };
67 
68 }
69 
70 #endif
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:27
size_t hash_block_size() const override
Definition: skein_512.h:32
MechanismType type
Definition: alg_id.cpp:13
size_t output_length() const override
Definition: skein_512.h:33