File indexing completed on 2025-01-18 09:55:10
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_TWOFISH_H
0007 #define CRYPTOPP_TWOFISH_H
0008
0009 #include "seckey.h"
0010 #include "secblock.h"
0011
0012 NAMESPACE_BEGIN(CryptoPP)
0013
0014
0015
0016 struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, FixedRounds<16>
0017 {
0018 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Twofish";}
0019 };
0020
0021
0022
0023
0024 class Twofish : public Twofish_Info, public BlockCipherDocumentation
0025 {
0026 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Twofish_Info>
0027 {
0028 public:
0029 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
0030
0031 protected:
0032 static word32 h0(word32 x, const word32 *key, unsigned int kLen);
0033 static word32 h(word32 x, const word32 *key, unsigned int kLen);
0034
0035 static const byte q[2][256];
0036 static const word32 mds[4][256];
0037
0038 FixedSizeSecBlock<word32, 40> m_k;
0039 FixedSizeSecBlock<word32, 4*256> m_s;
0040 };
0041
0042 class CRYPTOPP_NO_VTABLE Enc : public Base
0043 {
0044 public:
0045 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0046 };
0047
0048 class CRYPTOPP_NO_VTABLE Dec : public Base
0049 {
0050 public:
0051 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0052 };
0053
0054 public:
0055 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0056 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0057 };
0058
0059 typedef Twofish::Encryption TwofishEncryption;
0060 typedef Twofish::Decryption TwofishDecryption;
0061
0062 NAMESPACE_END
0063
0064 #endif