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