Back to home page

EIC code displayed by LXR

 
 

    


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

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

0002 
0003 /// \file shacal2.h

0004 /// \brief Classes for the SHACAL-2 block cipher

0005 /// \since Crypto++ 5.2, Intel SHA since Crypto++ 6.0

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

0016 struct SHACAL2_Info : public FixedBlockSize<32>, public VariableKeyLength<16, 16, 64>
0017 {
0018     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SHACAL-2";}
0019 };
0020 
0021 /// \brief SHACAL2 block cipher

0022 /// \since Crypto++ 5.2, Intel SHA since Crypto++ 6.0

0023 /// \sa <a href="http://www.cryptopp.com/wiki/SHACAL-2">SHACAL-2</a>

0024 class SHACAL2 : public SHACAL2_Info, public BlockCipherDocumentation
0025 {
0026     /// \brief SHACAL2 block cipher transformation functions

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

0028     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHACAL2_Info>
0029     {
0030     public:
0031         std::string AlgorithmProvider() const;
0032         void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
0033 
0034     protected:
0035         FixedSizeAlignedSecBlock<word32, 64> m_key;
0036 
0037         static const word32 K[64];
0038     };
0039 
0040     /// \brief SHACAL2 block cipher transformation functions

0041     /// \details Encryption transformation

0042     class CRYPTOPP_NO_VTABLE Enc : public Base
0043     {
0044     public:
0045         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0046     };
0047 
0048     /// \brief SHACAL2 block cipher transformation functions

0049     /// \details Decryption transformation

0050     class CRYPTOPP_NO_VTABLE Dec : public Base
0051     {
0052     public:
0053         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0054     };
0055 
0056 public:
0057     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0058     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0059 };
0060 
0061 typedef SHACAL2::Encryption SHACAL2Encryption;
0062 typedef SHACAL2::Decryption SHACAL2Decryption;
0063 
0064 NAMESPACE_END
0065 
0066 #endif