Back to home page

EIC code displayed by LXR

 
 

    


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

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

0002 
0003 /// \file skipjack.h

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

0005 /// \details The Crypto++ implementation conforms to SKIPJACK and KEA

0006 ///  Algorithm Specifications published by NIST in May 1998. The library passes

0007 ///  known answer tests available in NIST SP800-17, Table 6, pp. 140-42.

0008 /// \sa <a href ="http://csrc.nist.gov/encryption/skipjack/skipjack.pdf">SKIPJACK

0009 ///  and KEA Algorithm Specifications</a> (May 1998),

0010 ///  <a href="http://www.cryptopp.com/wiki/SKIPJACK">SKIPJACK</a> on the

0011 //   Crypto++ wiki

0012 
0013 #ifndef CRYPTOPP_SKIPJACK_H
0014 #define CRYPTOPP_SKIPJACK_H
0015 
0016 #include "seckey.h"
0017 #include "secblock.h"
0018 
0019 NAMESPACE_BEGIN(CryptoPP)
0020 
0021 /// \brief SKIPJACK block cipher information

0022 struct SKIPJACK_Info : public FixedBlockSize<8>, public FixedKeyLength<10>
0023 {
0024     CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "SKIPJACK";}
0025 };
0026 
0027 /// \brief SKIPJACK block cipher

0028 /// \details The Crypto++ implementation conforms to SKIPJACK and KEA

0029 ///  Algorithm Specifications published by NIST in May 1998. The library passes

0030 ///  known answer tests available in NIST SP800-17, Table 6, pp. 140-42.

0031 /// \sa <a href ="http://csrc.nist.gov/encryption/skipjack/skipjack.pdf">SKIPJACK

0032 ///  and KEA Algorithm Specifications</a> (May 1998),

0033 ///  <a href="http://www.cryptopp.com/wiki/SKIPJACK">SKIPJACK</a> on the

0034 ///  Crypto++ wiki

0035 class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation
0036 {
0037     /// \brief SKIPJACK block cipher default operation

0038     class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SKIPJACK_Info>
0039     {
0040     public:
0041         void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
0042         unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word16>();}
0043 
0044     protected:
0045         static const byte fTable[256];
0046 
0047         FixedSizeSecBlock<byte, 10*256> tab;
0048     };
0049 
0050     /// \brief SKIPJACK block cipher encryption operation

0051     class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Enc : public Base
0052     {
0053     public:
0054         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0055     private:
0056         static const byte Se[256];
0057         static const word32 Te[4][256];
0058     };
0059 
0060     /// \brief SKIPJACK block cipher decryption operation

0061     class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
0062     {
0063     public:
0064         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0065     private:
0066         static const byte Sd[256];
0067         static const word32 Td[4][256];
0068     };
0069 
0070 public:
0071     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0072     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0073 };
0074 
0075 typedef SKIPJACK::Encryption SKIPJACKEncryption;
0076 typedef SKIPJACK::Decryption SKIPJACKDecryption;
0077 
0078 NAMESPACE_END
0079 
0080 #endif