Crypto++
safer.h
Go to the documentation of this file.
1 #ifndef CRYPTOPP_SAFER_H
2 #define CRYPTOPP_SAFER_H
3 
4 /** \file
5 */
6 
7 #include "seckey.h"
8 #include "secblock.h"
9 
10 NAMESPACE_BEGIN(CryptoPP)
11 
12 /// base class, do not use directly
13 class SAFER
14 {
15 public:
16  class CRYPTOPP_NO_VTABLE Base : public BlockCipher
17  {
18  public:
19  unsigned int OptimalDataAlignment() const {return 1;}
20  void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs &params);
21 
22  protected:
23  virtual bool Strengthened() const =0;
24 
25  SecByteBlock keySchedule;
26  static const byte exp_tab[256];
27  static const byte log_tab[256];
28  };
29 
30  class CRYPTOPP_NO_VTABLE Enc : public Base
31  {
32  public:
33  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
34  };
35 
36  class CRYPTOPP_NO_VTABLE Dec : public Base
37  {
38  public:
39  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
40  };
41 };
42 
43 template <class BASE, class INFO, bool STR>
44 class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
45 {
46 protected:
47  bool Strengthened() const {return STR;}
48 };
49 
50 //! _
51 struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
52 {
53  static const char *StaticAlgorithmName() {return "SAFER-K";}
54 };
55 
56 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K">SAFER-K</a>
57 class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
58 {
59 public:
62 };
63 
64 //! _
65 struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
66 {
67  static const char *StaticAlgorithmName() {return "SAFER-SK";}
68 };
69 
70 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK">SAFER-SK</a>
71 class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
72 {
73 public:
76 };
77 
80 
83 
84 NAMESPACE_END
85 
86 #endif
SAFER-K
Definition: safer.h:57
These objects usually should not be used directly. See CipherModeDocumentation instead.
Definition: seckey.h:188
virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
encrypt or decrypt inBlock, xor with xorBlock, and write to outBlock
interface for one direction (encryption or decryption) of a block cipher
Definition: cryptlib.h:603
to be inherited by block ciphers with fixed block size
Definition: seckey.h:21
to be inherited by ciphers with variable number of rounds
Definition: seckey.h:39
base class, do not use directly
Definition: safer.h:13
SAFER-SK
Definition: safer.h:71
support query of variable key length, template parameters are default, min, max, multiple (default mu...
Definition: seckey.h:80
unsigned int OptimalDataAlignment() const
returns how inputs and outputs should be aligned for optimal performance
Definition: safer.h:19
interface for retrieving values given their names
Definition: cryptlib.h:224