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

serpent.h
Go to the documentation of this file.
1 // serpent.h - originally written and placed in the public domain by Wei Dai
2
3 /// \file serpent.h
4 /// \brief Classes for the Serpent block cipher
5 /// \sa <a href="https://www.cl.cam.ac.uk/~rja14/serpent.html">A
6 /// Candidate Block Cipher for the Advanced Encryption Standard</a>
7
8 #ifndef CRYPTOPP_SERPENT_H
9 #define CRYPTOPP_SERPENT_H
10
11 #include "seckey.h"
12 #include "secblock.h"
13
14 NAMESPACE_BEGIN(CryptoPP)
15
16 /// \brief Serpent block cipher information
17 /// \since Crypto++ 3.1
18 struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, public FixedRounds<32>
19 {
20 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Serpent";}
21 };
22
23 /// \brief Serpent block cipher
24 /// \sa <a href="http://www.cryptopp.com/wiki/Serpent">Serpent</a> on the
25 /// Crypto++ wiki, <a href="https://www.cl.cam.ac.uk/~rja14/serpent.html">A
26 /// Candidate Block Cipher for the Advanced Encryption Standard</a>
27 /// \since Crypto++ 3.1
28 class Serpent : public Serpent_Info, public BlockCipherDocumentation
29 {
30 /// \brief Serpen block cipher base implementation
31 /// \details Provides implementation common to encryption and decryption
32 /// \since Crypto++ 3.1
33 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Serpent_Info>
34 {
35 public:
36 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
37
38 protected:
39 FixedSizeSecBlock<word32, 33*4> m_key;
40 };
41
42 /// \brief Serpent encryption transformation
43 /// \details Enc provides the encryption transformation.
44 /// All key sizes are supported.
45 /// \since Crypto++ 3.1
46 class CRYPTOPP_NO_VTABLE Enc : public Base
47 {
48 public:
49 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
50 };
51
52 /// \brief Serpent decryption transformation
53 /// \details Dec provides the decryption transformation.
54 /// All key sizes are supported.
55 /// \since Crypto++ 3.1
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
62 public:
63 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
64 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
65 };
66
67 typedef Serpent::Encryption SerpentEncryption;
68 typedef Serpent::Decryption SerpentDecryption;
69
70 NAMESPACE_END
71
72 #endif // CRYPTOPP_SERPENT_H
BlockCipherFinal< ENCRYPTION, Enc >
BlockCipher
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1288
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
FixedRounds
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:53
FixedSizeSecBlock< word32, 33 *4 >
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:327
Serpent
Serpent block cipher.
Definition: serpent.h:29
VariableKeyLength
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:166
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
Serpent_Info
Serpent block cipher information.
Definition: serpent.h:19