1 | // skipjack.h - written and placed in the public domain by Wei Dai |
---|
2 | |
---|
3 | //! \file skipjack.h |
---|
4 | //! \brief Classes for the SKIPJACK block cipher |
---|
5 | |
---|
6 | #ifndef CRYPTOPP_SKIPJACK_H |
---|
7 | #define CRYPTOPP_SKIPJACK_H |
---|
8 | |
---|
9 | #include "seckey.h" |
---|
10 | #include "secblock.h" |
---|
11 | |
---|
12 | NAMESPACE_BEGIN(CryptoPP) |
---|
13 | |
---|
14 | //! \class SKIPJACK_Info |
---|
15 | //! \brief SKIPJACK block cipher information |
---|
16 | struct SKIPJACK_Info : public FixedBlockSize<8>, public FixedKeyLength<10> |
---|
17 | { |
---|
18 | CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "SKIPJACK";} |
---|
19 | }; |
---|
20 | |
---|
21 | //! \class SKIPJACK |
---|
22 | //! \brief SKIPJACK block cipher |
---|
23 | //! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#SKIPJACK">SKIPJACK</a> |
---|
24 | class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation |
---|
25 | { |
---|
26 | //! \class Base |
---|
27 | //! \brief SKIPJACK block cipher default operation |
---|
28 | class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SKIPJACK_Info> |
---|
29 | { |
---|
30 | public: |
---|
31 | void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms); |
---|
32 | unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word16>();} |
---|
33 | |
---|
34 | protected: |
---|
35 | static const byte fTable[256]; |
---|
36 | |
---|
37 | FixedSizeSecBlock<byte, 10*256> tab; |
---|
38 | }; |
---|
39 | |
---|
40 | //! \class Enc |
---|
41 | //! \brief SKIPJACK block cipher encryption operation |
---|
42 | class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base |
---|
43 | { |
---|
44 | public: |
---|
45 | void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
---|
46 | private: |
---|
47 | static const byte Se[256]; |
---|
48 | static const word32 Te[4][256]; |
---|
49 | }; |
---|
50 | |
---|
51 | //! \class Dec |
---|
52 | //! \brief SKIPJACK block cipher decryption operation |
---|
53 | class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base |
---|
54 | { |
---|
55 | public: |
---|
56 | void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; |
---|
57 | private: |
---|
58 | static const byte Sd[256]; |
---|
59 | static const word32 Td[4][256]; |
---|
60 | }; |
---|
61 | |
---|
62 | public: |
---|
63 | typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption; |
---|
64 | typedef BlockCipherFinal<DECRYPTION, Dec> Decryption; |
---|
65 | }; |
---|
66 | |
---|
67 | typedef SKIPJACK::Encryption SKIPJACKEncryption; |
---|
68 | typedef SKIPJACK::Decryption SKIPJACKDecryption; |
---|
69 | |
---|
70 | NAMESPACE_END |
---|
71 | |
---|
72 | #endif |
---|