File indexing completed on 2025-01-18 09:55:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef CRYPTOPP_HC128_H
0015 #define CRYPTOPP_HC128_H
0016
0017 #include "strciphr.h"
0018 #include "secblock.h"
0019
0020 NAMESPACE_BEGIN(CryptoPP)
0021
0022
0023
0024 struct HC128Info : public FixedKeyLength<16, SimpleKeyingInterface::UNIQUE_IV, 16>
0025 {
0026 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "HC-128"; }
0027 };
0028
0029
0030
0031 class HC128Policy : public AdditiveCipherConcretePolicy<word32, 16>, public HC128Info
0032 {
0033 protected:
0034 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length);
0035 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
0036 void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length);
0037 bool CanOperateKeystream() const { return true; }
0038 bool CipherIsRandomAccess() const { return false; }
0039
0040 void GenerateKeystream(word32* keystream);
0041 void SetupUpdate();
0042
0043 private:
0044 FixedSizeSecBlock<word32, 16> m_X;
0045 FixedSizeSecBlock<word32, 16> m_Y;
0046 FixedSizeSecBlock<word32, 8> m_key;
0047 FixedSizeSecBlock<word32, 8> m_iv;
0048 word32 m_T[1024];
0049 word32 m_ctr;
0050 };
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct HC128 : public HC128Info, public SymmetricCipherDocumentation
0060 {
0061 typedef SymmetricCipherFinal<ConcretePolicyHolder<HC128Policy, AdditiveCipherTemplate<> >, HC128Info> Encryption;
0062 typedef Encryption Decryption;
0063 };
0064
0065 NAMESPACE_END
0066
0067 #endif