中间件底层,websocket

serpent.h 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // serpent.h - originally written and placed in the public domain by Wei Dai
  2. /// \file serpent.h
  3. /// \brief Classes for the Serpent block cipher
  4. /// \sa <a href="https://www.cl.cam.ac.uk/~rja14/serpent.html">A
  5. /// Candidate Block Cipher for the Advanced Encryption Standard</a>
  6. #ifndef CRYPTOPP_SERPENT_H
  7. #define CRYPTOPP_SERPENT_H
  8. #include "seckey.h"
  9. #include "secblock.h"
  10. NAMESPACE_BEGIN(CryptoPP)
  11. /// \brief Serpent block cipher information
  12. /// \since Crypto++ 3.1
  13. struct Serpent_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>, public FixedRounds<32>
  14. {
  15. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Serpent";}
  16. };
  17. /// \brief Serpent block cipher
  18. /// \sa <a href="http://www.cryptopp.com/wiki/Serpent">Serpent</a> on the
  19. /// Crypto++ wiki, <a href="https://www.cl.cam.ac.uk/~rja14/serpent.html">A
  20. /// Candidate Block Cipher for the Advanced Encryption Standard</a>
  21. /// \since Crypto++ 3.1
  22. class Serpent : public Serpent_Info, public BlockCipherDocumentation
  23. {
  24. /// \brief Serpen block cipher base implementation
  25. /// \details Provides implementation common to encryption and decryption
  26. /// \since Crypto++ 3.1
  27. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Serpent_Info>
  28. {
  29. public:
  30. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  31. protected:
  32. FixedSizeSecBlock<word32, 33*4> m_key;
  33. };
  34. /// \brief Serpent encryption transformation
  35. /// \details Enc provides the encryption transformation.
  36. /// All key sizes are supported.
  37. /// \since Crypto++ 3.1
  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. /// \brief Serpent decryption transformation
  44. /// \details Dec provides the decryption transformation.
  45. /// All key sizes are supported.
  46. /// \since Crypto++ 3.1
  47. class CRYPTOPP_NO_VTABLE Dec : public Base
  48. {
  49. public:
  50. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  51. };
  52. public:
  53. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  54. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  55. };
  56. typedef Serpent::Encryption SerpentEncryption;
  57. typedef Serpent::Decryption SerpentDecryption;
  58. NAMESPACE_END
  59. #endif // CRYPTOPP_SERPENT_H