16
16
class CRYPTOPP_NO_VTABLE Base : public BlockCipher
19
unsigned int GetAlignment() const {return 1;}
20
void UncheckedSetKey(CipherDir dir, const byte *userkey, unsigned int length, unsigned nof_rounds);
19
unsigned int OptimalDataAlignment() const {return 1;}
20
void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs ¶ms);
23
virtual bool Strengthened() const =0;
23
25
SecByteBlock keySchedule;
24
26
static const byte exp_tab[256];
25
27
static const byte log_tab[256];
43
template <class BASE, class INFO, bool STR>
44
class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
47
bool Strengthened() const {return STR;}
42
51
struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
44
53
static const char *StaticAlgorithmName() {return "SAFER-K";}
45
static unsigned int DefaultRounds(unsigned int keylength) {return keylength == 8 ? 6 : 10;}
48
56
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K">SAFER-K</a>
49
57
class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
51
class CRYPTOPP_NO_VTABLE Enc : public BlockCipherImpl<SAFER_K_Info, SAFER::Enc>
54
Enc() {strengthened = false;}
57
class CRYPTOPP_NO_VTABLE Dec : public BlockCipherImpl<SAFER_K_Info, SAFER::Dec>
60
Dec() {strengthened = false;}
64
typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
65
typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
60
typedef BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_K_Info, false> > Encryption;
61
typedef BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_K_Info, false> > Decryption;
69
65
struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
71
67
static const char *StaticAlgorithmName() {return "SAFER-SK";}
72
static unsigned int DefaultRounds(unsigned int keylength) {return keylength == 8 ? 8 : 10;}
75
70
/// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK">SAFER-SK</a>
76
71
class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
78
class CRYPTOPP_NO_VTABLE Enc : public BlockCipherImpl<SAFER_SK_Info, SAFER::Enc>
81
Enc() {strengthened = true;}
84
class CRYPTOPP_NO_VTABLE Dec : public BlockCipherImpl<SAFER_SK_Info, SAFER::Dec>
87
Dec() {strengthened = true;}
91
typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
92
typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
74
typedef BlockCipherFinal<ENCRYPTION, SAFER_Impl<Enc, SAFER_SK_Info, true> > Encryption;
75
typedef BlockCipherFinal<DECRYPTION, SAFER_Impl<Dec, SAFER_SK_Info, true> > Decryption;
95
78
typedef SAFER_K::Encryption SAFER_K_Encryption;