Crypto++  5.6.3
Free C++ class library of cryptographic schemes
shark.h
Go to the documentation of this file.
1 // shark.h - written and placed in the public domain by Wei Dai
2 
3 //! \file shark.h
4 //! \brief Classes for the SHARK block cipher
5 
6 #ifndef CRYPTOPP_SHARK_H
7 #define CRYPTOPP_SHARK_H
8 
9 #include "config.h"
10 #include "seckey.h"
11 #include "secblock.h"
12 
13 NAMESPACE_BEGIN(CryptoPP)
14 
15 //! \class SHARK_Info
16 //! \brief SHARK block cipher information
17 struct SHARK_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 16>, public VariableRounds<6, 2>
18 {
19  static const char *StaticAlgorithmName() {return "SHARK-E";}
20 };
21 
22 //! \class SHARK
23 //! \brief SHARK block cipher
24 /// <a href="http://www.weidai.com/scan-mirror/cs.html#SHARK-E">SHARK-E</a>
26 {
27  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
28  {
29  public:
30  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &param);
31 
32  protected:
33  unsigned int m_rounds;
34  SecBlock<word64> m_roundKeys;
35  };
36 
37  class CRYPTOPP_NO_VTABLE Enc : public Base
38  {
39  public:
40  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
41 
42  // used by Base to do key setup
43  void InitForKeySetup();
44 
45  private:
46  static const byte sbox[256];
47  static const word64 cbox[8][256];
48  };
49 
50  class CRYPTOPP_NO_VTABLE Dec : public Base
51  {
52  public:
53  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
54 
55  private:
56  static const byte sbox[256];
57  static const word64 cbox[8][256];
58  };
59 
60 public:
63 };
64 
67 
68 NAMESPACE_END
69 
70 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:396
SHARK block cipher SHARK-E
Definition: shark.h:25
Library configuration file.
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1091
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:34
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:60
Classes and functions for implementing secret key algorithms.
SHARK block cipher information.
Definition: shark.h:17
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:157
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:303
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:277