Botan 3.9.0
Crypto and TLS for C&
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/internal/alignment_buffer.h>
13#include <botan/internal/threefish_512.h>
14
15#include <memory>
16#include <span>
17#include <string>
18
19namespace Botan {
20
21/**
22* Skein-512, a SHA-3 candidate
23*/
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 explicit Skein_512(size_t output_bits = 512, std::string_view personalization = "");
32
33 size_t hash_block_size() const override { return 64; }
34
35 size_t output_length() const override { return m_output_bits / 8; }
36
37 std::unique_ptr<HashFunction> new_object() const override;
38 std::unique_ptr<HashFunction> copy_state() const override;
39 std::string name() const override;
40 void clear() override;
41
42 private:
43 enum type_code : uint8_t {
44 SKEIN_KEY = 0,
45 SKEIN_CONFIG = 4,
46 SKEIN_PERSONALIZATION = 8,
47 SKEIN_PUBLIC_KEY = 12,
48 SKEIN_KEY_IDENTIFIER = 16,
49 SKEIN_NONCE = 20,
50 SKEIN_MSG = 48,
51 SKEIN_OUTPUT = 63
52 };
53
54 void add_data(std::span<const uint8_t> input) override;
55 void final_result(std::span<uint8_t> out) override;
56
57 void ubi_512(std::span<const uint8_t> msg);
58
59 void ubi_512(const uint8_t msg[], size_t length) { ubi_512({msg, length}); }
60
61 void initial_block();
62 void reset_tweak(type_code type, bool is_final);
63
64 std::string m_personalization;
65 size_t m_output_bits;
66
67 std::unique_ptr<Threefish_512> m_threefish;
69 AlignmentBuffer<uint8_t, 64, AlignmentBufferFinalBlock::must_be_deferred> m_buffer;
70};
71
72} // namespace Botan
73
74#endif
void final(uint8_t out[])
Definition buf_comp.h:69
size_t hash_block_size() const override
Definition skein_512.h:33
std::unique_ptr< HashFunction > copy_state() const override
Definition skein_512.cpp:42
std::unique_ptr< HashFunction > new_object() const override
Definition skein_512.cpp:38
std::string name() const override
Definition skein_512.cpp:30
size_t output_length() const override
Definition skein_512.h:35
Skein_512(size_t output_bits=512, std::string_view personalization="")
Definition skein_512.cpp:18
void clear() override
Definition skein_512.cpp:50
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:69