Back to home page

EIC code displayed by LXR

 
 

    


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

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

0002 
0003 /// \file shark.h

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

0005 /// \since Crypto++ 2.1

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

0017 /// \since Crypto++ 2.1

0018 struct SHARK_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<6, 2>
0019 {
0020     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "SHARK-E";}
0021 };
0022 
0023 /// \brief SHARK block cipher

0024 /// <a href="http://www.cryptopp.com/wiki/SHARK-E">SHARK-E</a>

0025 /// \since Crypto++ 2.1

0026 class SHARK : public SHARK_Info, public BlockCipherDocumentation
0027 {
0028     /// \brief SHARK block cipher default operation

0029     /// \since Crypto++ 2.1

0030     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SHARK_Info>
0031     {
0032     public:
0033         void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &param);
0034 
0035     protected:
0036         unsigned int m_rounds;
0037         SecBlock<word64> m_roundKeys;
0038     };
0039 
0040     /// \brief SHARK block cipher encryption operation

0041     /// \since Crypto++ 2.1

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         // used by Base to do key setup

0048         void InitForKeySetup();
0049 
0050     private:
0051         static const byte sbox[256];
0052         static const word64 cbox[8][256];
0053     };
0054 
0055     /// \brief SHARK block cipher decryption operation

0056     /// \since Crypto++ 2.1

0057     class CRYPTOPP_NO_VTABLE Dec : public Base
0058     {
0059     public:
0060         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0061 
0062     private:
0063         static const byte sbox[256];
0064         static const word64 cbox[8][256];
0065     };
0066 
0067 public:
0068     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0069     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0070 };
0071 
0072 typedef SHARK::Encryption SHARKEncryption;
0073 typedef SHARK::Decryption SHARKDecryption;
0074 
0075 NAMESPACE_END
0076 
0077 #endif