Crypto++ 8.6 Free C++ class library of cryptographic schemes

shark.h
Go to the documentation of this file.
1 // shark.h - originally written and placed in the public domain by Wei Dai
2
3 /// \file shark.h
4 /// \brief Classes for the SHARK block cipher
5 /// \since Crypto++ 2.1
6
7 #ifndef CRYPTOPP_SHARK_H
8 #define CRYPTOPP_SHARK_H
9
10 #include "config.h"
11 #include "seckey.h"
12 #include "secblock.h"
13
14 NAMESPACE_BEGIN(CryptoPP)
15
16 /// \brief SHARK block cipher information
17 /// \since Crypto++ 2.1
18 struct SHARK_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<6, 2>
19 {
20 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SHARK-E";}
21 };
22
23 /// \brief SHARK block cipher
24 /// <a href="http://www.cryptopp.com/wiki/SHARK-E">SHARK-E</a>
25 /// \since Crypto++ 2.1
26 class SHARK : public SHARK_Info, public BlockCipherDocumentation
27 {
28 /// \brief SHARK block cipher default operation
29 /// \since Crypto++ 2.1
30 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
31 {
32 public:
33 void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &param);
34
35 protected:
36 unsigned int m_rounds;
37 SecBlock<word64> m_roundKeys;
38 };
39
40 /// \brief SHARK block cipher encryption operation
41 /// \since Crypto++ 2.1
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 // used by Base to do key setup
48 void InitForKeySetup();
49
50 private:
51 static const byte sbox[256];
52 static const word64 cbox[8][256];
53 };
54
55 /// \brief SHARK block cipher decryption operation
56 /// \since Crypto++ 2.1
57 class CRYPTOPP_NO_VTABLE Dec : public Base
58 {
59 public:
60 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
61
62 private:
63 static const byte sbox[256];
64 static const word64 cbox[8][256];
65 };
66
67 public:
68 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
69 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
70 };
71
72 typedef SHARK::Encryption SHARKEncryption;
73 typedef SHARK::Decryption SHARKDecryption;
74
75 NAMESPACE_END
76
77 #endif
SHARK
SHARK block cipher SHARK-E
Definition: shark.h:26
secblock.h
Classes and functions for secure memory allocations.
word64
unsigned long long word64
64-bit unsigned datatype
Definition: config_int.h:91
FixedBlockSize
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
SHARK_Info
SHARK block cipher information.
Definition: shark.h:18
BlockCipherImpl
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:305
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:124
BlockCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition: seckey.h:398
seckey.h
Classes and functions for implementing secret key algorithms.
BlockCipherFinal< ENCRYPTION, Enc >
CryptoPP
Crypto++ library namespace.
config.h
Library configuration file.
BlockCipher
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1282
SecBlock< word64 >
VariableRounds
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:64
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:321