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_HC256_H
0015 #define CRYPTOPP_HC256_H
0016
0017 #include "strciphr.h"
0018 #include "secblock.h"
0019
0020 NAMESPACE_BEGIN(CryptoPP)
0021
0022
0023
0024 struct HC256Info : public FixedKeyLength<32, SimpleKeyingInterface::UNIQUE_IV, 32>
0025 {
0026 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "HC-256"; }
0027 };
0028
0029
0030
0031 class HC256Policy : public AdditiveCipherConcretePolicy<word32, 4>, public HC256Info
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 word32 H1(word32 u);
0041 word32 H2(word32 u);
0042
0043 void GenerateKeystream(word32* keystream);
0044 word32 Generate();
0045
0046 private:
0047 FixedSizeSecBlock<word32, 8> m_key;
0048 FixedSizeSecBlock<word32, 8> m_iv;
0049 word32 m_P[1024];
0050 word32 m_Q[1024];
0051 word32 m_ctr;
0052 };
0053
0054
0055
0056
0057
0058
0059
0060
0061 struct HC256 : public HC256Info, public SymmetricCipherDocumentation
0062 {
0063 typedef SymmetricCipherFinal<ConcretePolicyHolder<HC256Policy, AdditiveCipherTemplate<> >, HC256Info> Encryption;
0064 typedef Encryption Decryption;
0065 };
0066
0067 NAMESPACE_END
0068
0069 #endif