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

mars.h
Go to the documentation of this file.
1 // mars.h - originally written and placed in the public domain by Wei Dai
2
3 /// \file mars.h
4 /// \brief Classes for the MARS block cipher (IBM AES submission)
5 /// \since Crypto++ 3.0
6
7 #ifndef CRYPTOPP_MARS_H
8 #define CRYPTOPP_MARS_H
9
10 #include "seckey.h"
11 #include "secblock.h"
12
13 NAMESPACE_BEGIN(CryptoPP)
14
15 /// \brief MARS block cipher information
16 /// \since Crypto++ 3.0
17 struct MARS_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 56, 8>
18 {
19 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "MARS";}
20 };
21
22 /// \brief MARS block cipher
23 /// \sa <a href="http://www.cryptopp.com/wiki/MARS">MARS</a>
24 /// \since Crypto++ 3.0
25 class MARS : public MARS_Info, public BlockCipherDocumentation
26 {
27 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<MARS_Info>
28 {
29 public:
30 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
31
32 protected:
33 static const word32 Sbox[512];
34
35 FixedSizeSecBlock<word32, 40> m_k;
36 };
37
38 class CRYPTOPP_NO_VTABLE Enc : public Base
39 {
40 public:
41 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
42 };
43
44 class CRYPTOPP_NO_VTABLE Dec : public Base
45 {
46 public:
47 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
48 };
49
50 public:
51 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
52 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
53 };
54
55 typedef MARS::Encryption MARSEncryption;
56 typedef MARS::Decryption MARSDecryption;
57
58 NAMESPACE_END
59
60 #endif
BlockCipherFinal< ENCRYPTION, Enc >
BlockCipherImpl
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:306
FixedBlockSize
Inherited by algorithms with fixed block size.
Definition: seckey.h:41
FixedSizeSecBlock< word32, 40 >
MARS
MARS block cipher.
Definition: mars.h:26
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:327
VariableKeyLength
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:166
word32
unsigned int word32
32-bit unsigned datatype
Definition: config_int.h:72
CryptoPP
Crypto++ library namespace.
secblock.h
Classes and functions for secure memory allocations.
seckey.h
Classes and functions for implementing secret key algorithms.
BlockCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition: seckey.h:399
MARS_Info
MARS block cipher information.
Definition: mars.h:18