00001
#ifndef CRYPTOPP_DIAMOND_H
00002
#define CRYPTOPP_DIAMOND_H
00003
00004
00005
00006
00007
#include "seckey.h"
00008
#include "secblock.h"
00009
00010 NAMESPACE_BEGIN(CryptoPP)
00011
00012 struct Diamond2_Info : public
FixedBlockSize<16>, public
VariableKeyLength<16, 1, 256>, public
VariableRounds<10>
00013 {
00014
static const char *StaticAlgorithmName() {
return "Diamond2";}
00015 };
00016
00017
00018 class Diamond2 :
public Diamond2_Info,
public BlockCipherDocumentation
00019 {
00020
class Base :
public BlockCipherBaseTemplate<Diamond2_Info>
00021 {
00022
public:
00023
void UncheckedSetKey(
CipherDir direction,
const byte *userKey,
unsigned int length,
unsigned int rounds);
00024
00025
protected:
00026
enum {ROUNDSIZE=4096};
00027
inline void substitute(
int round, byte *x,
const byte *y)
const;
00028
00029
int numrounds;
00030
SecByteBlock s;
00031
00032
static inline void permute(byte *);
00033
static inline void ipermute(byte *);
00034
#ifdef DIAMOND_USE_PERMTABLE
00035
static const word32 permtable[9][256];
00036
static const word32 ipermtable[9][256];
00037
#endif
00038
};
00039
00040
class Enc :
public Base
00041 {
00042
public:
00043
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00044 };
00045
00046
class Dec :
public Base
00047 {
00048
public:
00049
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00050 };
00051
00052
public:
00053 typedef BlockCipherTemplate<ENCRYPTION, Enc> Encryption;
00054 typedef BlockCipherTemplate<DECRYPTION, Dec> Decryption;
00055 };
00056
00057
typedef Diamond2::Encryption Diamond2Encryption;
00058
typedef Diamond2::Decryption Diamond2Decryption;
00059
00060
struct Diamond2Lite_Info :
public FixedBlockSize<8>,
public VariableKeyLength<16, 1, 256>,
public VariableRounds<8>
00061 {
00062
static const char *StaticAlgorithmName() {
return "Diamond2Lite";}
00063 };
00064
00065
00066 class Diamond2Lite :
public Diamond2Lite_Info,
public BlockCipherDocumentation
00067 {
00068
class Base :
public BlockCipherBaseTemplate<Diamond2Lite_Info>
00069 {
00070
public:
00071
void UncheckedSetKey(
CipherDir direction,
const byte *userKey,
unsigned int length,
unsigned int rounds);
00072
00073
protected:
00074
enum {ROUNDSIZE=2048};
00075
inline void substitute(
int round, byte *x,
const byte *y)
const;
00076
int numrounds;
00077
SecByteBlock s;
00078
00079
static inline void permute(byte *);
00080
static inline void ipermute(byte *);
00081
#ifdef DIAMOND_USE_PERMTABLE
00082
static const word32 permtable[8][256];
00083
static const word32 ipermtable[8][256];
00084
#endif
00085
};
00086
00087
class Enc :
public Base
00088 {
00089
public:
00090
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00091 };
00092
00093
class Dec :
public Base
00094 {
00095
public:
00096
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00097 };
00098
00099
public:
00100 typedef BlockCipherTemplate<ENCRYPTION, Enc> Encryption;
00101 typedef BlockCipherTemplate<DECRYPTION, Dec> Decryption;
00102 };
00103
00104
typedef Diamond2Lite::Encryption Diamond2LiteEncryption;
00105
typedef Diamond2Lite::Decryption Diamond2LiteDecryption;
00106
00107 NAMESPACE_END
00108
00109
#endif