Security Scol plugin
sm4.h
Go to the documentation of this file.
1// sm4.h - written and placed in the public domain by Jeffrey Walton and Han Lulu
2
13
14#ifndef CRYPTOPP_SM4_H
15#define CRYPTOPP_SM4_H
16
17#include "config.h"
18#include "seckey.h"
19#include "secblock.h"
20
21#if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86)
22# ifndef CRYPTOPP_DISABLE_SM4_SIMD
23# define CRYPTOPP_SM4_ADVANCED_PROCESS_BLOCKS 1
24# endif
25#endif
26
27NAMESPACE_BEGIN(CryptoPP)
28
29
31struct SM4_Info : public FixedBlockSize<16>, FixedKeyLength<16>
32{
33 static const std::string StaticAlgorithmName()
34 {
35 return "SM4";
36 }
37};
38
44class CRYPTOPP_NO_VTABLE SM4 : public SM4_Info, public BlockCipherDocumentation
45{
46public:
50 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SM4_Info>
51 {
52 protected:
53 void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs &params);
54
57 };
58
66 class CRYPTOPP_NO_VTABLE Enc : public Base
67 {
68 public:
69 std::string AlgorithmProvider() const;
70 protected:
71 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
72#if CRYPTOPP_SM4_ADVANCED_PROCESS_BLOCKS
73 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
74#endif
75 };
76
84 class CRYPTOPP_NO_VTABLE Dec : public Base
85 {
86 protected:
87 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
88 };
89
92};
93
94NAMESPACE_END
95
96#endif // CRYPTOPP_SM4_H
Provides class member functions to key a block cipher.
Definition seckey.h:318
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition seckey.h:306
Inherited by algorithms with fixed block size.
Definition seckey.h:41
Inherited by keyed algorithms with fixed key length.
Definition seckey.h:125
Interface for retrieving values given their names.
Definition cryptlib.h:322
SM4 block cipher transformation functions.
Definition sm4.h:51
Decryption transformation.
Definition sm4.h:85
Encryption transformation.
Definition sm4.h:67
Classes for the SM4 block cipher.
Definition sm4.h:45
Secure memory block with allocator and cleanup.
Definition secblock.h:731
Library configuration file.
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition seckey.h:399
BlockCipher Decryption
implements the BlockCipher interface
Definition seckey.h:403
BlockCipher Encryption
implements the BlockCipher interface
Definition seckey.h:401
SM4 block cipher information.
Definition sm4.h:32