- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# shark.h

Go to the documentation of this file.

    00001 #ifndef CRYPTOPP_SHARK_H
    00002 #define CRYPTOPP_SHARK_H
    00003
    00004 /** \file
    00005 */
    00006
    00007 #include "config.h"
    00008
    00009 #ifdef WORD64_AVAILABLE
    00010
    00011 #include "seckey.h"
    00012 #include "secblock.h"
    00013
    00014 NAMESPACE_BEGIN(CryptoPP)
    00015
    00016 //! _
    00017 struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>, public VariableRounds<6, 2>
    00018 {
    00019         static const char *StaticAlgorithmName() {return "SHARK-E";}
    00020 };
    00021
    00022 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SHARK-E">SHARK-E</a>
    00023 class SHARK : public SHARK_Info, public BlockCipherDocumentation
    00024 {
    00025         class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
    00026         {
    00027         public:
    00028                 void UncheckedSetKey(CipherDir dir, const byte *key, unsigned int length, unsigned int rounds);
    00029
    00030         protected:
    00031                 unsigned int m_rounds;
    00032                 SecBlock<word64> m_roundKeys;
    00033         };
    00034
    00035         class CRYPTOPP_NO_VTABLE Enc : public Base
    00036         {
    00037         public:
    00038                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
    00039
    00040                 // used by Base to do key setup
    00041                 void InitForKeySetup();
    00042
    00043         private:
    00044                 static const byte sbox[256];
    00045                 static const word64 cbox[8][256];
    00046         };
    00047
    00048         class CRYPTOPP_NO_VTABLE Dec : public Base
    00049         {
    00050         public:
    00051                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
    00052
    00053         private:
    00054                 static const byte sbox[256];
    00055                 static const word64 cbox[8][256];
    00056         };
    00057
    00058 public:
    00059         typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
    00060         typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
    00061 };
    00062
    00063 typedef SHARK::Encryption SHARKEncryption;
    00064 typedef SHARK::Decryption SHARKDecryption;
    00065
    00066 NAMESPACE_END
    00067
    00068 #endif
    00069 #endif