Botan 3.6.1
Crypto and TLS for C&
sm4.h
Go to the documentation of this file.
1/*
2* SM4
3* (C) 2017 Ribose Inc
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_SM4_H_
9#define BOTAN_SM4_H_
10
11#include <botan/block_cipher.h>
12
13namespace Botan {
14
15/**
16* SM4
17*/
18class SM4 final : public Block_Cipher_Fixed_Params<16, 16> {
19 public:
20 void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
21 void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override;
22
23 void clear() override;
24
25 std::string name() const override { return "SM4"; }
26
27 std::unique_ptr<BlockCipher> new_object() const override { return std::make_unique<SM4>(); }
28
29 std::string provider() const override;
30 size_t parallelism() const override;
31 bool has_keying_material() const override;
32
33 private:
34 void key_schedule(std::span<const uint8_t> key) override;
35
36#if defined(BOTAN_HAS_SM4_ARMV8)
37 void sm4_armv8_encrypt(const uint8_t in[], uint8_t out[], size_t blocks) const;
38 void sm4_armv8_decrypt(const uint8_t in[], uint8_t out[], size_t blocks) const;
39#endif
40
41#if defined(BOTAN_HAS_SM4_GFNI)
42 void sm4_gfni_encrypt(const uint8_t in[], uint8_t out[], size_t blocks) const;
43 void sm4_gfni_decrypt(const uint8_t in[], uint8_t out[], size_t blocks) const;
44#endif
45
47};
48
49} // namespace Botan
50
51#endif
std::string name() const override
Definition sm4.h:25
std::string provider() const override
Definition sm4.cpp:342
size_t parallelism() const override
Definition sm4.cpp:326
void decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
Definition sm4.cpp:228
bool has_keying_material() const override
Definition sm4.cpp:292
void encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const override
Definition sm4.cpp:161
std::unique_ptr< BlockCipher > new_object() const override
Definition sm4.h:27
void clear() override
Definition sm4.cpp:322
int(* final)(unsigned char *, CTX *)
std::vector< T, secure_allocator< T > > secure_vector
Definition secmem.h:61