summaryrefslogtreecommitdiff
path: root/aria.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-04-10 10:52:40 -0400
committerJeffrey Walton <noloader@gmail.com>2017-04-10 10:52:40 -0400
commit8ca0f479391c54ee454e9cddfcbe1657da240f85 (patch)
tree68b52541de179f62f3cd7e83c09f09bada8d4649 /aria.h
parent8c7408bcd56ab3177ee61fe68ff07cc16d13cdd4 (diff)
downloadcryptopp-git-8ca0f479391c54ee454e9cddfcbe1657da240f85.tar.gz
Add ARIA block cipher
This is the reference implementation, test data and test vectors from the ARIA.zip package on the KISA website. The website is located at http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002. We have optimized routines that improve Key Setup and Bulk Encryption performance, but they are not being checked-in at the moment. The ARIA team is updating its implementation for contemporary hardware and we would like to use it as a starting point before we wander too far away from the KISA implementation.
Diffstat (limited to 'aria.h')
-rw-r--r--aria.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/aria.h b/aria.h
new file mode 100644
index 00000000..de041f96
--- /dev/null
+++ b/aria.h
@@ -0,0 +1,59 @@
+// aria.h - written and placed in the public domain by Jeffrey Walton
+
+//! \file aria.h
+//! \brief Classes for the ARIA block cipher
+//! \sa <A HREF="http://tools.ietf.org/html/rfc5794">RFC 5794, A Description of the ARIA Encryption Algorithm</A>,
+//! <A HREF="http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002">Korea
+//! Internet & Security Agency homepage</A>
+
+#ifndef CRYPTOPP_ARIA_H
+#define CRYPTOPP_ARIA_H
+
+#include "config.h"
+#include "seckey.h"
+#include "secblock.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+//! \class ARIA_Info
+//! \brief ARIA block cipher information
+struct ARIA_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32, 8>
+{
+ CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "ARIA";}
+};
+
+//! \class ARIA
+//! \brief ARIA block cipher
+//! \sa <a href="http://www.weidai.com/scan-mirror/cs.html#ARIA">ARIA</a>
+class ARIA : public ARIA_Info, public BlockCipherDocumentation
+{
+public:
+ class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ARIA_Info>
+ {
+ public:
+ void UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &params);
+ void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
+
+ protected:
+ CRYPTOPP_ALIGN_DATA(16)
+ static const byte S[4][256];
+
+ CRYPTOPP_ALIGN_DATA(16)
+ static const byte KRK[3][16];
+
+ FixedSizeAlignedSecBlock<byte, 16*17> m_rkey; // round keys
+ FixedSizeAlignedSecBlock<byte, 16*6> m_w; // scratch, w0, w1, w2, w3 and t
+ unsigned int m_rounds;
+ };
+
+public:
+ typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
+ typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
+};
+
+typedef ARIA::Encryption ARIAEncryption;
+typedef ARIA::Decryption ARIADecryption;
+
+NAMESPACE_END
+
+#endif