00001
#ifndef CRYPTOPP_SQUARE_H
00002
#define CRYPTOPP_SQUARE_H
00003
00004
00005
00006
00007
#include "seckey.h"
00008
#include "secblock.h"
00009
00010 NAMESPACE_BEGIN(CryptoPP)
00011
00012 struct Square_Info : public
FixedBlockSize<16>, public
FixedKeyLength<16>,
FixedRounds<8>
00013 {
00014
static const char *StaticAlgorithmName() {
return "Square";}
00015 };
00016
00017
00018 class Square :
public Square_Info,
public BlockCipherDocumentation
00019 {
00020
class Base :
public BlockCipherBaseTemplate<Square_Info>
00021 {
00022
public:
00023
void UncheckedSetKey(
CipherDir direction,
const byte *userKey,
unsigned int length);
00024
00025
protected:
00026 FixedSizeSecBlock<word32[4], ROUNDS+1> roundkeys;
00027 };
00028
00029
class Enc :
public Base
00030 {
00031
public:
00032
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00033
private:
00034
static const byte Se[256];
00035
static const word32 Te[4][256];
00036 };
00037
00038
class Dec :
public Base
00039 {
00040
public:
00041
void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const;
00042
private:
00043
static const byte Sd[256];
00044
static const word32 Td[4][256];
00045 };
00046
00047
public:
00048 typedef BlockCipherTemplate<ENCRYPTION, Enc> Encryption;
00049 typedef BlockCipherTemplate<DECRYPTION, Dec> Decryption;
00050 };
00051
00052
typedef Square::Encryption SquareEncryption;
00053
typedef Square::Decryption SquareDecryption;
00054
00055 NAMESPACE_END
00056
00057
#endif