Crypto++  5.6.3
Free C++ class library of cryptographic schemes
safer.h
Go to the documentation of this file.
1 // safer.h - written and placed in the public domain by Wei Dai
2 
3 //! \file safer.h
4 //! \brief Classes for the SAFER block cipher
5 
6 #ifndef CRYPTOPP_SAFER_H
7 #define CRYPTOPP_SAFER_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 
12 NAMESPACE_BEGIN(CryptoPP)
13 
14 /// base class, do not use directly
15 class SAFER
16 {
17 public:
18  class CRYPTOPP_NO_VTABLE Base : public BlockCipher
19  {
20  public:
21  unsigned int OptimalDataAlignment() const {return 1;}
22  void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs &params);
23 
24  protected:
25  virtual bool Strengthened() const =0;
26 
27  SecByteBlock keySchedule;
28  static const byte exp_tab[256];
29  static const byte log_tab[256];
30  };
31 
32  class CRYPTOPP_NO_VTABLE Enc : public Base
33  {
34  public:
35  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
36  };
37 
38  class CRYPTOPP_NO_VTABLE Dec : public Base
39  {
40  public:
41  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
42  };
43 };
44 
45 template <class BASE, class INFO, bool STR>
46 class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
47 {
48 protected:
49  bool Strengthened() const {return STR;}
50 };
51 
52 //! _
53 struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
54 {
55  static const char *StaticAlgorithmName() {return "SAFER-K";}
56 };
57 
58 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-K">SAFER-K</a>
59 class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
60 {
61 public:
64 };
65 
66 //! _
67 struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
68 {
69  static const char *StaticAlgorithmName() {return "SAFER-SK";}
70 };
71 
72 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SAFER-SK">SAFER-SK</a>
73 class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
74 {
75 public:
78 };
79 
82 
85 
86 NAMESPACE_END
87 
88 #endif
SAFER-K
Definition: safer.h:59
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:385
SecByteBlock is a SecBlock<byte> typedef.
Definition: secblock.h:719
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1013
Classes and functions for secure memory allocations.
Inherited by block ciphers with fixed block size.
Definition: seckey.h:34
Inherited by ciphers with variable number of rounds.
Definition: seckey.h:60
base class, do not use directly
Definition: safer.h:15
Classes and functions for implementing secret key algorithms.
Provides class member functions to key a block cipher.
Definition: seckey.h:305
SAFER-SK
Definition: safer.h:73
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:152
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: safer.h:21
virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
Encrypt or decrypt a block.
Provides class member functions to access BlockCipher constants.
Definition: seckey.h:292
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:261