Coverage Report

Created: 2020-08-01 06:18

/src/botan/build/include/botan/skein_512.h
Line
Count
Source (jump to first uncovered line)
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
BOTAN_FUTURE_INTERNAL_HEADER(skin_512.h)
17
18
namespace Botan {
19
20
/**
21
* Skein-512, a SHA-3 candidate
22
*/
23
class BOTAN_PUBLIC_API(2,0) Skein_512 final : public HashFunction
24
   {
25
   public:
26
      /**
27
      * @param output_bits the output size of Skein in bits
28
      * @param personalization is a string that will parameterize the
29
      * hash output
30
      */
31
      Skein_512(size_t output_bits = 512,
32
                const std::string& personalization = "");
33
34
0
      size_t hash_block_size() const override { return 64; }
35
0
      size_t output_length() const override { return m_output_bits / 8; }
36
37
      HashFunction* clone() const override;
38
      std::unique_ptr<HashFunction> copy_state() const override;
39
      std::string name() const override;
40
      void clear() override;
41
   private:
42
      enum type_code {
43
         SKEIN_KEY = 0,
44
         SKEIN_CONFIG = 4,
45
         SKEIN_PERSONALIZATION = 8,
46
         SKEIN_PUBLIC_KEY = 12,
47
         SKEIN_KEY_IDENTIFIER = 16,
48
         SKEIN_NONCE = 20,
49
         SKEIN_MSG = 48,
50
         SKEIN_OUTPUT = 63
51
      };
52
53
      void add_data(const uint8_t input[], size_t length) override;
54
      void final_result(uint8_t out[]) override;
55
56
      void ubi_512(const uint8_t msg[], size_t msg_len);
57
58
      void initial_block();
59
      void reset_tweak(type_code type, bool is_final);
60
61
      std::string m_personalization;
62
      size_t m_output_bits;
63
64
      std::unique_ptr<Threefish_512> m_threefish;
65
      secure_vector<uint64_t> m_T;
66
      secure_vector<uint8_t> m_buffer;
67
      size_t m_buf_pos;
68
   };
69
70
}
71
72
#endif