Fabcoin Core  0.16.2
P2P Digital Currency
rc2.h
Go to the documentation of this file.
1 // rc2.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_RC2_H
7 #define CRYPTOPP_RC2_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 #include "algparam.h"
12 
14 
15 struct RC2_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 128>
18 {
19  CRYPTOPP_CONSTANT(DEFAULT_EFFECTIVE_KEYLENGTH = 1024)
20  CRYPTOPP_CONSTANT(MAX_EFFECTIVE_KEYLENGTH = 1024)
21  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "RC2";}
22 };
23 
27 class RC2 : public RC2_Info, public BlockCipherDocumentation
28 {
32  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC2_Info>
33  {
34  public:
35  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
36  unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word16>();}
37 
38  protected:
39  FixedSizeSecBlock<word16, 64> K; // expanded key table
40  };
41 
45  class CRYPTOPP_NO_VTABLE Enc : public Base
46  {
47  public:
48  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
49  };
50 
54  class CRYPTOPP_NO_VTABLE Dec : public Base
55  {
56  public:
57  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
58  };
59 
60 public:
61 
65  class Encryption : public BlockCipherFinal<ENCRYPTION, Enc>
66  {
67  public:
69  Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
70  {SetKey(key, keyLen);}
71  Encryption(const byte *key, size_t keyLen, int effectiveKeyLen)
72  {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
73  };
74 
78  class Decryption : public BlockCipherFinal<DECRYPTION, Dec>
79  {
80  public:
82  Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
83  {SetKey(key, keyLen);}
84  Decryption(const byte *key, size_t keyLen, int effectiveKeyLen)
85  {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
86  };
87 };
88 
91 
93 
94 #endif
95 
Decryption(const byte *key, size_t keyLen, int effectiveKeyLen)
Definition: rc2.h:84
Classes for working with NameValuePairs.
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
RC2::Decryption RC2Decryption
Definition: rc2.h:90
Encryption(const byte *key, size_t keyLen, int effectiveKeyLen)
Definition: rc2.h:71
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
Class specific methods used to operate the cipher in the forward direction.
Definition: rc2.h:45
Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
Definition: rc2.h:69
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
FixedSizeSecBlock< word16, 64 > K
Definition: rc2.h:39
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Definition: algparam.h:498
Decryption()
Definition: rc2.h:81
Classes and functions for implementing secret key algorithms.
RC2 block cipher.
Definition: rc2.h:27
Provides class member functions to key a block cipher.
Definition: seckey.h:324
CRYPTOPP_STATIC_CONSTEXPR const char *CRYPTOPP_API StaticAlgorithmName()
Definition: sha.h:30
RC2 block cipher information.
Definition: rc2.h:17
#define CRYPTOPP_CONSTANT(x)
Definition: config.h:540
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:169
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
Definition: rc2.h:82
#define NAMESPACE_END
Definition: config.h:201
RC2::Encryption RC2Encryption
Definition: rc2.h:89
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
Class specific methods used to operate the cipher in the reverse direction.
Definition: rc2.h:78
Class specific methods used to operate the cipher in the reverse direction.
Definition: rc2.h:54
Class specific methods used to operate the cipher in the forward direction.
Definition: rc2.h:65
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Definition: rc2.h:36
Encryption()
Definition: rc2.h:68
Class specific methods used to operate the cipher.
Definition: rc2.h:32
Interface for retrieving values given their names.
Definition: cryptlib.h:279