00001 #ifndef CRYPTOPP_SHARK_H
00002 #define CRYPTOPP_SHARK_H
00003
00007 #include "config.h"
00008
00009 #ifdef WORD64_AVAILABLE
00010
00011 #include "cryptlib.h"
00012 #include "misc.h"
00013
00014 NAMESPACE_BEGIN(CryptoPP)
00015
00017 class SHARKBase : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>
00018 {
00019 public:
00020 enum {DEFAULT_ROUNDS=6};
00021
00022 protected:
00023 static void InitEncryptionRoundKeys(const byte *key, unsigned int keyLen, unsigned int rounds, word64 *roundkeys);
00024 SHARKBase(unsigned int rounds) : rounds(rounds), roundkeys(rounds+1) {}
00025
00026 unsigned int rounds;
00027 SecBlock<word64> roundkeys;
00028 };
00029
00031 class SHARKEncryption : public SHARKBase
00032 {
00033 public:
00034 SHARKEncryption(const byte *key, unsigned int keyLen=DEFAULT_KEYLENGTH, unsigned int rounds=DEFAULT_ROUNDS);
00035
00036 void ProcessBlock(byte * inoutBlock) const
00037 {SHARKEncryption::ProcessBlock(inoutBlock, inoutBlock);}
00038 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00039
00040 private:
00041 friend class SHARKBase;
00042 SHARKEncryption();
00043 static const byte sbox[256];
00044 static const word64 cbox[8][256];
00045 };
00046
00048 class SHARKDecryption : public SHARKBase
00049 {
00050 public:
00051 SHARKDecryption(const byte *key, unsigned int keyLen=DEFAULT_KEYLENGTH, unsigned int rounds=DEFAULT_ROUNDS);
00052
00053 void ProcessBlock(byte * inoutBlock) const
00054 {SHARKDecryption::ProcessBlock(inoutBlock, inoutBlock);}
00055 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00056
00057 private:
00058 static const byte sbox[256];
00059 static const word64 cbox[8][256];
00060 };
00061
00062 NAMESPACE_END
00063
00064 #endif
00065 #endif