Botan 3.4.0
Crypto and TLS for C&
sm3.h
Go to the documentation of this file.
1/*
2* SM3
3* (C) 2017 Ribose Inc.
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_SM3_H_
9#define BOTAN_SM3_H_
10
11#include <botan/internal/mdx_hash.h>
12
13namespace Botan {
14
15/**
16* SM3
17*/
18class SM3 final : public HashFunction {
19 public:
21
24 static constexpr size_t block_bytes = 64;
25 static constexpr size_t output_bytes = 32;
26 static constexpr size_t ctr_bytes = 8;
27
28 static void compress_n(digest_type& digest, std::span<const uint8_t> input, size_t blocks);
29 static void init(digest_type& digest);
30
31 public:
32 std::string name() const override { return "SM3"; }
33
34 size_t output_length() const override { return output_bytes; }
35
36 size_t hash_block_size() const override { return block_bytes; }
37
38 std::unique_ptr<HashFunction> new_object() const override;
39
40 std::unique_ptr<HashFunction> copy_state() const override;
41
42 void clear() override { m_md.clear(); }
43
44 private:
45 void add_data(std::span<const uint8_t> input) override;
46
47 void final_result(std::span<uint8_t> output) override;
48
49 private:
51};
52
53} // namespace Botan
54
55#endif
std::unique_ptr< HashFunction > copy_state() const override
Definition sm3.cpp:244
size_t hash_block_size() const override
Definition sm3.h:36
void clear() override
Definition sm3.h:42
static constexpr MD_Endian byte_endianness
Definition sm3.h:22
std::string name() const override
Definition sm3.h:32
std::unique_ptr< HashFunction > new_object() const override
Definition sm3.cpp:240
static constexpr MD_Endian bit_endianness
Definition sm3.h:23
size_t output_length() const override
Definition sm3.h:34
secure_vector< uint32_t > digest_type
Definition sm3.h:20
static constexpr size_t block_bytes
Definition sm3.h:24
static void compress_n(digest_type &digest, std::span< const uint8_t > input, size_t blocks)
Definition sm3.cpp:81
static constexpr size_t output_bytes
Definition sm3.h:25
static constexpr size_t ctr_bytes
Definition sm3.h:26
int(* init)(CTX *)
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61
MD_Endian
Definition mdx_hash.h:20