safer.h
Go to the documentation of this file.
#ifndef CRYPTOPP_SAFER_H
#define CRYPTOPP_SAFER_H
/** \file
*/
#include "seckey.h"
#include "secblock.h"
NAMESPACE_BEGIN(CryptoPP)
/// base class, do not use directly
class SAFER
{
public:
class CRYPTOPP_NO_VTABLE Base : public BlockCipher
{
public:
unsigned int OptimalDataAlignment() const {return 1;}
void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs &params);
protected:
virtual bool Strengthened() const =0;
SecByteBlock keySchedule;
static const byte exp_tab[256];
static const byte log_tab[256];
};
class CRYPTOPP_NO_VTABLE Enc : public Base
{
public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
};
class CRYPTOPP_NO_VTABLE Dec : public Base
{
public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
};
};
template <class BASE, class INFO, bool STR>
class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
{
protected:
bool Strengthened() const {return STR;}
};
//! _
struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
{
static const char *StaticAlgorithmName() {return "SAFER-K";}
};
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K">SAFER-K</a>
class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
{
public:
typedef BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_K_Info, false> > Encryption;
typedef BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_K_Info, false> > Decryption;
};
//! _
struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
{
static const char *StaticAlgorithmName() {return "SAFER-SK";}
};
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK">SAFER-SK</a>
class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
{
public:
typedef BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_SK_Info, true> > Encryption;
typedef BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_SK_Info, true> > Decryption;
};
typedef SAFER_K::Encryption SAFER_K_Encryption;
typedef SAFER_K::Decryption SAFER_K_Decryption;
typedef SAFER_SK::Encryption SAFER_SK_Encryption;
typedef SAFER_SK::Decryption SAFER_SK_Decryption;
NAMESPACE_END
#endif
SAFER_K
SAFER-K
Definition: safer.h:57
BlockCipherDocumentation
These objects usually should not be used directly. See CipherModeDocumentation instead.
Definition: seckey.h:188
BlockTransformation::ProcessAndXorBlock
virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
encrypt or decrypt inBlock, xor with xorBlock, and write to outBlock
SecBlock< byte >
BlockCipher
interface for one direction (encryption or decryption) of a block cipher
Definition: cryptlib.h:603
SAFER::Dec
Definition: safer.h:36
FixedBlockSize
to be inherited by block ciphers with fixed block size
Definition: seckey.h:21
VariableRounds
to be inherited by ciphers with variable number of rounds
Definition: seckey.h:39
SAFER::Base
Definition: safer.h:16
SAFER
base class, do not use directly
Definition: safer.h:13
BlockCipherFinal
_
Definition: seckey.h:151
SAFER_Impl
Definition: safer.h:44
SAFER_K_Info
_
Definition: safer.h:51
SAFER_SK
SAFER-SK
Definition: safer.h:71
VariableKeyLength
support query of variable key length, template parameters are default, min, max, multiple (default mu...
Definition: seckey.h:80
SAFER::Base::OptimalDataAlignment
unsigned int OptimalDataAlignment() const
returns how inputs and outputs should be aligned for optimal performance
Definition: safer.h:19
BlockCipherImpl
Definition: seckey.h:143
SAFER_SK_Info
_
Definition: safer.h:65
NameValuePairs
interface for retrieving values given their names
Definition: cryptlib.h:224
SAFER::Enc
Definition: safer.h:30