- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# safer.h

Go to the documentation of this file.

    00001 #ifndef CRYPTOPP_SAFER_H
    00002 #define CRYPTOPP_SAFER_H
    00003
    00004 /** \file
    00005 */
    00006
    00007 #include "seckey.h"
    00008 #include "secblock.h"
    00009
    00010 NAMESPACE_BEGIN(CryptoPP)
    00011
    00012 /// base class, do not use directly
    00013 class SAFER
    00014 {
    00015 public:
    00016         class CRYPTOPP_NO_VTABLE Base : public BlockCipher
    00017         {
    00018         public:
    00019                 unsigned int GetAlignment() const {return 1;}
    00020                 void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs &params);
    00021
    00022         protected:
    00023                 virtual bool Strengthened() const =0;
    00024
    00025                 SecByteBlock keySchedule;
    00026                 static const byte exp_tab[256];
    00027                 static const byte log_tab[256];
    00028         };
    00029
    00030         class CRYPTOPP_NO_VTABLE Enc : public Base
    00031         {
    00032         public:
    00033                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
    00034         };
    00035
    00036         class CRYPTOPP_NO_VTABLE Dec : public Base
    00037         {
    00038         public:
    00039                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
    00040         };
    00041 };
    00042
    00043 template <class BASE, class INFO, bool STR>
    00044 class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
    00045 {
    00046 protected:
    00047         bool Strengthened() const {return STR;}
    00048 };
    00049
    00050 //! _
    00051 struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
    00052 {
    00053         static const char *StaticAlgorithmName() {return "SAFER-K";}
    00054 };
    00055
    00056 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K">SAFER-K</a>
    00057 class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
    00058 {
    00059 public:
    00060         typedef BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_K_Info, false> > Encryption;
    00061         typedef BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_K_Info, false> > Decryption;
    00062 };
    00063
    00064 //! _
    00065 struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
    00066 {
    00067         static const char *StaticAlgorithmName() {return "SAFER-SK";}
    00068 };
    00069
    00070 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK">SAFER-SK</a>
    00071 class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
    00072 {
    00073 public:
    00074         typedef BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_SK_Info, true> > Encryption;
    00075         typedef BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_SK_Info, true> > Decryption;
    00076 };
    00077
    00078 typedef SAFER_K::Encryption SAFER_K_Encryption;
    00079 typedef SAFER_K::Decryption SAFER_K_Decryption;
    00080
    00081 typedef SAFER_SK::Encryption SAFER_SK_Encryption;
    00082 typedef SAFER_SK::Decryption SAFER_SK_Decryption;
    00083
    00084 NAMESPACE_END
    00085
    00086 #endif