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