ARIA build integration
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 1c98558..8c21754 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -1798,6 +1798,15 @@
#define MBEDTLS_CAMELLIA_C
/**
+ * \def MBEDTLS_ARIA_C
+ *
+ * Enable the ARIA block cipher.
+ *
+ * Module: library/aria.c
+ */
+#define MBEDTLS_ARIA_C
+
+/**
* \def MBEDTLS_CCM_C
*
* Enable the Counter with CBC-MAC (CCM) mode for 128-bit block cipher.
diff --git a/include/mbedtls/error.h b/include/mbedtls/error.h
index 8b4d3a8..5bdb6bb 100644
--- a/include/mbedtls/error.h
+++ b/include/mbedtls/error.h
@@ -63,6 +63,7 @@
* CTR_DBRG 4 0x0034-0x003A
* ENTROPY 3 0x003C-0x0040 0x003D-0x003F
* NET 11 0x0042-0x0052 0x0043-0x0045
+ * ARIA 1 0x005C-0x005E
* ASN1 7 0x0060-0x006C
* CMAC 1 0x007A-0x007A
* PBKDF2 1 0x007C-0x007C
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 02ccea8..96992c1 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -6,6 +6,7 @@
aes.c
aesni.c
arc4.c
+ aria.c
asn1parse.c
asn1write.c
base64.c
diff --git a/library/Makefile b/library/Makefile
index 65a102f..6420281 100644
--- a/library/Makefile
+++ b/library/Makefile
@@ -47,6 +47,7 @@
OBJS_CRYPTO= aes.o aesni.o arc4.o \
asn1parse.o asn1write.o base64.o \
bignum.o blowfish.o camellia.o \
+ aria.o \
ccm.o cipher.o cipher_wrap.o \
cmac.o ctr_drbg.o des.o \
dhm.o ecdh.o ecdsa.o \
diff --git a/library/aria.c b/library/aria.c
index da31f09..9121d8f 100644
--- a/library/aria.c
+++ b/library/aria.c
@@ -651,10 +651,8 @@
// Mode tests from "Test Vectors for ARIA" Version 1.0
// http://210.104.33.10/ARIA/doc/ARIA-testvector-e.pdf
-#if (defined(MBEDTLS_CIPHER_MODE_CBC) || \
- defined(MBEDTLS_CIPHER_MODE_CFB) || \
+#if (defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB) || \
defined(MBEDTLS_CIPHER_MODE_CTR))
-
static const uint8_t aria_test2_key[32] =
{
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // 128 bit
@@ -663,12 +661,6 @@
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff // 256 bit
};
-static const uint8_t aria_test2_iv[16] =
-{
- 0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78, // same for all
- 0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0
-};
-
static const uint8_t aria_test2_pt[48] =
{
0x11, 0x11, 0x11, 0x11, 0xaa, 0xaa, 0xaa, 0xaa, // same for all
@@ -678,10 +670,15 @@
0x22, 0x22, 0x22, 0x22, 0xaa, 0xaa, 0xaa, 0xaa,
0x22, 0x22, 0x22, 0x22, 0xbb, 0xbb, 0xbb, 0xbb,
};
+#endif
-#endif /* defined(MBEDTLS_CIPHER_MODE_CBC) || \
- defined(MBEDTLS_CIPHER_MODE_CFB) || \
- defined(MBEDTLS_CIPHER_MODE_CTR) */
+#if (defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB))
+static const uint8_t aria_test2_iv[16] =
+{
+ 0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78, // same for CBC, CFB
+ 0x87, 0x96, 0xa5, 0xb4, 0xc3, 0xd2, 0xe1, 0xf0 // CTR has zero IV
+};
+#endif
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const uint8_t aria_test2_cbc_ct[3][48] = // CBC ciphertxt
@@ -774,10 +771,15 @@
int i;
uint8_t blk[16];
mbedtls_aria_context ctx;
+
+#if (defined(MBEDTLS_CIPHER_MODE_CFB) || \
+ defined(MBEDTLS_CIPHER_MODE_CTR))
+ size_t j;
+#endif
+
#if (defined(MBEDTLS_CIPHER_MODE_CBC) || \
defined(MBEDTLS_CIPHER_MODE_CFB) || \
defined(MBEDTLS_CIPHER_MODE_CTR))
- size_t j;
uint8_t buf[48], iv[16];
#endif
diff --git a/library/error.c b/library/error.c
index 0292480..1668077 100644
--- a/library/error.c
+++ b/library/error.c
@@ -65,6 +65,10 @@
#include "mbedtls/camellia.h"
#endif
+#if defined(MBEDTLS_ARIA_C)
+#include "mbedtls/aria.h"
+#endif
+
#if defined(MBEDTLS_CCM_C)
#include "mbedtls/ccm.h"
#endif
@@ -642,6 +646,13 @@
mbedtls_snprintf( buf, buflen, "CAMELLIA - Camellia hardware accelerator failed" );
#endif /* MBEDTLS_CAMELLIA_C */
+#if defined(MBEDTLS_ARIA_C)
+ if( use_ret == -(MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH) )
+ mbedtls_snprintf( buf, buflen, "ARIA - Invalid key length" );
+ if( use_ret == -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH) )
+ mbedtls_snprintf( buf, buflen, "ARIA - Invalid data input length" );
+#endif /* MBEDTLS_ARIA_C */
+
#if defined(MBEDTLS_CCM_C)
if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) )
mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to the function" );
diff --git a/library/version_features.c b/library/version_features.c
index da47e3d..3b1319e 100644
--- a/library/version_features.c
+++ b/library/version_features.c
@@ -525,6 +525,9 @@
#if defined(MBEDTLS_CAMELLIA_C)
"MBEDTLS_CAMELLIA_C",
#endif /* MBEDTLS_CAMELLIA_C */
+#if defined(MBEDTLS_ARIA_C)
+ "MBEDTLS_ARIA_C",
+#endif /* MBEDTLS_ARIA_C */
#if defined(MBEDTLS_CCM_C)
"MBEDTLS_CCM_C",
#endif /* MBEDTLS_CCM_C */
diff --git a/programs/test/selftest.c b/programs/test/selftest.c
index 72a3734..019071b 100644
--- a/programs/test/selftest.c
+++ b/programs/test/selftest.c
@@ -44,6 +44,7 @@
#include "mbedtls/des.h"
#include "mbedtls/aes.h"
#include "mbedtls/camellia.h"
+#include "mbedtls/aria.h"
#include "mbedtls/base64.h"
#include "mbedtls/bignum.h"
#include "mbedtls/rsa.h"
@@ -225,6 +226,9 @@
#if defined(MBEDTLS_CAMELLIA_C)
{"camellia", mbedtls_camellia_self_test},
#endif
+#if defined(MBEDTLS_ARIA_C)
+ {"aria", mbedtls_aria_self_test},
+#endif
#if defined(MBEDTLS_CTR_DRBG_C)
{"ctr_drbg", mbedtls_ctr_drbg_self_test},
#endif
diff --git a/scripts/generate_errors.pl b/scripts/generate_errors.pl
index 59618d4..95ec512 100755
--- a/scripts/generate_errors.pl
+++ b/scripts/generate_errors.pl
@@ -29,7 +29,7 @@
my $error_format_file = $data_dir.'/error.fmt';
-my @low_level_modules = qw( AES ARC4 ASN1 BASE64 BIGNUM BLOWFISH
+my @low_level_modules = qw( AES ARC4 ARIA ASN1 BASE64 BIGNUM BLOWFISH
CAMELLIA CCM CMAC CTR_DRBG DES
ENTROPY GCM HMAC_DRBG MD2 MD4 MD5
NET OID PADLOCK PBKDF2 RIPEMD160