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 //! \class CAST128_Info
21 //! \brief CAST128 block cipher information
22 struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16>
23 {
24  static const char *StaticAlgorithmName() {return "CAST-128";}
25 };
26 
27 //! \class CAST128
28 //! \brief CAST128 block cipher
29 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-128">CAST-128</a>
31 {
32  class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST128_Info>
33  {
34  public:
35  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
36 
37  protected:
38  bool reduced;
40  };
41 
42  class CRYPTOPP_NO_VTABLE Enc : public Base
43  {
44  public:
45  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
46  };
47 
48  class CRYPTOPP_NO_VTABLE Dec : public Base
49  {
50  public:
51  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
52  };
53 
54 public:
57 };
58 
59 //! \class CAST256_Info
60 //! \brief CAST256 block cipher information
61 struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32>
62 {
63  static const char *StaticAlgorithmName() {return "CAST-256";}
64 };
65 
66 //! \class CAST256
67 //! \brief CAST256 block cipher
68 //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-256">CAST-256</a>
70 {
71  class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST256_Info>
72  {
73  public:
74  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
75  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
76 
77  protected:
78  static const word32 t_m[8][24];
79  static const unsigned int t_r[8][24];
80 
81  static void Omega(int i, word32 kappa[8]);
82 
84  };
85 
86 public:
89 };
90 
93 
96 
97 NAMESPACE_END
98 
99 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:396
Classes and functions for secure memory allocations.
CAST128 block cipher.
Definition: cast.h:30
Inherited by algorithms with fixed block size.
Definition: seckey.h:34
CAST256 block cipher.
Definition: cast.h:69
Classes and functions for implementing secret key algorithms.
Definition: cast.h:14
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:157
CAST256 block cipher information.
Definition: cast.h:61
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:303
Crypto++ library namespace.
CAST128 block cipher information.
Definition: cast.h:22
Interface for retrieving values given their names.
Definition: cryptlib.h:277