skipjack.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // skipjack.h - originally written and placed in the public domain by Wei Dai
  2. /// \file skipjack.h
  3. /// \brief Classes for the SKIPJACK block cipher
  4. /// \details The Crypto++ implementation conforms to SKIPJACK and KEA
  5. /// Algorithm Specifications published by NIST in May 1998. The library passes
  6. /// known answer tests available in NIST SP800-17, Table 6, pp. 140-42.
  7. /// \sa <a href ="http://csrc.nist.gov/encryption/skipjack/skipjack.pdf">SKIPJACK
  8. /// and KEA Algorithm Specifications</a> (May 1998),
  9. /// <a href="http://www.cryptopp.com/wiki/SKIPJACK">SKIPJACK</a> on the
  10. // Crypto++ wiki
  11. #ifndef CRYPTOPP_SKIPJACK_H
  12. #define CRYPTOPP_SKIPJACK_H
  13. #include "seckey.h"
  14. #include "secblock.h"
  15. NAMESPACE_BEGIN(CryptoPP)
  16. /// \brief SKIPJACK block cipher information
  17. struct SKIPJACK_Info : public FixedBlockSize<8>, public FixedKeyLength<10>
  18. {
  19. CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "SKIPJACK";}
  20. };
  21. /// \brief SKIPJACK block cipher
  22. /// \details The Crypto++ implementation conforms to SKIPJACK and KEA
  23. /// Algorithm Specifications published by NIST in May 1998. The library passes
  24. /// known answer tests available in NIST SP800-17, Table 6, pp. 140-42.
  25. /// \sa <a href ="http://csrc.nist.gov/encryption/skipjack/skipjack.pdf">SKIPJACK
  26. /// and KEA Algorithm Specifications</a> (May 1998),
  27. /// <a href="http://www.cryptopp.com/wiki/SKIPJACK">SKIPJACK</a> on the
  28. /// Crypto++ wiki
  29. class SKIPJACK : public SKIPJACK_Info, public BlockCipherDocumentation
  30. {
  31. /// \brief SKIPJACK block cipher default operation
  32. class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<SKIPJACK_Info>
  33. {
  34. public:
  35. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  36. unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word16>();}
  37. protected:
  38. static const byte fTable[256];
  39. FixedSizeSecBlock<byte, 10*256> tab;
  40. };
  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. /// \brief SKIPJACK block cipher decryption operation
  51. class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Dec : public Base
  52. {
  53. public:
  54. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  55. private:
  56. static const byte Sd[256];
  57. static const word32 Td[4][256];
  58. };
  59. public:
  60. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  61. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  62. };
  63. typedef SKIPJACK::Encryption SKIPJACKEncryption;
  64. typedef SKIPJACK::Decryption SKIPJACKDecryption;
  65. NAMESPACE_END
  66. #endif