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 /** \file
10 */
11 
12 #include "seckey.h"
13 #include "secblock.h"
14 
15 NAMESPACE_BEGIN(CryptoPP)
16 
17 class CAST
18 {
19 protected:
20  static const word32 S[8][256];
21 };
22 
23 //! algorithm info
24 struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16>
25 {
26  static const char *StaticAlgorithmName() {return "CAST-128";}
27 };
28 
29 /// <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 //! algorithm info
60 struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32>
61 {
62  static const char *StaticAlgorithmName() {return "CAST-256";}
63 };
64 
65 //! <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-256">CAST-256</a>
67 {
68  class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST256_Info>
69  {
70  public:
71  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
72  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
73 
74  protected:
75  static const word32 t_m[8][24];
76  static const unsigned int t_r[8][24];
77 
78  static void Omega(int i, word32 kappa[8]);
79 
81  };
82 
83 public:
86 };
87 
90 
93 
94 NAMESPACE_END
95 
96 #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:30
Inherited by block ciphers with fixed block size.
Definition: seckey.h:34
CAST-256
Definition: cast.h:66
Classes and functions for implementing secret key algorithms.
Definition: cast.h:17
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:152
algorithm info
Definition: cast.h:60
Provides class member functions to access BlockCipher constants.
Definition: seckey.h:292
Crypto++ library namespace.
algorithm info
Definition: cast.h:24
Interface for retrieving values given their names.
Definition: cryptlib.h:261