00001 #ifndef CRYPTOPP_DIAMOND_H
00002 #define CRYPTOPP_DIAMOND_H
00003
00007 #include "cryptlib.h"
00008 #include "misc.h"
00009 #include "crc.h"
00010
00011 NAMESPACE_BEGIN(CryptoPP)
00012
00014 class Diamond2Base : public FixedBlockSize<16>, public VariableKeyLength<16, 1, 256>
00015 {
00016 public:
00017 Diamond2Base(const byte *key, unsigned int key_size, unsigned int rounds,
00018 CipherDir direction);
00019
00020 enum {DEFAULT_ROUNDS=10};
00021
00022 protected:
00023 enum {ROUNDSIZE=4096};
00024 inline void substitute(int round, byte *y) const;
00025
00026 const int numrounds;
00027 SecByteBlock s;
00028
00029 static inline void permute(byte *);
00030 static inline void ipermute(byte *);
00031 #ifdef DIAMOND_USE_PERMTABLE
00032 static const word32 permtable[9][256];
00033 static const word32 ipermtable[9][256];
00034 #endif
00035 };
00036
00038 class Diamond2Encryption : public Diamond2Base
00039 {
00040 public:
00041 Diamond2Encryption(const byte *key, unsigned int key_size=DEFAULT_KEYLENGTH, unsigned int rounds=DEFAULT_ROUNDS)
00042 : Diamond2Base(key, key_size, rounds, ENCRYPTION) {}
00043
00044 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00045 void ProcessBlock(byte * inoutBlock) const;
00046 };
00047
00049 class Diamond2Decryption : public Diamond2Base
00050 {
00051 public:
00052 Diamond2Decryption(const byte *key, unsigned int key_size=DEFAULT_KEYLENGTH, unsigned int rounds=DEFAULT_ROUNDS)
00053 : Diamond2Base(key, key_size, rounds, DECRYPTION) {}
00054
00055 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00056 void ProcessBlock(byte * inoutBlock) const;
00057 };
00058
00060 class Diamond2LiteBase : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 256>
00061 {
00062 public:
00063 Diamond2LiteBase(const byte *key, unsigned int key_size, unsigned int rounds,
00064 CipherDir direction);
00065
00066 enum {DEFAULT_ROUNDS=8};
00067
00068 protected:
00069 enum {ROUNDSIZE=2048};
00070 inline void substitute(int round, byte *y) const;
00071 const int numrounds;
00072 SecByteBlock s;
00073
00074 static inline void permute(byte *);
00075 static inline void ipermute(byte *);
00076 #ifdef DIAMOND_USE_PERMTABLE
00077 static const word32 permtable[8][256];
00078 static const word32 ipermtable[8][256];
00079 #endif
00080 };
00081
00083 class Diamond2LiteEncryption : public Diamond2LiteBase
00084 {
00085 public:
00086 Diamond2LiteEncryption(const byte *key, unsigned int key_size=DEFAULT_KEYLENGTH, unsigned int rounds=DEFAULT_ROUNDS)
00087 : Diamond2LiteBase(key, key_size, rounds, ENCRYPTION) {}
00088
00089 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00090 void ProcessBlock(byte * inoutBlock) const;
00091 };
00092
00094 class Diamond2LiteDecryption : public Diamond2LiteBase
00095 {
00096 public:
00097 Diamond2LiteDecryption(const byte *key, unsigned int key_size=DEFAULT_KEYLENGTH, unsigned int rounds=DEFAULT_ROUNDS)
00098 : Diamond2LiteBase(key, key_size, rounds, DECRYPTION) {}
00099
00100 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00101 void ProcessBlock(byte * inoutBlock) const;
00102 };
00103
00104 NAMESPACE_END
00105
00106 #endif