Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:10

0001 // wake.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file wake.h

0004 /// \brief Classes for WAKE stream cipher

0005 
0006 #ifndef CRYPTOPP_WAKE_H
0007 #define CRYPTOPP_WAKE_H
0008 
0009 #include "seckey.h"
0010 #include "secblock.h"
0011 #include "strciphr.h"
0012 
0013 NAMESPACE_BEGIN(CryptoPP)
0014 
0015 /// \brief WAKE stream cipher information

0016 /// \tparam B Endianness of the stream cipher

0017 /// \since Crypto++ 1.0

0018 template <class B = BigEndian>
0019 struct WAKE_OFB_Info : public FixedKeyLength<32>
0020 {
0021     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-OFB-LE" : "WAKE-OFB-BE";}
0022 };
0023 
0024 class CRYPTOPP_NO_VTABLE WAKE_Base
0025 {
0026 protected:
0027     word32 M(word32 x, word32 y);
0028     void GenKey(word32 k0, word32 k1, word32 k2, word32 k3);
0029 
0030     word32 t[257];
0031     word32 r3, r4, r5, r6;
0032 };
0033 
0034 /// \brief WAKE stream cipher operation

0035 /// \tparam B Endianness of the stream cipher

0036 /// \since Crypto++ 1.0

0037 template <class B = BigEndian>
0038 class CRYPTOPP_NO_VTABLE WAKE_Policy : public AdditiveCipherConcretePolicy<word32, 1, 64>, protected WAKE_Base
0039 {
0040 protected:
0041     void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length);
0042     // OFB

0043     void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount);
0044     bool CipherIsRandomAccess() const {return false;}
0045 };
0046 
0047 /// \brief WAKE stream cipher

0048 /// \tparam B Endianness of the stream cipher

0049 /// \since Crypto++ 1.0

0050 template <class B = BigEndian>
0051 struct WAKE_OFB : public WAKE_OFB_Info<B>, public SymmetricCipherDocumentation
0052 {
0053     typedef SymmetricCipherFinal<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> >,  WAKE_OFB_Info<B> > Encryption;
0054     typedef Encryption Decryption;
0055 };
0056 
0057 NAMESPACE_END
0058 
0059 #endif