Line | Count | Source (jump to first uncovered line) |
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 | 0 | 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 ¶ms); |
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 |