Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# wake.h

    00001 #ifndef CRYPTOPP_WAKE_H
    00002 #define CRYPTOPP_WAKE_H
    00003
    00004 #include "seckey.h"
    00005 #include "secblock.h"
    00006 #include "strciphr.h"
    00007
    00008 NAMESPACE_BEGIN(CryptoPP)
    00009
    00010 template <class B = BigEndian>
    00011 struct WAKE_Info : public FixedKeyLength<32>
    00012 {
    00013         static const char *StaticAlgorithmName() {return B::ToEnum() == LITTLE_ENDIAN_ORDER ? "WAKE-CFB-LE" : "WAKE-CFB-BE";}
    00014 };
    00015
    00016 class WAKE_Base
    00017 {
    00018 protected:
    00019         word32 M(word32 x, word32 y);
    00020         void GenKey(word32 k0, word32 k1, word32 k2, word32 k3);
    00021
    00022         word32 t[257];
    00023         word32 r3, r4, r5, r6;
    00024 };
    00025
    00026 template <class B = BigEndian>
    00027 class WAKE_Policy : public WAKE_Info<B>
    00028                                 , public CFB_CipherConcretePolicy<word32, 1>
    00029                                 , public AdditiveCipherConcretePolicy<word32, 1, 64>
    00030                                 , protected WAKE_Base
    00031 {
    00032 protected:
    00033         void CipherSetKey(const NameValuePairs &params, const byte *key, unsigned int length);
    00034         // CFB
    00035         byte * GetRegisterBegin() {return (byte *)&r6;}
    00036         void Iterate(byte *output, const byte *input, CipherDir dir, unsigned int iterationCount);
    00037         // OFB
    00038         void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
    00039         bool IsRandomAccess() const {return false;}
    00040 };
    00041
    00042 //! <a href="http://www.weidai.com/scan-mirror/cs.html#WAKE-CFB-BE">WAKE-CFB-BE</a>
    00043 template <class B = BigEndian>
    00044 struct WAKE_CFB : public WAKE_Info<B>, public SymmetricCipherDocumentation
    00045 {
    00046         typedef SymmetricCipherFinalTemplate<ConcretePolicyHolder<WAKE_Policy<B>, CFB_EncryptionTemplate<> > > Encryption;
    00047         typedef SymmetricCipherFinalTemplate<ConcretePolicyHolder<WAKE_Policy<B>, CFB_DecryptionTemplate<> > > Decryption;
    00048 };
    00049
    00050 //! WAKE-OFB
    00051 template <class B = BigEndian>
    00052 struct WAKE_OFB : public WAKE_Info<B>, public SymmetricCipherDocumentation
    00053 {
    00054         typedef SymmetricCipherFinalTemplate<ConcretePolicyHolder<WAKE_Policy<B>, AdditiveCipherTemplate<> > > Encryption;
    00055         typedef Encryption Decryption;
    00056 };
    00057
    00058 /*
    00059 template <class B = BigEndian>
    00060 class WAKE_ROFB_Policy : public WAKE_Policy<B>
    00061 {
    00062 protected:
    00063         void Iterate(KeystreamOperation operation, byte *output, const byte *input, unsigned int iterationCount);
    00064 };
    00065
    00066 template <class B = BigEndian>
    00067 struct WAKE_ROFB : public WAKE_Info<B>
    00068 {
    00069         typedef SymmetricCipherTemplate<ConcretePolicyHolder<AdditiveCipherTemplate<>, WAKE_ROFB_Policy<B> > > Encryption;
    00070         typedef Encryption Decryption;
    00071 };
    00072 */
    00073
    00074 NAMESPACE_END
    00075
    00076 #endif