Fabcoin Core  0.16.2
P2P Digital Currency
safer.h
Go to the documentation of this file.
1 // safer.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_SAFER_H
7 #define CRYPTOPP_SAFER_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 
13 
14 class SAFER
17 {
18 public:
22  {
23  public:
24  unsigned int OptimalDataAlignment() const {return 1;}
25  void UncheckedSetKey(const byte *userkey, unsigned int length, const NameValuePairs &params);
26 
27  protected:
28  virtual bool Strengthened() const =0;
29 
31  static const byte exp_tab[256];
32  static const byte log_tab[256];
33  };
34 
37  class CRYPTOPP_NO_VTABLE Enc : public Base
38  {
39  public:
40  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
41  };
42 
45  class CRYPTOPP_NO_VTABLE Dec : public Base
46  {
47  public:
48  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
49  };
50 };
51 
58 template <class BASE, class INFO, bool STR>
59 class CRYPTOPP_NO_VTABLE SAFER_Impl : public BlockCipherImpl<INFO, BASE>
60 {
61 protected:
62  bool Strengthened() const {return STR;}
63 };
64 
67 struct SAFER_K_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
68 {
69  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SAFER-K";}
70 };
71 
75 class SAFER_K : public SAFER_K_Info, public SAFER, public BlockCipherDocumentation
76 {
77 public:
80 };
81 
84 struct SAFER_SK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 8, 16, 8>, public VariableRounds<10, 1, 13>
85 {
86  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SAFER-SK";}
87 };
88 
92 class SAFER_SK : public SAFER_SK_Info, public SAFER, public BlockCipherDocumentation
93 {
94 public:
97 };
98 
101 
104 
106 
107 #endif
SAFER-K block cipher.
Definition: safer.h:75
uint8_t byte
Definition: Common.h:57
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:408
virtual void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const =0
Encrypt or decrypt a block.
SAFER_K::Encryption SAFER_K_Encryption
Definition: safer.h:99
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
BlockCipherFinal< DECRYPTION, SAFER_Impl< Dec, SAFER_K_Info, false > > Decryption
Definition: safer.h:79
BlockCipherFinal< DECRYPTION, SAFER_Impl< Dec, SAFER_SK_Info, true > > Decryption
Definition: safer.h:96
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1095
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: safer.h:69
SAFER block cipher decryption operation.
Definition: safer.h:45
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:66
SAFER block cipher default operation.
Definition: safer.h:21
SAFER block cipher.
Definition: safer.h:16
SecByteBlock keySchedule
Definition: safer.h:30
Classes and functions for implementing secret key algorithms.
Provides class member functions to key a block cipher.
Definition: seckey.h:324
SAFER_K::Decryption SAFER_K_Decryption
Definition: safer.h:100
SAFER block cipher default implementation.
Definition: safer.h:59
SAFER_SK::Decryption SAFER_SK_Decryption
Definition: safer.h:103
SAFER-K block cipher information.
Definition: safer.h:67
SAFER-SK block cipher.
Definition: safer.h:92
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:169
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: safer.h:24
bool Strengthened() const
Definition: safer.h:62
virtual void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)=0
Sets the key for this object without performing parameter validation.
#define NAMESPACE_END
Definition: config.h:201
SAFER_SK::Encryption SAFER_SK_Encryption
Definition: safer.h:102
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
BlockCipherFinal< ENCRYPTION, SAFER_Impl< Enc, SAFER_K_Info, false > > Encryption
Definition: safer.h:78
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: safer.h:86
SAFER-SK block cipher information.
Definition: safer.h:84
BlockCipherFinal< ENCRYPTION, SAFER_Impl< Enc, SAFER_SK_Info, true > > Encryption
Definition: safer.h:95
Interface for retrieving values given their names.
Definition: cryptlib.h:279
SAFER block cipher encryption operation.
Definition: safer.h:37