Crypto++  5.6.5
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 FixedKeyLength<16>, public VariableRounds<6, 2>
18 {
19  CRYPTOPP_STATIC_CONSTEXPR 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 Base
28  //! \brief SHARK block cipher default operation
29  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
30  {
31  public:
32  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &param);
33 
34  protected:
35  unsigned int m_rounds;
36  SecBlock<word64> m_roundKeys;
37  };
38 
39  //! \class Enc
40  //! \brief SHARK block cipher encryption operation
41  class CRYPTOPP_NO_VTABLE Enc : public Base
42  {
43  public:
44  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
45 
46  // used by Base to do key setup
47  void InitForKeySetup();
48 
49  private:
50  static const byte sbox[256];
51  static const word64 cbox[8][256];
52  };
53 
54  //! \class Dec
55  //! \brief SHARK 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  private:
62  static const byte sbox[256];
63  static const word64 cbox[8][256];
64  };
65 
66 public:
69 };
70 
73 
74 NAMESPACE_END
75 
76 #endif
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:127
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:408
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:1095
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:66
Classes and functions for implementing secret key algorithms.
SHARK block cipher information.
Definition: shark.h:17
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:279