Botan 3.6.1
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 <string>
17
18namespace Botan {
19
20/**
21* Skein-512, a SHA-3 candidate
22*/
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; }
33
34 size_t output_length() const override { return m_output_bits / 8; }
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;
66 AlignmentBuffer<uint8_t, 64, AlignmentBufferFinalBlock::must_be_deferred> m_buffer;
67};
68
69} // namespace Botan
70
71#endif
size_t hash_block_size() const override
Definition skein_512.h:32
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:34
Skein_512(size_t output_bits=512, std::string_view personalization="")
Definition skein_512.cpp:18
void clear() override
Definition skein_512.cpp:50
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61