|
||||
File indexing completed on 2025-01-18 09:55:08
0001 // rabbit.h - written and placed in the public domain by Jeffrey Walton 0002 // based on public domain code by Martin Boesgaard, Mette Vesterager, 0003 // Thomas Pedersen, Jesper Christiansen and Ove Scavenius. 0004 // 0005 // The reference materials and source files are available at 0006 // The eSTREAM Project, http://www.ecrypt.eu.org/stream/e2-rabbit.html. 0007 0008 /// \file rabbit.h 0009 /// \brief Classes for Rabbit stream cipher 0010 /// \sa <A HREF="http://www.ecrypt.eu.org/stream/e2-rabbit.html">The 0011 /// eSTREAM Project | Rabbit</A> and 0012 /// <A HREF="https://www.cryptopp.com/wiki/Rabbit">Crypto++ Wiki | Rabbit</A>. 0013 /// \since Crypto++ 8.0 0014 0015 #ifndef CRYPTOPP_RABBIT_H 0016 #define CRYPTOPP_RABBIT_H 0017 0018 #include "strciphr.h" 0019 #include "secblock.h" 0020 0021 // The library does not have a way to describe an optional IV. Rabbit takes 0022 // an optional IV so two classes are offered to bridge the gap. One provides 0023 // Rabbit without an IV and the second provides Rabbit with an IV. 0024 0025 NAMESPACE_BEGIN(CryptoPP) 0026 0027 /// \brief Rabbit stream cipher information 0028 /// \since Crypto++ 8.0 0029 struct RabbitInfo : public FixedKeyLength<16, SimpleKeyingInterface::NOT_RESYNCHRONIZABLE> 0030 { 0031 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "Rabbit"; } 0032 }; 0033 0034 /// \brief Rabbit stream cipher information 0035 /// \since Crypto++ 8.0 0036 struct RabbitWithIVInfo : public FixedKeyLength<16, SimpleKeyingInterface::UNIQUE_IV, 8> 0037 { 0038 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "RabbitWithIV"; } 0039 }; 0040 0041 /// \brief Rabbit stream cipher implementation 0042 /// \since Crypto++ 8.0 0043 class RabbitPolicy : public AdditiveCipherConcretePolicy<word32, 4>, public RabbitInfo 0044 { 0045 protected: 0046 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); 0047 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); 0048 bool CanOperateKeystream() const { return true; } 0049 bool CipherIsRandomAccess() const { return false; } 0050 0051 private: 0052 // Master and working states 0053 FixedSizeSecBlock<word32, 8> m_mx, m_mc, m_wx, m_wc; 0054 // Workspace 0055 FixedSizeSecBlock<word32, 12> m_t; 0056 word32 m_mcy, m_wcy; // carry 0057 }; 0058 0059 /// \brief Rabbit stream cipher implementation 0060 /// \since Crypto++ 8.0 0061 class RabbitWithIVPolicy : public AdditiveCipherConcretePolicy<word32, 4>, public RabbitWithIVInfo 0062 { 0063 protected: 0064 void CipherSetKey(const NameValuePairs ¶ms, const byte *key, size_t length); 0065 void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); 0066 void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); 0067 bool CanOperateKeystream() const { return true; } 0068 bool CipherIsRandomAccess() const { return false; } 0069 0070 private: 0071 // Master and working states 0072 FixedSizeSecBlock<word32, 8> m_mx, m_mc, m_wx, m_wc; 0073 // Workspace 0074 FixedSizeSecBlock<word32, 12> m_t; 0075 word32 m_mcy, m_wcy; // carry 0076 }; 0077 0078 /// \brief Rabbit stream cipher 0079 /// \details Rabbit is a stream cipher developed by Martin Boesgaard, Mette Vesterager, 0080 /// Thomas Pedersen, Jesper Christiansen and Ove Scavenius. Rabbit is one of the final four 0081 /// Profile 1 (software) ciphers selected for the eSTREAM portfolio. 0082 /// \details Crypto++ provides Rabbit and RabbitWithIV classes. Two classes are necessary 0083 /// because the library lacks the means to describe and manage optional IVs. 0084 /// \sa RabbitWithIV, <A HREF="http://www.ecrypt.eu.org/stream/e2-rabbit.html">The 0085 /// eSTREAM Project | Rabbit</A> and 0086 /// <A HREF="https://www.cryptopp.com/wiki/Rabbit">Crypto++ Wiki | Rabbit</A>. 0087 /// \since Crypto++ 8.0 0088 struct Rabbit : public RabbitInfo, public SymmetricCipherDocumentation 0089 { 0090 typedef SymmetricCipherFinal<ConcretePolicyHolder<RabbitPolicy, AdditiveCipherTemplate<> >, RabbitInfo> Encryption; 0091 typedef Encryption Decryption; 0092 }; 0093 0094 /// \brief Rabbit stream cipher 0095 /// \details Rabbit is a stream cipher developed by Martin Boesgaard, Mette Vesterager, 0096 /// Thomas Pedersen, Jesper Christiansen and Ove Scavenius. Rabbit is one of the final four 0097 /// Profile 1 (software) ciphers selected for the eSTREAM portfolio. 0098 /// \details Crypto++ provides Rabbit and RabbitWithIV classes. Two classes are necessary 0099 /// because the library lacks the means to describe and manage optional IVs. 0100 /// \sa Rabbit, <A HREF="http://www.ecrypt.eu.org/stream/e2-rabbit.html">The 0101 /// eSTREAM Project | Rabbit</A> and 0102 /// <A HREF="https://www.cryptopp.com/wiki/Rabbit">Crypto++ Wiki | Rabbit</A>. 0103 /// \since Crypto++ 8.0 0104 struct RabbitWithIV : public RabbitWithIVInfo, public SymmetricCipherDocumentation 0105 { 0106 typedef SymmetricCipherFinal<ConcretePolicyHolder<RabbitWithIVPolicy, AdditiveCipherTemplate<> >, RabbitWithIVInfo> Encryption; 0107 typedef Encryption Decryption; 0108 }; 0109 0110 NAMESPACE_END 0111 0112 #endif // CRYPTOPP_RABBIT_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |