Crypto++  5.6.3
Free C++ class library of cryptographic schemes
cast.h
Go to the documentation of this file.
1 // cast.h - written and placed in the public domain by Wei Dai
2 
3 //! \file cast.h
4 //! \brief Classes for the CAST-128 and CAST-256 block ciphers
5 
6 #ifndef CRYPTOPP_CAST_H
7 #define CRYPTOPP_CAST_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 
12 NAMESPACE_BEGIN(CryptoPP)
13 
14 class CAST
15 {
16 protected:
17  static const word32 S[8][256];
18 };
19 
20 //! algorithm info
21 struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16>
22 {
23  static const char *StaticAlgorithmName() {return "CAST-128";}
24 };
25 
26 /// <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-128">CAST-128</a>
28 {
29  class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST128_Info>
30  {
31  public:
32  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
33 
34  protected:
35  bool reduced;
37  };
38 
39  class CRYPTOPP_NO_VTABLE Enc : public Base
40  {
41  public:
42  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
43  };
44 
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 public:
54 };
55 
56 //! algorithm info
57 struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32>
58 {
59  static const char *StaticAlgorithmName() {return "CAST-256";}
60 };
61 
62 //! <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-256">CAST-256</a>
64 {
65  class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST256_Info>
66  {
67  public:
68  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
69  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
70 
71  protected:
72  static const word32 t_m[8][24];
73  static const unsigned int t_r[8][24];
74 
75  static void Omega(int i, word32 kappa[8]);
76 
78  };
79 
80 public:
83 };
84 
87 
90 
91 NAMESPACE_END
92 
93 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:385
Classes and functions for secure memory allocations.
CAST-128
Definition: cast.h:27
Inherited by block ciphers with fixed block size.
Definition: seckey.h:34
CAST-256
Definition: cast.h:63
Classes and functions for implementing secret key algorithms.
Definition: cast.h:14
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:152
algorithm info
Definition: cast.h:57
Provides class member functions to access BlockCipher constants.
Definition: seckey.h:292
Crypto++ library namespace.
algorithm info
Definition: cast.h:21
Interface for retrieving values given their names.
Definition: cryptlib.h:261