• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 6253464532

19 Sep 2023 12:06AM UTC coverage: 91.748% (+0.02%) from 91.726%
6253464532

push

github

web-flow
Merge pull request #3693 from Rohde-Schwarz/refactor/alignment_buffer

Refactor: AlignmentBuffer<> helper for block-oriented Hashes

79472 of 86620 relevant lines covered (91.75%)

8492168.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/lib/hash/skein/skein_512.h
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/internal/alignment_buffer.h>
13
#include <botan/internal/threefish_512.h>
14

15
#include <memory>
16
#include <string>
17

18
namespace Botan {
19

20
/**
21
* Skein-512, a SHA-3 candidate
22
*/
23
class Skein_512 final : public HashFunction {
×
24
   public:
25
      /**
26
      * @param output_bits the output size of Skein in bits
27
      * @param personalization is a string that will parameterize the
28
      * hash output
29
      */
30
      Skein_512(size_t output_bits = 512, std::string_view personalization = "");
31

32
      size_t hash_block_size() const override { return 64; }
2,074✔
33

34
      size_t output_length() const override { return m_output_bits / 8; }
8,242✔
35

36
      std::unique_ptr<HashFunction> new_object() const override;
37
      std::unique_ptr<HashFunction> copy_state() const override;
38
      std::string name() const override;
39
      void clear() override;
40

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(std::span<const uint8_t> input) override;
54
      void final_result(std::span<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
      AlignmentBuffer<uint8_t, 64, AlignmentBufferFinalBlock::must_be_deferred> m_buffer;
67
};
68

69
}  // namespace Botan
70

71
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc