Index: /trunk/KISA_SHA256.c
===================================================================
--- /trunk/KISA_SHA256.c	(revision 7)
+++ /trunk/KISA_SHA256.c	(revision 7)
@@ -0,0 +1,208 @@
+#include "KISA_SHA256.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+const UINT SHA256_K[64] = 
+{
+	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
+	0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
+	0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
+	0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
+	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
+	0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
+	0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
+	0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
+	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
+	0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
+	0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
+};
+
+#if defined(_MSC_VER)
+	#define ROTL_ULONG(x, n) _lrotl((x), (n))
+	#define ROTR_ULONG(x, n) _lrotr((x), (n))
+#else
+	#define ROTL_ULONG(x, n) ((ULONG)((x) << (n)) | (ULONG)((x) >> (32 - (n))))
+	#define ROTR_ULONG(x, n) ((ULONG)((x) >> (n)) | (ULONG)((x) << (32 - (n))))
+#endif
+
+#define ENDIAN_REVERSE_ULONG(dwS)	( (ROTL_ULONG((dwS),  8) & 0x00ff00ff)	\
+									| (ROTL_ULONG((dwS), 24) & 0xff00ff00) )
+
+#if defined(BIG_ENDIAN)
+	#define BIG_B2D(B, D)		D = *(ULONG_PTR)(B)
+	#define BIG_D2B(D, B)		*(ULONG_PTR)(B) = (ULONG)(D)
+	#define LITTLE_B2D(B, D)	D = ENDIAN_REVERSE_ULONG(*(ULONG_PTR)(B))
+	#define LITTLE_D2B(D, B)	*(ULONG_PTR)(B) = ENDIAN_REVERSE_ULONG(D)
+#elif defined(LITTLE_ENDIAN)
+	#define BIG_B2D(B, D)		D = ENDIAN_REVERSE_ULONG(*(ULONG_PTR)(B))
+	#define BIG_D2B(D, B)		*(ULONG_PTR)(B) = ENDIAN_REVERSE_ULONG(D)
+	#define LITTLE_B2D(B, D)	D = *(ULONG_PTR)(B)
+	#define LITTLE_D2B(D, B)	*(ULONG_PTR)(B) = (ULONG)(D)
+#else
+	#error ERROR : Invalid DataChangeType
+#endif
+
+#define RR(x, n)		ROTR_ULONG(x, n)
+#define SS(x, n)		(x >> n)
+
+#define Ch(x, y, z)		((x & y) ^ ((~x) & z))
+#define Maj(x, y, z)	((x & y) ^ (x & z) ^ (y & z))
+#define Sigma0(x)		(RR(x,  2) ^ RR(x, 13) ^ RR(x, 22))
+#define Sigma1(x)		(RR(x,  6) ^ RR(x, 11) ^ RR(x, 25))
+
+#define RHO0(x)			(RR(x,  7) ^ RR(x, 18) ^ SS(x,  3))
+#define RHO1(x)			(RR(x, 17) ^ RR(x, 19) ^ SS(x, 10))
+
+		
+//*********************************************************************************************************************************
+// o SHA256_Transform()	: 512 ºñÆ® ´ÜÀ§ ºí·ÏÀÇ ¸Þ½ÃÁö¸¦ ÀÔ·Â ¹Þ¾Æ ¿¬¼âº¯¼ö¸¦ °»½ÅÇÏ´Â ¾ÐÃà ÇÔ¼ö·Î½á
+//						  4 ¶ó¿îµå(64 ´Ü°è)·Î ±¸¼ºµÇ¸ç 8°³ÀÇ ¿¬¼âº¯¼ö(a, b, c, d, e, f, g, h)¸¦ »ç¿ë
+// o ÀÔ·Â				: Message		- ÀÔ·Â ¸Þ½ÃÁöÀÇ Æ÷ÀÎÅÍ º¯¼ö
+//						  ChainVar		- ¿¬¼âº¯¼öÀÇ Æ÷ÀÎÅÍ º¯¼ö
+// o Ãâ·Â				: 
+//*********************************************************************************************************************************
+void SHA256_Transform(ULONG_PTR Message, ULONG_PTR ChainVar)
+{
+	ULONG a, b, c, d, e, f, g, h, T1, X[64];
+	ULONG j;
+
+#define FF(a, b, c, d, e, f, g, h, j) {							\
+	T1 = h + Sigma1(e) + Ch(e, f, g) + SHA256_K[j] + X[j];		\
+	d += T1;													\
+	h = T1 + Sigma0(a) + Maj(a, b, c);							\
+}
+
+#if defined(BIG_ENDIAN)
+	#define GetData(x)	x
+#else
+	#define GetData(x)	ENDIAN_REVERSE_ULONG(x)
+#endif
+
+	for (j = 0; j < 16; j++)
+		X[j] = GetData(Message[j]);
+
+	for (j = 16; j < 64; j++)
+		X[j] = RHO1(X[j - 2]) + X[j - 7] + RHO0(X[j - 15]) + X[j - 16];
+
+	a = ChainVar[0];
+	b = ChainVar[1];
+	c = ChainVar[2];
+	d = ChainVar[3];
+	e = ChainVar[4];
+	f = ChainVar[5];
+	g = ChainVar[6];
+	h = ChainVar[7];
+
+	for (j = 0; j < 64; j += 8)
+	{
+		FF(a, b, c, d, e, f, g, h, j + 0);
+		FF(h, a, b, c, d, e, f, g, j + 1);
+		FF(g, h, a, b, c, d, e, f, j + 2);
+		FF(f, g, h, a, b, c, d, e, j + 3);
+		FF(e, f, g, h, a, b, c, d, j + 4);
+		FF(d, e, f, g, h, a, b, c, j + 5);
+		FF(c, d, e, f, g, h, a, b, j + 6);
+		FF(b, c, d, e, f, g, h, a, j + 7);
+	}
+
+	ChainVar[0] += a;
+	ChainVar[1] += b;
+	ChainVar[2] += c;
+	ChainVar[3] += d;
+	ChainVar[4] += e;
+	ChainVar[5] += f;
+	ChainVar[6] += g;
+	ChainVar[7] += h;
+}
+
+//*********************************************************************************************************************************
+// o SHA256_Init()		: ¿¬¼âº¯¼ö¿Í ±æÀÌº¯¼ö¸¦ ÃÊ±âÈ­ÇÏ´Â ÇÔ¼ö
+// o ÀÔ·Â				: Info		-  SHA-256 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ º¯¼ö
+// o Ãâ·Â				: 
+//*********************************************************************************************************************************
+void SHA256_Init( OUT SHA256_INFO *Info )
+{
+	Info->uChainVar[0] = 0x6a09e667;
+	Info->uChainVar[1] = 0xbb67ae85;
+	Info->uChainVar[2] = 0x3c6ef372;
+	Info->uChainVar[3] = 0xa54ff53a;
+	Info->uChainVar[4] = 0x510e527f;
+	Info->uChainVar[5] = 0x9b05688c;
+	Info->uChainVar[6] = 0x1f83d9ab;
+	Info->uChainVar[7] = 0x5be0cd19;
+
+	Info->uHighLength = Info->uLowLength = 0;
+}
+
+//*********************************************************************************************************************************
+// o SHA256_Process()	: ÀÓÀÇÀÇ ±æÀÌ¸¦ °¡Áö´Â ÀÔ·Â ¸Þ½ÃÁö¸¦ 512 ºñÆ® ºí·Ï ´ÜÀ§·Î ³ª´©¾î ¾ÐÃàÇÔ¼ö¸¦ È£ÃâÇÏ´Â ÇÔ¼ö
+// o ÀÔ·Â				: Info		 - SHA-256 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ º¯¼ö
+//						  pszMessage - ÀÔ·Â ¸Þ½ÃÁöÀÇ Æ÷ÀÎÅÍ º¯¼ö
+//						  uDataLen	 - ÀÔ·Â ¸Þ½ÃÁöÀÇ ¹ÙÀÌÆ® ±æÀÌ
+// o Ãâ·Â				: 
+//*********************************************************************************************************************************
+void SHA256_Process( OUT SHA256_INFO *Info, IN const BYTE *pszMessage, IN UINT uDataLen )
+{
+	if ((Info->uLowLength += (uDataLen << 3)) < 0)
+		Info->uHighLength++;
+
+	Info->uHighLength += (uDataLen >> 29);
+
+	while (uDataLen >= SHA256_DIGEST_BLOCKLEN)
+	{
+		memcpy((UCHAR_PTR)Info->szBuffer, pszMessage, (SINT)SHA256_DIGEST_BLOCKLEN);
+		SHA256_Transform((ULONG_PTR)Info->szBuffer, Info->uChainVar);
+		pszMessage += SHA256_DIGEST_BLOCKLEN;
+		uDataLen -= SHA256_DIGEST_BLOCKLEN;
+	}
+
+	memcpy((UCHAR_PTR)Info->szBuffer, pszMessage, uDataLen);
+}
+
+//*********************************************************************************************************************************
+// o SHA256_Close()		: ¸Þ½ÃÁö µ¡ºÙÀÌ±â¿Í ±æÀÌ µ¡ºÙÀÌ±â¸¦ ¼öÇàÇÑ ÈÄ ¸¶Áö¸· ¸Þ½ÃÁö ºí·ÏÀ» °¡Áö°í ¾ÐÃàÇÔ¼ö¸¦ È£ÃâÇÏ´Â ÇÔ¼ö
+// o ÀÔ·Â				: Info	    - SHA-256 ±¸Á¶Ã¼ÀÇ Æ÷ÀÎÅÍ º¯¼ö
+//						  pszDigest	- SHA-256 ÇØ½¬°ªÀ» ÀúÀåÇÒ Æ÷ÀÎÅÍ º¯¼ö
+// o Ãâ·Â				:
+//*********************************************************************************************************************************
+void SHA256_Close( OUT SHA256_INFO *Info, IN BYTE *pszDigest )
+{
+	ULONG i, Index;
+
+	Index = (Info->uLowLength >> 3) % SHA256_DIGEST_BLOCKLEN;
+	Info->szBuffer[Index++] = 0x80;
+
+	if (Index > SHA256_DIGEST_BLOCKLEN - 8)
+	{
+		memset((UCHAR_PTR)Info->szBuffer + Index, 0, (SINT)(SHA256_DIGEST_BLOCKLEN - Index));
+		SHA256_Transform((ULONG_PTR)Info->szBuffer, Info->uChainVar);
+		memset((UCHAR_PTR)Info->szBuffer, 0, (SINT)SHA256_DIGEST_BLOCKLEN - 8);
+	}
+	else
+		memset((UCHAR_PTR)Info->szBuffer + Index, 0, (SINT)(SHA256_DIGEST_BLOCKLEN - Index - 8));
+
+#if defined(LITTLE_ENDIAN)
+	Info->uLowLength = ENDIAN_REVERSE_ULONG(Info->uLowLength);
+	Info->uHighLength = ENDIAN_REVERSE_ULONG(Info->uHighLength);
+#endif
+
+	((ULONG_PTR)Info->szBuffer)[SHA256_DIGEST_BLOCKLEN / 4 - 2] = Info->uHighLength;
+	((ULONG_PTR)Info->szBuffer)[SHA256_DIGEST_BLOCKLEN / 4 - 1] = Info->uLowLength;
+
+	SHA256_Transform((ULONG_PTR)Info->szBuffer, Info->uChainVar);
+
+	for (i = 0; i < SHA256_DIGEST_VALUELEN; i += 4)
+		BIG_D2B((Info->uChainVar)[i / 4], &(pszDigest[i]));
+}
+
+void SHA256_Encrpyt( IN const BYTE *pszMessage, IN UINT uPlainTextLen, OUT BYTE *pszDigest )
+{
+	SHA256_INFO info;
+
+	SHA256_Init( &info );
+
+	SHA256_Process( &info, pszMessage, uPlainTextLen );
+
+	SHA256_Close( &info, pszDigest );
+}
Index: /trunk/KISA_SHA256.h
===================================================================
--- /trunk/KISA_SHA256.h	(revision 7)
+++ /trunk/KISA_SHA256.h	(revision 7)
@@ -0,0 +1,101 @@
+/**
+@file KISA_SHA_256.h
+@brief SHA256 ¾ÏÈ£ ¾Ë°í¸®Áò
+@author Copyright (c) 2013 by KISA
+@remarks http://seed.kisa.or.kr/
+*/
+
+#ifndef SHA256_H
+#define SHA256_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#ifndef OUT
+#define OUT
+#endif
+
+#ifndef IN
+#define IN
+#endif
+
+#ifndef INOUT
+#define INOUT
+#endif
+
+#undef BIG_ENDIAN
+#undef LITTLE_ENDIAN
+
+#if defined(USER_BIG_ENDIAN)
+	#define BIG_ENDIAN
+#elif defined(USER_LITTLE_ENDIAN)
+	#define LITTLE_ENDIAN
+#else
+	#if 0
+		#define BIG_ENDIAN
+	#elif defined(_MSC_VER)
+		#define LITTLE_ENDIAN
+	#else
+		#error
+	#endif
+#endif
+
+typedef unsigned long ULONG;
+typedef ULONG* ULONG_PTR;
+
+typedef unsigned int UINT;
+typedef UINT* UINT_PTR;
+
+typedef signed int SINT;
+typedef SINT* SINT_PTR;
+
+typedef unsigned char UCHAR;
+typedef UCHAR* UCHAR_PTR;
+
+typedef unsigned char BYTE;
+
+#define SHA256_DIGEST_BLOCKLEN	64
+#define SHA256_DIGEST_VALUELEN	32
+
+typedef struct{
+	UINT uChainVar[SHA256_DIGEST_VALUELEN / 4];
+	UINT uHighLength;
+	UINT uLowLength;
+	BYTE szBuffer[SHA256_DIGEST_BLOCKLEN];
+} SHA256_INFO;
+
+/**
+@brief ¿¬¼âº¯¼ö¿Í ±æÀÌº¯¼ö¸¦ ÃÊ±âÈ­ÇÏ´Â ÇÔ¼ö
+@param Info : SHA256_Process È£Ãâ ½Ã »ç¿ëµÇ´Â ±¸Á¶Ã¼
+*/
+void SHA256_Init( OUT SHA256_INFO *Info );
+
+/**
+@brief ¿¬¼âº¯¼ö¿Í ±æÀÌº¯¼ö¸¦ ÃÊ±âÈ­ÇÏ´Â ÇÔ¼ö
+@param Info : SHA256_Init È£ÃâÇÏ¿© ÃÊ±âÈ­µÈ ±¸Á¶Ã¼(³»ºÎÀûÀ¸·Î »ç¿ëµÈ´Ù.)
+@param pszMessage : »ç¿ëÀÚ ÀÔ·Â Æò¹®
+@param inLen : »ç¿ëÀÚ ÀÔ·Â Æò¹® ±æÀÌ
+*/
+void SHA256_Process( OUT SHA256_INFO *Info, IN const BYTE *pszMessage, IN UINT uDataLen );
+
+/**
+@brief ¸Þ½ÃÁö µ¡ºÙÀÌ±â¿Í ±æÀÌ µ¡ºÙÀÌ±â¸¦ ¼öÇàÇÑ ÈÄ ¸¶Áö¸· ¸Þ½ÃÁö ºí·ÏÀ» °¡Áö°í ¾ÐÃàÇÔ¼ö¸¦ È£ÃâÇÏ´Â ÇÔ¼ö
+@param Info : SHA256_Init È£ÃâÇÏ¿© ÃÊ±âÈ­µÈ ±¸Á¶Ã¼(³»ºÎÀûÀ¸·Î »ç¿ëµÈ´Ù.)
+@param pszDigest : ¾ÏÈ£¹®
+*/
+void SHA256_Close( OUT SHA256_INFO *Info, OUT BYTE *pszDigest );
+
+/**
+@brief »ç¿ëÀÚ ÀÔ·Â Æò¹®À» ÇÑ¹ø¿¡ Ã³¸®
+@param pszMessage : »ç¿ëÀÚ ÀÔ·Â Æò¹®
+@param pszDigest : ¾ÏÈ£¹®
+@remarks ³»ºÎÀûÀ¸·Î SHA256_Init, SHA256_Process, SHA256_Close¸¦ È£ÃâÇÑ´Ù.
+*/
+void SHA256_Encrpyt( IN const BYTE *pszMessage, IN UINT uPlainTextLen, OUT BYTE *pszDigest );
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif
Index: /trunk/aria.c
===================================================================
--- /trunk/aria.c	(revision 7)
+++ /trunk/aria.c	(revision 7)
@@ -0,0 +1,428 @@
+#include "aria.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+static byte SBOX_1[16][16] = {
+	{0x63,0x7c,0x77,0x7b,0xf2,0x6b,0x6f,0xc5,0x30,0x01,0x67,0x2b,0xfe,0xd7,0xab,0x76},
+	{0xca,0x82,0xc9,0x7d,0xfa,0x59,0x47,0xf0,0xad,0xd4,0xa2,0xaf,0x9c,0xa4,0x72,0xc0},
+	{0xb7,0xfd,0x93,0x26,0x36,0x3f,0xf7,0xcc,0x34,0xa5,0xe5,0xf1,0x71,0xd8,0x31,0x15},
+	{0x04,0xc7,0x23,0xc3,0x18,0x96,0x05,0x9a,0x07,0x12,0x80,0xe2,0xeb,0x27,0xb2,0x75},
+	{0x09,0x83,0x2c,0x1a,0x1b,0x6e,0x5a,0xa0,0x52,0x3b,0xd6,0xb3,0x29,0xe3,0x2f,0x84},
+	{0x53,0xd1,0x00,0xed,0x20,0xfc,0xb1,0x5b,0x6a,0xcb,0xbe,0x39,0x4a,0x4c,0x58,0xcf},
+	{0xd0,0xef,0xaa,0xfb,0x43,0x4d,0x33,0x85,0x45,0xf9,0x02,0x7f,0x50,0x3c,0x9f,0xa8},
+	{0x51,0xa3,0x40,0x8f,0x92,0x9d,0x38,0xf5,0xbc,0xb6,0xda,0x21,0x10,0xff,0xf3,0xd2},
+	{0xcd,0x0c,0x13,0xec,0x5f,0x97,0x44,0x17,0xc4,0xa7,0x7e,0x3d,0x64,0x5d,0x19,0x73},
+	{0x60,0x81,0x4f,0xdc,0x22,0x2a,0x90,0x88,0x46,0xee,0xb8,0x14,0xde,0x5e,0x0b,0xdb},
+	{0xe0,0x32,0x3a,0x0a,0x49,0x06,0x24,0x5c,0xc2,0xd3,0xac,0x62,0x91,0x95,0xe4,0x79},
+	{0xe7,0xc8,0x37,0x6d,0x8d,0xd5,0x4e,0xa9,0x6c,0x56,0xf4,0xea,0x65,0x7a,0xae,0x08},
+	{0xba,0x78,0x25,0x2e,0x1c,0xa6,0xb4,0xc6,0xe8,0xdd,0x74,0x1f,0x4b,0xbd,0x8b,0x8a},
+	{0x70,0x3e,0xb5,0x66,0x48,0x03,0xf6,0x0e,0x61,0x35,0x57,0xb9,0x86,0xc1,0x1d,0x9e},
+	{0xe1,0xf8,0x98,0x11,0x69,0xd9,0x8e,0x94,0x9b,0x1e,0x87,0xe9,0xce,0x55,0x28,0xdf},
+	{0x8c,0xa1,0x89,0x0d,0xbf,0xe6,0x42,0x68,0x41,0x99,0x2d,0x0f,0xb0,0x54,0xbb,0x16}
+};
+
+static byte SBOX_1_I[16][16] = {
+	{0x52,0x09,0x6a,0xd5,0x30,0x36,0xa5,0x38,0xbf,0x40,0xa3,0x9e,0x81,0xf3,0xd7,0xfb},
+	{0x7c,0xe3,0x39,0x82,0x9b,0x2f,0xff,0x87,0x34,0x8e,0x43,0x44,0xc4,0xde,0xe9,0xcb},
+	{0x54,0x7b,0x94,0x32,0xa6,0xc2,0x23,0x3d,0xee,0x4c,0x95,0x0b,0x42,0xfa,0xc3,0x4e},
+	{0x08,0x2e,0xa1,0x66,0x28,0xd9,0x24,0xb2,0x76,0x5b,0xa2,0x49,0x6d,0x8b,0xd1,0x25},
+	{0x72,0xf8,0xf6,0x64,0x86,0x68,0x98,0x16,0xd4,0xa4,0x5c,0xcc,0x5d,0x65,0xb6,0x92},
+	{0x6c,0x70,0x48,0x50,0xfd,0xed,0xb9,0xda,0x5e,0x15,0x46,0x57,0xa7,0x8d,0x9d,0x84},
+	{0x90,0xd8,0xab,0x00,0x8c,0xbc,0xd3,0x0a,0xf7,0xe4,0x58,0x05,0xb8,0xb3,0x45,0x06},
+	{0xd0,0x2c,0x1e,0x8f,0xca,0x3f,0x0f,0x02,0xc1,0xaf,0xbd,0x03,0x01,0x13,0x8a,0x6b},
+	{0x3a,0x91,0x11,0x41,0x4f,0x67,0xdc,0xea,0x97,0xf2,0xcf,0xce,0xf0,0xb4,0xe6,0x73},
+	{0x96,0xac,0x74,0x22,0xe7,0xad,0x35,0x85,0xe2,0xf9,0x37,0xe8,0x1c,0x75,0xdf,0x6e},
+	{0x47,0xf1,0x1a,0x71,0x1d,0x29,0xc5,0x89,0x6f,0xb7,0x62,0x0e,0xaa,0x18,0xbe,0x1b},
+	{0xfc,0x56,0x3e,0x4b,0xc6,0xd2,0x79,0x20,0x9a,0xdb,0xc0,0xfe,0x78,0xcd,0x5a,0xf4},
+	{0x1f,0xdd,0xa8,0x33,0x88,0x07,0xc7,0x31,0xb1,0x12,0x10,0x59,0x27,0x80,0xec,0x5f},
+	{0x60,0x51,0x7f,0xa9,0x19,0xb5,0x4a,0x0d,0x2d,0xe5,0x7a,0x9f,0x93,0xc9,0x9c,0xef},
+	{0xa0,0xe0,0x3b,0x4d,0xae,0x2a,0xf5,0xb0,0xc8,0xeb,0xbb,0x3c,0x83,0x53,0x99,0x61},
+	{0x17,0x2b,0x04,0x7e,0xba,0x77,0xd6,0x26,0xe1,0x69,0x14,0x63,0x55,0x21,0x0c,0x7d}
+};
+
+static byte SBOX_2[16][16] = {
+	{0xe2,0x4e,0x54,0xfc,0x94,0xc2,0x4a,0xcc,0x62,0x0d,0x6a,0x46,0x3c,0x4d,0x8b,0xd1},
+	{0x5e,0xfa,0x64,0xcb,0xb4,0x97,0xbe,0x2b,0xbc,0x77,0x2e,0x03,0xd3,0x19,0x59,0xc1},
+	{0x1d,0x06,0x41,0x6b,0x55,0xf0,0x99,0x69,0xea,0x9c,0x18,0xae,0x63,0xdf,0xe7,0xbb},
+	{0x00,0x73,0x66,0xfb,0x96,0x4c,0x85,0xe4,0x3a,0x09,0x45,0xaa,0x0f,0xee,0x10,0xeb},
+	{0x2d,0x7f,0xf4,0x29,0xac,0xcf,0xad,0x91,0x8d,0x78,0xc8,0x95,0xf9,0x2f,0xce,0xcd},
+	{0x08,0x7a,0x88,0x38,0x5c,0x83,0x2a,0x28,0x47,0xdb,0xb8,0xc7,0x93,0xa4,0x12,0x53},
+	{0xff,0x87,0x0e,0x31,0x36,0x21,0x58,0x48,0x01,0x8e,0x37,0x74,0x32,0xca,0xe9,0xb1},
+	{0xb7,0xab,0x0c,0xd7,0xc4,0x56,0x42,0x26,0x07,0x98,0x60,0xd9,0xb6,0xb9,0x11,0x40},
+	{0xec,0x20,0x8c,0xbd,0xa0,0xc9,0x84,0x04,0x49,0x23,0xf1,0x4f,0x50,0x1f,0x13,0xdc},
+	{0xd8,0xc0,0x9e,0x57,0xe3,0xc3,0x7b,0x65,0x3b,0x02,0x8f,0x3e,0xe8,0x25,0x92,0xe5},
+	{0x15,0xdd,0xfd,0x17,0xa9,0xbf,0xd4,0x9a,0x7e,0xc5,0x39,0x67,0xfe,0x76,0x9d,0x43},
+	{0xa7,0xe1,0xd0,0xf5,0x68,0xf2,0x1b,0x34,0x70,0x05,0xa3,0x8a,0xd5,0x79,0x86,0xa8},
+	{0x30,0xc6,0x51,0x4b,0x1e,0xa6,0x27,0xf6,0x35,0xd2,0x6e,0x24,0x16,0x82,0x5f,0xda},
+	{0xe6,0x75,0xa2,0xef,0x2c,0xb2,0x1c,0x9f,0x5d,0x6f,0x80,0x0a,0x72,0x44,0x9b,0x6c},
+	{0x90,0x0b,0x5b,0x33,0x7d,0x5a,0x52,0xf3,0x61,0xa1,0xf7,0xb0,0xd6,0x3f,0x7c,0x6d},
+	{0xed,0x14,0xe0,0xa5,0x3d,0x22,0xb3,0xf8,0x89,0xde,0x71,0x1a,0xaf,0xba,0xb5,0x81}
+};
+
+static byte SBOX_2_I[16][16] = {
+	{0x30,0x68,0x99,0x1b,0x87,0xb9,0x21,0x78,0x50,0x39,0xdb,0xe1,0x72,0x09,0x62,0x3c},
+	{0x3e,0x7e,0x5e,0x8e,0xf1,0xa0,0xcc,0xa3,0x2a,0x1d,0xfb,0xb6,0xd6,0x20,0xc4,0x8d},
+	{0x81,0x65,0xf5,0x89,0xcb,0x9d,0x77,0xc6,0x57,0x43,0x56,0x17,0xd4,0x40,0x1a,0x4d},
+	{0xc0,0x63,0x6c,0xe3,0xb7,0xc8,0x64,0x6a,0x53,0xaa,0x38,0x98,0x0c,0xf4,0x9b,0xed},
+	{0x7f,0x22,0x76,0xaf,0xdd,0x3a,0x0b,0x58,0x67,0x88,0x06,0xc3,0x35,0x0d,0x01,0x8b},
+	{0x8c,0xc2,0xe6,0x5f,0x02,0x24,0x75,0x93,0x66,0x1e,0xe5,0xe2,0x54,0xd8,0x10,0xce},
+	{0x7a,0xe8,0x08,0x2c,0x12,0x97,0x32,0xab,0xb4,0x27,0x0a,0x23,0xdf,0xef,0xca,0xd9},
+	{0xb8,0xfa,0xdc,0x31,0x6b,0xd1,0xad,0x19,0x49,0xbd,0x51,0x96,0xee,0xe4,0xa8,0x41},
+	{0xda,0xff,0xcd,0x55,0x86,0x36,0xbe,0x61,0x52,0xf8,0xbb,0x0e,0x82,0x48,0x69,0x9a},
+	{0xe0,0x47,0x9e,0x5c,0x04,0x4b,0x34,0x15,0x79,0x26,0xa7,0xde,0x29,0xae,0x92,0xd7},
+	{0x84,0xe9,0xd2,0xba,0x5d,0xf3,0xc5,0xb0,0xbf,0xa4,0x3b,0x71,0x44,0x46,0x2b,0xfc},
+	{0xeb,0x6f,0xd5,0xf6,0x14,0xfe,0x7c,0x70,0x5a,0x7d,0xfd,0x2f,0x18,0x83,0x16,0xa5},
+	{0x91,0x1f,0x05,0x95,0x74,0xa9,0xc1,0x5b,0x4a,0x85,0x6d,0x13,0x07,0x4f,0x4e,0x45},
+	{0xb2,0x0f,0xc9,0x1c,0xa6,0xbc,0xec,0x73,0x90,0x7b,0xcf,0x59,0x8f,0xa1,0xf9,0x2d},
+	{0xf2,0xb1,0x00,0x94,0x37,0x9f,0xd0,0x2e,0x9c,0x6e,0x28,0x3f,0x80,0xf0,0x3d,0xd3},
+	{0x25,0x8a,0xb5,0xe7,0x42,0xb3,0xc7,0xea,0xf7,0x4c,0x11,0x33,0x03,0xa2,0xac,0x60}
+};
+
+static byte C1[] = {0x51,0x7c,0xc1,0xb7,0x27,0x22,0x0a,0x94,
+					0xfe,0x13,0xab,0xe8,0xfa,0x9a,0x6e,0xe0};
+
+static byte C2[] = {0x6d,0xb1,0x4a,0xcc,0x9e,0x21,0xc8,0x20,
+					0xff,0x28,0xb1,0xd5,0xef,0x5d,0xe2,0xb0};
+
+static byte C3[] = {0xdb,0x92,0x37,0x1d,0x21,0x26,0xe9,0x70,
+					0x03,0x24,0x97,0x75,0x04,0xe8,0xc9,0x0e};
+
+int
+CHEV_ARIA_SubstitutionLayer (byte * state,
+							 byte * out)
+{
+#define LT(in, out)												\
+	(out)[0] = SBOX_1  [((in)[0] & 0xf0) >> 4][(in)[0] & 0x0f];	\
+	(out)[1] = SBOX_2  [((in)[1] & 0xf0) >> 4][(in)[1] & 0x0f];	\
+	(out)[2] = SBOX_1_I[((in)[2] & 0xf0) >> 4][(in)[2] & 0x0f];	\
+	(out)[3] = SBOX_2_I[((in)[3] & 0xf0) >> 4][(in)[3] & 0x0f]
+
+	LT (state +  0, out +  0);
+	LT (state +  4, out +  4);
+	LT (state +  8, out +  8);
+	LT (state + 12, out + 12);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_SubstitutionLayer_I (byte * state,
+							   byte * out)
+{
+#define LT_I(in, out)											\
+	(out)[0] = SBOX_1_I[((in)[0] & 0xf0) >> 4][(in)[0] & 0x0f];	\
+	(out)[1] = SBOX_2_I[((in)[1] & 0xf0) >> 4][(in)[1] & 0x0f];	\
+	(out)[2] = SBOX_1  [((in)[2] & 0xf0) >> 4][(in)[2] & 0x0f];	\
+	(out)[3] = SBOX_2  [((in)[3] & 0xf0) >> 4][(in)[3] & 0x0f]
+
+	LT_I (state +  0, out +  0);
+	LT_I (state +  4, out +  4);
+	LT_I (state +  8, out +  8);
+	LT_I (state + 12, out + 12);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_DiffusionLayer (byte * state,
+						  byte * out)
+{
+#define DIFFUSION(st, i1, i2, i3, i4, i5, i6, i7) \
+	(st[i1] ^ st[i2] ^ st[i3] ^ st[i4] ^ st[i5] ^ st[i6] ^ st[i7])
+
+	out[ 0] = DIFFUSION (state, 3, 4, 6,  8,  9, 13, 14);
+	out[ 1] = DIFFUSION (state, 2, 5, 7,  8,  9, 12, 15);
+	out[ 2] = DIFFUSION (state, 1, 4, 6, 10, 11, 12, 15);
+	out[ 3] = DIFFUSION (state, 0, 5, 7, 10, 11, 13, 14);
+	out[ 4] = DIFFUSION (state, 0, 2, 5,  8, 11, 14, 15);
+	out[ 5] = DIFFUSION (state, 1, 3, 4,  9, 10, 14, 15);
+	out[ 6] = DIFFUSION (state, 0, 2, 7,  9, 10, 12, 13);
+	out[ 7] = DIFFUSION (state, 1, 3, 6,  8, 11, 12, 13);
+	out[ 8] = DIFFUSION (state, 0, 1, 4,  7, 10, 13, 15);
+	out[ 9] = DIFFUSION (state, 0, 1, 5,  6, 11, 12, 14);
+	out[10] = DIFFUSION (state, 2, 3, 5,  6,  8, 13, 15);
+	out[11] = DIFFUSION (state, 2, 3, 4,  7,  9, 12, 14);
+	out[12] = DIFFUSION (state, 1, 2, 6,  7,  9, 11, 12);
+	out[13] = DIFFUSION (state, 0, 3, 6,  7,  8, 10, 13);
+	out[14] = DIFFUSION (state, 0, 3, 4,  5,  9, 11, 14);
+	out[15] = DIFFUSION (state, 1, 2, 4,  5,  8, 10, 15);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_FunctionFo (byte * state,
+					  byte * key,
+					  byte * out)
+{
+	byte buf1[16] = {0x00,};
+	byte buf2[16] = {0x00,};
+
+	CHEV_BIT_XOR (state, key, 128, buf1);
+	CHEV_ARIA_SubstitutionLayer (buf1, buf2);
+	CHEV_ARIA_DiffusionLayer (buf2, out);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_FunctionFe (byte * state,
+					  byte * key,
+					  byte * out)
+{
+	byte buf1[16] = {0x00,};
+	byte buf2[16] = {0x00,};
+
+	CHEV_BIT_XOR (state, key, 128, buf1);
+	CHEV_ARIA_SubstitutionLayer_I (buf1, buf2);
+	CHEV_ARIA_DiffusionLayer (buf2, out);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_FunctionFf (byte * state,
+					  byte * key1,
+					  byte * key2,
+					  byte * out)
+{
+	byte buf1[16] = {0x00,};
+	byte buf2[16] = {0x00,};
+
+	CHEV_BIT_XOR (state, key1, 128, buf1);
+	CHEV_ARIA_SubstitutionLayer_I (buf1, buf2);
+	CHEV_BIT_XOR (buf2, key2, 128, out);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_GenerateEncryptionKey (CHEV_ARIA_INFO	* info,
+								 byte			* w0,
+								 byte			* w1,
+								 byte			* w2,
+								 byte			* w3)
+{
+	byte buf[16] = {0x00,};
+
+#define ROT_XOR_19(keep, rot, out)				\
+	CHEV_BIT_RotateRight (rot, buf, 128, 19);	\
+	CHEV_BIT_XOR (buf, keep, 128, out)
+
+#define ROT_XOR_31(keep, rot, out)				\
+	CHEV_BIT_RotateRight (rot, buf, 128, 31);	\
+	CHEV_BIT_XOR (buf, keep, 128, out)
+
+#define ROT_XOR_67(keep, rot, out)				\
+	CHEV_BIT_RotateRight (rot, buf, 128, 67);	\
+	CHEV_BIT_XOR (buf, keep, 128, out)
+
+#define ROT_XOR_97(keep, rot, out)				\
+	CHEV_BIT_RotateRight (rot, buf, 128, 97);	\
+	CHEV_BIT_XOR (buf, keep, 128, out)
+
+#define ROT_XOR_109(keep, rot, out)				\
+	CHEV_BIT_RotateRight (rot, buf, 128, 109);	\
+	CHEV_BIT_XOR (buf, keep, 128, out)
+
+	ROT_XOR_19 (w0, w1, info->ek[ 0]);
+	ROT_XOR_19 (w1, w2, info->ek[ 1]);
+	ROT_XOR_19 (w2, w3, info->ek[ 2]);
+	ROT_XOR_19 (w3, w0, info->ek[ 3]);
+
+	ROT_XOR_31 (w0, w1, info->ek[ 4]);
+	ROT_XOR_31 (w1, w2, info->ek[ 5]);
+	ROT_XOR_31 (w2, w3, info->ek[ 6]);
+	ROT_XOR_31 (w3, w0, info->ek[ 7]);
+
+	ROT_XOR_67 (w0, w1, info->ek[ 8]);
+	ROT_XOR_67 (w1, w2, info->ek[ 9]);
+	ROT_XOR_67 (w2, w3, info->ek[10]);
+	ROT_XOR_67 (w3, w0, info->ek[11]);
+
+	ROT_XOR_97 (w0, w1, info->ek[12]);
+
+	if (info->type > CHEV_ARIA_128)
+	{
+		ROT_XOR_97 (w1, w2, info->ek[13]);
+		ROT_XOR_97 (w2, w3, info->ek[14]);
+
+		if (info->type > CHEV_ARIA_192)
+		{
+			ROT_XOR_97 (w3, w0, info->ek[15]);
+			ROT_XOR_109 (w0, w1, info->ek[16]);
+		}
+	}
+
+	return 0;
+}
+
+int
+CHEV_ARIA_GenerateDecryptionKey (CHEV_ARIA_INFO	* info)
+{
+	int iter = 0;
+	int lastRound = info->round - 1;
+
+	memcpy (info->dk[0], info->ek[lastRound], 16);
+	memcpy (info->dk[lastRound], info->ek[0], 16);
+
+	for (iter = 1 ; iter < lastRound ; iter++)
+	{
+		CHEV_ARIA_DiffusionLayer (info->ek[iter], info->dk[lastRound - iter]);
+	}
+
+	return 0;
+}
+
+int
+CHEV_ARIA_GenerateRoundKey (CHEV_ARIA_INFO	* info,
+							byte			* key)
+{
+	byte * ck1 = NULL;
+	byte * ck2 = NULL;
+	byte * ck3 = NULL;
+
+	/* 128-bits */
+	byte w0[16] = {0x00,};
+	byte w1[16] = {0x00,};
+	byte w2[16] = {0x00,};
+	byte w3[16] = {0x00,};
+
+	byte buf[16] = {0x00,};
+
+	switch (info->type)
+	{
+		case CHEV_ARIA_128: ck1 = C1; ck2 = C2; ck3 = C3; break;
+		case CHEV_ARIA_192: ck1 = C2; ck2 = C3; ck3 = C1; break;
+		case CHEV_ARIA_256: ck1 = C3; ck2 = C1; ck3 = C2; break;
+		default: return -1;
+	}
+
+	/* step 1. Initialize Round Key */
+	/* step 1.1. w0 */
+	memcpy (w0, key, 16);
+
+	/* step 1.2. w1 */
+	CHEV_ARIA_FunctionFo (w0, ck1, buf);
+	CHEV_BIT_XOR (buf, &key[16], 128, w1);
+
+	/* step 1.3. w2 */
+	CHEV_ARIA_FunctionFe (w1, ck2, buf);
+	CHEV_BIT_XOR (buf, w0, 128, w2);
+
+	/* step 1.4. w3 */
+	CHEV_ARIA_FunctionFo (w2, ck3, buf);
+	CHEV_BIT_XOR (buf, w1, 128, w3);
+
+	/* step 2. Generate Round Key (Key Expansion) */
+	CHEV_ARIA_GenerateEncryptionKey (info, w0, w1, w2, w3);
+	CHEV_ARIA_GenerateDecryptionKey (info);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_Initialize (CHEV_ARIA_INFO	* info,
+					  CHEV_ARIA_TYPE	type,
+					  byte				* inputKey,
+					  int				keySize)
+{
+#define CHEV_ARIA_KEY_SIZE	32 /* 256-bits */
+	int		algSize = 16 + (8 * (int)type);
+	byte	key[CHEV_ARIA_KEY_SIZE] = {0x00,};
+
+	memset (info, 0x00, sizeof (CHEV_ARIA_INFO));
+
+	info->type = type;
+
+	switch (type)
+	{
+		case CHEV_ARIA_128: info->round = 13; break;
+		case CHEV_ARIA_192: info->round = 15; break;
+		case CHEV_ARIA_256: info->round = 17; break;
+		default: return -1;
+	}
+
+	memcpy (key, inputKey, (keySize < algSize) ? keySize : algSize);
+
+	CHEV_ARIA_GenerateRoundKey (info, key);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_CryptBlock (CHEV_ARIA_INFO	* info,
+					  byte				key[17][16],
+					  byte				* input,
+					  byte				* out)
+{
+	int iter = 0;
+	int round = info->round - 3;
+
+	byte buf1[16] = {0x00,};
+	byte buf2[16] = {0x00,};
+
+	memcpy (buf1, input, 16);
+
+	for (iter = 0 ; iter < round ; iter += 2)
+	{
+		CHEV_ARIA_FunctionFo (buf1, key[iter    ], buf2);
+		CHEV_ARIA_FunctionFe (buf2, key[iter + 1], buf1);
+	}
+
+	CHEV_ARIA_FunctionFo (buf1, key[iter    ], buf2);
+	CHEV_ARIA_FunctionFf (buf2, key[iter + 1], key[iter + 2], out);
+
+	return 0;
+}
+
+int
+CHEV_ARIA_EncryptBlock (CHEV_ARIA_INFO	* info,
+						byte			* input,
+						byte			* out)
+{
+	return CHEV_ARIA_CryptBlock (info, info->ek, input, out);
+}
+
+int
+CHEV_ARIA_DecryptBlock (CHEV_ARIA_INFO	* info,
+						byte			* input,
+						byte			* out)
+{
+	return CHEV_ARIA_CryptBlock (info, info->dk, input, out);
+}
+
+int
+CHEV_ARIA_Encrypt (CHEV_ARIA_INFO	* info,
+				   byte				* input,
+				   int				inSize,
+				   byte				* out,
+				   int				* outSize)
+{
+	int iter = 0;
+
+	for (iter = 0 ; iter < inSize ; iter += 16)
+		CHEV_ARIA_EncryptBlock (info, input + iter, out + iter);
+
+	*outSize = iter;
+
+	return 0;
+}
+
+int
+CHEV_ARIA_Decrypt (CHEV_ARIA_INFO	* info,
+				   byte				* input,
+				   int				inSize,
+				   byte				* out,
+				   int				* outSize)
+{
+	int iter = 0;
+
+	for (iter = 0 ; iter < inSize ; iter += 16)
+		CHEV_ARIA_DecryptBlock (info, input + iter, out + iter);
+
+	*outSize = iter;
+
+	return 0;
+}
Index: /trunk/aria.h
===================================================================
--- /trunk/aria.h	(revision 7)
+++ /trunk/aria.h	(revision 7)
@@ -0,0 +1,39 @@
+#include "bit.h"
+
+/* definition */
+typedef enum
+{
+	CHEV_ARIA_128 = 0,
+	CHEV_ARIA_192,
+	CHEV_ARIA_256
+} CHEV_ARIA_TYPE;
+
+typedef struct
+{
+	CHEV_ARIA_TYPE	type;
+	int				round;
+	byte			ek[17][16 /* 128-bits */];
+	byte			dk[17][16 /* 128-bits */];
+} CHEV_ARIA_INFO;
+
+/* function */
+int
+CHEV_ARIA_Initialize	(CHEV_ARIA_INFO	* info,
+						 CHEV_ARIA_TYPE	type,
+						 byte			* inputKey,
+						 int			keySize);
+
+int
+CHEV_ARIA_Encrypt		(CHEV_ARIA_INFO	* info,
+						 byte			* input,
+						 int			inSize,
+						 byte			* out,
+						 int			* outSize);
+
+int
+CHEV_ARIA_Decrypt		(CHEV_ARIA_INFO	* info,
+						 byte			* input,
+						 int			inSize,
+						 byte			* out,
+						 int			* outSize);
+
Index: /trunk/bit.c
===================================================================
--- /trunk/bit.c	(revision 7)
+++ /trunk/bit.c	(revision 7)
@@ -0,0 +1,157 @@
+#include "bit.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+CHEV_BIT_ShiftLeft (byte	* in,
+					byte	* out,
+					int		size,
+					int		offset)
+{
+	int		iter = 0;
+
+	int		quota = offset / 8;
+	int		remain = offset % 8;
+	int		byteSize = size / 8;
+	int		loop = byteSize - quota;
+
+	int		idx = 0;
+	int		maskPos = 8 - remain;
+	byte	mask = 0xff << (8 - remain);
+
+	out[0] = in[0 + quota] << remain;
+
+	for (iter = 1 ; iter < loop ; iter++)
+	{
+		idx = iter + quota;
+
+		out[iter    ]  = (in[idx]       ) << remain;
+		out[iter - 1] |= (in[idx] & mask) >> maskPos;
+	}
+
+	return 0;
+}
+
+int
+CHEV_BIT_ShiftRight (byte	* in,
+					 byte	* out,
+					 int	size,
+					 int	offset)
+{
+	int		iter = 0;
+
+	int		quota = offset / 8;
+	int		remain = offset % 8;
+	int		byteSize = size / 8;
+	int		loop = quota - 1;
+
+	int		idx = 0;
+	int		maskPos = 8 - remain;
+	byte	mask = 0xff >> (8 - remain);
+
+	out[byteSize - 1] = in[byteSize - 1 - quota] >> remain;
+
+	for (iter = byteSize - 2 ; iter > loop ; iter--)
+	{
+		idx = iter - quota;
+
+		out[iter    ]  = (in[idx]       ) >> remain;
+		out[iter + 1] |= (in[idx] & mask) << maskPos;
+	}
+
+	return 0;
+}
+
+int
+CHEV_BIT_RotateLeft (byte	* in,
+					 byte	* out,
+					 int	size,
+					 int	offset)
+{
+	int		result = 0;
+	byte	* buf1 = NULL;
+
+	buf1 = (byte *) calloc (size, 2);
+
+	if (!buf1)
+		return -1;
+
+	CHEV_BIT_ShiftLeft (in, buf1, size, offset);
+	CHEV_BIT_ShiftRight (in, buf1 + size, size, size - offset);
+
+	CHEV_BIT_OR (buf1, buf1 + size, size, out);
+
+	free (buf1);
+
+	return result;
+}
+
+int
+CHEV_BIT_RotateRight (byte	* in,
+					  byte	* out,
+					  int	size,
+					  int	offset)
+{
+	int		result = 0;
+	byte	* buf1 = NULL;
+
+	buf1 = (byte *) calloc (size, 2);
+
+	if (!buf1)
+		return -1;
+
+	CHEV_BIT_ShiftRight (in, buf1, size, offset);
+	CHEV_BIT_ShiftLeft (in, buf1 + size, size, size - offset);
+
+	CHEV_BIT_OR (buf1, buf1 + size, size, out);
+
+	free (buf1);
+
+	return result;
+}
+
+int
+CHEV_BIT_AND (byte	* in1,
+			  byte	* in2,
+			  int	size,
+			  byte	* out)
+{
+	int iter = 0;
+	int quota = size / 8;
+
+	for (iter = 0 ; iter < quota ; iter++)
+		out[iter] = in1[iter] & in2[iter];
+
+	return 0;
+}
+
+int
+CHEV_BIT_OR (byte	* in1,
+			 byte	* in2,
+			 int	size,
+			 byte	* out)
+{
+	int iter = 0;
+	int quota = size / 8;
+
+	for (iter = 0 ; iter < quota ; iter++)
+		out[iter] = in1[iter] | in2[iter];
+
+	return 0;
+}
+
+int
+CHEV_BIT_XOR (byte	* in1,
+			  byte	* in2,
+			  int	size,
+			  byte	* out)
+{
+	int iter = 0;
+	int quota = size / 8;
+
+	for (iter = 0 ; iter < quota ; iter++)
+		out[iter] = in1[iter] ^ in2[iter];
+
+	return 0;
+}
Index: /trunk/bit.h
===================================================================
--- /trunk/bit.h	(revision 7)
+++ /trunk/bit.h	(revision 7)
@@ -0,0 +1,43 @@
+
+typedef unsigned char byte;
+
+int
+CHEV_BIT_ShiftLeft		(byte	* in,
+						 byte	* out,
+						 int	size,
+						 int	offset);
+int
+CHEV_BIT_ShiftRight		(byte	* in,
+						 byte	* out,
+						 int	size,
+						 int	offset);
+
+int
+CHEV_BIT_RotateLeft		(byte	* in,
+						 byte	* out,
+						 int	size,
+						 int	offset);
+
+int
+CHEV_BIT_RotateRight	(byte	* in,
+						 byte	* out,
+						 int	size,
+						 int	offset);
+
+int
+CHEV_BIT_AND			(byte	* in1,
+						 byte	* in2,
+						 int	size,
+						 byte	* out);
+
+int
+CHEV_BIT_OR				(byte	* in1,
+						 byte	* in2,
+						 int	size,
+						 byte	* out);
+
+int
+CHEV_BIT_XOR			(byte	* in1,
+						 byte	* in2,
+						 int	size,
+						 byte	* out);
Index: /trunk/crypto.cpp
===================================================================
--- /trunk/crypto.cpp	(revision 7)
+++ /trunk/crypto.cpp	(revision 7)
@@ -0,0 +1,71 @@
+#include "crypto.h"
+
+#include "KISA_SHA256.h"
+
+#define ARIA_BLOCKSIZE	16
+
+crypto::crypto()
+{
+}
+
+void crypto::setKey(cf::bin & key)
+{
+	CHEV_ARIA_Initialize(&info, CHEV_ARIA_256, key.buffer(), key.size());
+}
+
+cf::bin crypto::sha256(cf::bin & input)
+{
+	cf::bin out;
+
+	out.resize(SHA256_DIGEST_VALUELEN);
+
+	SHA256_Encrpyt(input.buffer(), input.size(), out.buffer());
+
+	return out;
+}
+
+cf::bin crypto::encrypt(cf::bin & input)
+{
+	cf::bin plain;
+	cf::bin out;
+	int outSize;
+
+	plain = input + getPaddingBytes(ARIA_BLOCKSIZE, input.size());
+
+	out.resize(plain.size());
+
+	CHEV_ARIA_Encrypt(&info, plain.buffer(), plain.size(), out.buffer(), &outSize);
+
+	return out;
+}
+
+cf::bin crypto::decrypt(cf::bin & input)
+{
+	int plainSize;
+	int paddingSize;
+	cf::bin out;
+	int outSize;
+
+	out.resize(input.size());
+
+	CHEV_ARIA_Decrypt(&info, input.buffer(), input.size(), out.buffer(), &outSize);
+
+	paddingSize = out[outSize - 1];
+
+	plainSize = outSize - paddingSize;
+	out.resize(plainSize);
+
+	return out;
+}
+
+cf::bin crypto::getPaddingBytes(int blockSize, int inputSize)
+{
+	int paddingSize = blockSize - (inputSize % blockSize);
+	cf::bin result;
+
+	result.resize(paddingSize);
+
+	memset(result.buffer(), paddingSize, paddingSize);
+
+	return result;
+}
Index: /trunk/crypto.h
===================================================================
--- /trunk/crypto.h	(revision 7)
+++ /trunk/crypto.h	(revision 7)
@@ -0,0 +1,23 @@
+#pragma once
+
+#include "cf/bin.h"
+#include "aria.h"
+
+class crypto
+{
+private:
+	CHEV_ARIA_INFO info;
+
+public:
+	crypto();
+
+	void setKey(cf::bin & key);
+
+	cf::bin sha256(cf::bin & input);
+
+	cf::bin encrypt(cf::bin & input);
+
+	cf::bin decrypt(cf::bin & input);
+
+	cf::bin getPaddingBytes(int blockSize, int inputSize);
+};
Index: /trunk/msgsrv.cpp
===================================================================
--- /trunk/msgsrv.cpp	(revision 6)
+++ /trunk/msgsrv.cpp	(revision 7)
@@ -481,4 +481,9 @@
 }
 
+int createSessionID(std::string & idList)
+{
+	return 0;
+}
+
 int main(int argc, char ** argv)
 {
Index: /trunk/msvc14/chevmsgr.sln
===================================================================
--- /trunk/msvc14/chevmsgr.sln	(revision 6)
+++ /trunk/msvc14/chevmsgr.sln	(revision 7)
@@ -17,4 +17,6 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ChevMsgrClient_MFC", "ChevMsgrClient_MFC\ChevMsgrClient_MFC.vcxproj", "{D1A1A73A-7E56-40FA-9D43-B8737C585D18}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "crypto", "crypto\crypto.vcxproj", "{A5238B12-5F59-4AF2-BC5C-DD93352082FD}"
 EndProject
 Global
@@ -58,4 +60,12 @@
 		{D1A1A73A-7E56-40FA-9D43-B8737C585D18}.Release|x86.ActiveCfg = Release|Win32
 		{D1A1A73A-7E56-40FA-9D43-B8737C585D18}.Release|x86.Build.0 = Release|Win32
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Debug|x64.ActiveCfg = Debug|x64
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Debug|x64.Build.0 = Debug|x64
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Debug|x86.ActiveCfg = Debug|Win32
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Debug|x86.Build.0 = Debug|Win32
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Release|x64.ActiveCfg = Release|x64
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Release|x64.Build.0 = Release|x64
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Release|x86.ActiveCfg = Release|Win32
+		{A5238B12-5F59-4AF2-BC5C-DD93352082FD}.Release|x86.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
Index: /trunk/msvc14/crypto/crypto.vcxproj
===================================================================
--- /trunk/msvc14/crypto/crypto.vcxproj	(revision 7)
+++ /trunk/msvc14/crypto/crypto.vcxproj	(revision 7)
@@ -0,0 +1,150 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>{A5238B12-5F59-4AF2-BC5C-DD93352082FD}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>crypto</RootNamespace>
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>NotSet</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>StaticLibrary</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\properties.props" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\properties.props" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\properties.props" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+    <Import Project="..\properties.props" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup />
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <WarningLevel>Level3</WarningLevel>
+      <PrecompiledHeader>
+      </PrecompiledHeader>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+    </ClCompile>
+    <Link>
+      <SubSystem>Windows</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\aria.c" />
+    <ClCompile Include="..\..\bit.c" />
+    <ClCompile Include="..\..\crypto.cpp" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\aria.h" />
+    <ClInclude Include="..\..\bit.h" />
+    <ClInclude Include="..\..\crypto.h" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>
Index: /trunk/msvc14/crypto/crypto.vcxproj.filters
===================================================================
--- /trunk/msvc14/crypto/crypto.vcxproj.filters	(revision 7)
+++ /trunk/msvc14/crypto/crypto.vcxproj.filters	(revision 7)
@@ -0,0 +1,39 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="소스 파일">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="헤더 파일">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+    </Filter>
+    <Filter Include="리소스 파일">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="..\..\crypto.cpp">
+      <Filter>소스 파일</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\aria.c">
+      <Filter>소스 파일</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\bit.c">
+      <Filter>소스 파일</Filter>
+    </ClCompile>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="..\..\crypto.h">
+      <Filter>소스 파일</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\aria.h">
+      <Filter>소스 파일</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\bit.h">
+      <Filter>소스 파일</Filter>
+    </ClInclude>
+  </ItemGroup>
+</Project>
