Botan 3.6.1
Crypto and TLS for C&
sha3.h
Go to the documentation of this file.
1/*
2* SHA-3
3* (C) 2010,2016 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_SHA3_H_
9#define BOTAN_SHA3_H_
10
11#include <botan/hash.h>
12#include <botan/secmem.h>
13#include <botan/internal/keccak_perm.h>
14#include <string>
15
16namespace Botan {
17
18/**
19* SHA-3
20*/
21class SHA_3 : public HashFunction {
22 public:
23 /**
24 * @param output_bits the size of the hash output; must be one of
25 * 224, 256, 384, or 512
26 */
27 explicit SHA_3(size_t output_bits);
28
29 size_t hash_block_size() const override { return m_keccak.byte_rate(); }
30
31 size_t output_length() const override { return m_output_length; }
32
33 std::unique_ptr<HashFunction> new_object() const override;
34 std::unique_ptr<HashFunction> copy_state() const override;
35 std::string name() const override;
36 void clear() override;
37 std::string provider() const override;
38
39 private:
40 void add_data(std::span<const uint8_t> input) override;
41 void final_result(std::span<uint8_t> out) override;
42
43 private:
44 Keccak_Permutation m_keccak;
45 size_t m_output_length;
46};
47
48/**
49* SHA-3-224
50*/
51class SHA_3_224 final : public SHA_3 {
52 public:
53 SHA_3_224() : SHA_3(224) {}
54};
55
56/**
57* SHA-3-256
58*/
59class SHA_3_256 final : public SHA_3 {
60 public:
61 SHA_3_256() : SHA_3(256) {}
62};
63
64/**
65* SHA-3-384
66*/
67class SHA_3_384 final : public SHA_3 {
68 public:
69 SHA_3_384() : SHA_3(384) {}
70};
71
72/**
73* SHA-3-512
74*/
75class SHA_3_512 final : public SHA_3 {
76 public:
77 SHA_3_512() : SHA_3(512) {}
78};
79
80} // namespace Botan
81
82#endif
size_t byte_rate() const
Definition keccak_perm.h:55
void clear() override
Definition sha3.cpp:42
SHA_3(size_t output_bits)
Definition sha3.cpp:18
size_t hash_block_size() const override
Definition sha3.h:29
std::unique_ptr< HashFunction > new_object() const override
Definition sha3.cpp:38
std::string provider() const override
Definition sha3.cpp:30
std::string name() const override
Definition sha3.cpp:26
size_t output_length() const override
Definition sha3.h:31
std::unique_ptr< HashFunction > copy_state() const override
Definition sha3.cpp:34
int(* final)(unsigned char *, CTX *)