File indexing completed on 2025-01-18 09:55:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef CRYPTOPP_LEA_H
0011 #define CRYPTOPP_LEA_H
0012
0013 #include "config.h"
0014 #include "seckey.h"
0015 #include "secblock.h"
0016 #include "algparam.h"
0017
0018 #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_ARM32 || CRYPTOPP_BOOL_ARMV8)
0019 # ifndef CRYPTOPP_DISABLE_LEA_SIMD
0020 # define CRYPTOPP_LEA_ADVANCED_PROCESS_BLOCKS 1
0021 # endif
0022 #endif
0023
0024
0025
0026 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5120)
0027 # undef CRYPTOPP_LEA_ADVANCED_PROCESS_BLOCKS
0028 #endif
0029
0030 NAMESPACE_BEGIN(CryptoPP)
0031
0032
0033
0034 struct LEA_Info : public FixedBlockSize<16>, public VariableKeyLength<16,16,32,8>
0035 {
0036
0037
0038
0039
0040 static const std::string StaticAlgorithmName()
0041 {
0042
0043 return "LEA-128";
0044 }
0045 };
0046
0047
0048
0049
0050
0051
0052
0053
0054 class CRYPTOPP_NO_VTABLE LEA : public LEA_Info, public BlockCipherDocumentation
0055 {
0056 public:
0057
0058
0059
0060 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<LEA_Info>
0061 {
0062 protected:
0063 void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms);
0064 std::string AlgorithmProvider() const;
0065
0066 SecBlock<word32> m_rkey;
0067 mutable SecBlock<word32> m_temp;
0068 unsigned int m_rounds;
0069 };
0070
0071
0072
0073
0074
0075 class CRYPTOPP_NO_VTABLE Enc : public Base
0076 {
0077 public:
0078 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0079
0080 #if CRYPTOPP_LEA_ADVANCED_PROCESS_BLOCKS
0081 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
0082 #endif
0083 };
0084
0085
0086
0087
0088
0089 class CRYPTOPP_NO_VTABLE Dec : public Base
0090 {
0091 public:
0092 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0093
0094 #if CRYPTOPP_LEA_ADVANCED_PROCESS_BLOCKS
0095 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
0096 #endif
0097 };
0098
0099 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0100 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0101 };
0102
0103 typedef LEA::Encryption LEAEncryption;
0104 typedef LEA::Decryption LEADecryption;
0105
0106 NAMESPACE_END
0107
0108 #endif