aria.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // aria.h - written and placed in the public domain by Jeffrey Walton
  2. /// \file aria.h
  3. /// \brief Classes for the ARIA block cipher
  4. /// \details The Crypto++ ARIA implementation is based on the 32-bit implementation by Aaram Yun
  5. /// from the National Security Research Institute, KOREA. Aaram Yun's implementation is based on
  6. /// the 8-bit implementation by Jin Hong. The source files are available in ARIA.zip from the Korea
  7. /// Internet & Security Agency website.
  8. /// \sa <A HREF="http://tools.ietf.org/html/rfc5794">RFC 5794, A Description of the ARIA Encryption Algorithm</A>,
  9. /// <A HREF="http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002">Korea
  10. /// Internet & Security Agency homepage</A>
  11. #ifndef CRYPTOPP_ARIA_H
  12. #define CRYPTOPP_ARIA_H
  13. #include "config.h"
  14. #include "seckey.h"
  15. #include "secblock.h"
  16. NAMESPACE_BEGIN(CryptoPP)
  17. /// \brief ARIA block cipher information
  18. /// \since Crypto++ 6.0
  19. struct ARIA_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
  20. {
  21. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "ARIA";}
  22. };
  23. /// \brief ARIA block cipher
  24. /// \details The Crypto++ ARIA implementation is based on the 32-bit implementation by Aaram Yun
  25. /// from the National Security Research Institute, KOREA. Aaram Yun's implementation is based on
  26. /// the 8-bit implementation by Jin Hong. The source files are available in ARIA.zip from the Korea
  27. /// Internet & Security Agency website.
  28. /// \sa <A HREF="http://tools.ietf.org/html/rfc5794">RFC 5794, A Description of the ARIA Encryption Algorithm</A>,
  29. /// <A HREF="http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002">Korea
  30. /// Internet & Security Agency homepage</A>
  31. /// \sa <a href="http://www.cryptopp.com/wiki/ARIA">ARIA</a>
  32. /// \since Crypto++ 6.0
  33. class ARIA : public ARIA_Info, public BlockCipherDocumentation
  34. {
  35. public:
  36. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ARIA_Info>
  37. {
  38. public:
  39. Base() : m_rounds(0) {}
  40. protected:
  41. void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &params);
  42. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  43. private:
  44. // Reference implementation allocates a table of 17 round keys.
  45. typedef SecBlock<byte, AllocatorWithCleanup<byte, true> > AlignedByteBlock;
  46. typedef SecBlock<word32, AllocatorWithCleanup<word32, true> > AlignedWordBlock;
  47. AlignedByteBlock m_rk; // round keys
  48. AlignedWordBlock m_w; // w0, w1, w2, w3, t and u
  49. unsigned int m_rounds;
  50. };
  51. public:
  52. typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
  53. typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
  54. };
  55. typedef ARIA::Encryption ARIAEncryption;
  56. typedef ARIA::Decryption ARIADecryption;
  57. NAMESPACE_END
  58. #endif