Botan 2.19.2
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/threefish_512.h>
13#include <string>
14#include <memory>
15
17
18namespace Botan {
19
20/**
21* Skein-512, a SHA-3 candidate
22*/
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 size_t hash_block_size() const override { return 64; }
35 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
virtual HashFunction * clone() const =0
virtual std::unique_ptr< HashFunction > copy_state() const =0
virtual std::string name() const =0
virtual void clear()=0
size_t hash_block_size() const override
Definition: skein_512.h:34
size_t output_length() const override
Definition: skein_512.h:35
int(* final)(unsigned char *, CTX *)
#define BOTAN_PUBLIC_API(maj, min)
Definition: compiler.h:31
#define BOTAN_FUTURE_INTERNAL_HEADER(hdr)
Definition: compiler.h:136
Definition: alg_id.cpp:13
MechanismType type