Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:08

0001 // serpent.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file serpent.h

0004 /// \brief Classes for the Serpent block cipher

0005 /// \sa <a href="https://www.cl.cam.ac.uk/~rja14/serpent.html">A

0006 ///  Candidate Block Cipher for the Advanced Encryption Standard</a>

0007 
0008 #ifndef CRYPTOPP_SERPENT_H
0009 #define CRYPTOPP_SERPENT_H
0010 
0011 #include "seckey.h"
0012 #include "secblock.h"
0013 
0014 NAMESPACE_BEGIN(CryptoPP)
0015 
0016 /// \brief Serpent block cipher information

0017 /// \since Crypto++ 3.1

0018 struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, public FixedRounds<32>
0019 {
0020     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Serpent";}
0021 };
0022 
0023 /// \brief Serpent block cipher

0024 /// \sa <a href="http://www.cryptopp.com/wiki/Serpent">Serpent</a> on the

0025 ///  Crypto++ wiki, <a href="https://www.cl.cam.ac.uk/~rja14/serpent.html">A

0026 ///  Candidate Block Cipher for the Advanced Encryption Standard</a>

0027 /// \since Crypto++ 3.1

0028 class Serpent : public Serpent_Info, public BlockCipherDocumentation
0029 {
0030     /// \brief Serpen block cipher base implementation

0031     /// \details Provides implementation common to encryption and decryption

0032     /// \since Crypto++ 3.1

0033     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Serpent_Info>
0034     {
0035     public:
0036         void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
0037 
0038     protected:
0039         FixedSizeSecBlock<word32, 33*4> m_key;
0040     };
0041 
0042     /// \brief Serpent encryption transformation

0043     /// \details Enc provides the encryption transformation.

0044     ///  All key sizes are supported.

0045     /// \since Crypto++ 3.1

0046     class CRYPTOPP_NO_VTABLE Enc : public Base
0047     {
0048     public:
0049         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0050     };
0051 
0052     /// \brief Serpent decryption transformation

0053     /// \details Dec provides the decryption transformation.

0054     ///  All key sizes are supported.

0055     /// \since Crypto++ 3.1

0056     class CRYPTOPP_NO_VTABLE Dec : public Base
0057     {
0058     public:
0059         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0060     };
0061 
0062 public:
0063     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0064     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0065 };
0066 
0067 typedef Serpent::Encryption SerpentEncryption;
0068 typedef Serpent::Decryption SerpentDecryption;
0069 
0070 NAMESPACE_END
0071 
0072 #endif  // CRYPTOPP_SERPENT_H