#include "common.h"
#if defined(MBEDTLS_ARIA_C)
#include "mbedtls/aria.h"
#include <string.h>
#include "mbedtls/platform.h"
#if !defined(MBEDTLS_ARIA_ALT)
#include "mbedtls/platform_util.h"
#if defined(MBEDTLS_HAVE_ASM)
#if defined(__arm__)
#if defined(__GNUC__) && \
(!defined(__ARMCC_VERSION) || __ARMCC_VERSION >= 6000000) && \
__ARM_ARCH >= 6
static inline uint32_t aria_p1(uint32_t x)
{
uint32_t r;
__asm("rev16 %0, %1" : "=l" (r) : "l" (x));
return r;
}
#define ARIA_P1 …
#elif defined(__ARMCC_VERSION) && __ARMCC_VERSION < 6000000 && \
(__TARGET_ARCH_ARM >= 6 || __TARGET_ARCH_THUMB >= 3)
static inline uint32_t aria_p1(uint32_t x)
{
uint32_t r;
__asm("rev16 r, x");
return r;
}
#define ARIA_P1 …
#endif
#endif
#if defined(__GNUC__) && \
defined(__i386__) || defined(__amd64__) || defined(__x86_64__)
#define ARIA_P1(x) …
#endif
#endif
#if !defined(ARIA_P1)
#define ARIA_P1 …
#endif
#define ARIA_P2(x) …
#define ARIA_P3(x) …
static inline void aria_a(uint32_t *a, uint32_t *b,
uint32_t *c, uint32_t *d)
{ … }
static inline void aria_sl(uint32_t *a, uint32_t *b,
uint32_t *c, uint32_t *d,
const uint8_t sa[256], const uint8_t sb[256],
const uint8_t sc[256], const uint8_t sd[256])
{ … }
static const uint8_t aria_sb1[256] = …;
static const uint8_t aria_sb2[256] = …;
static const uint8_t aria_is1[256] = …;
static const uint8_t aria_is2[256] = …;
static void aria_fo_xor(uint32_t r[4], const uint32_t p[4],
const uint32_t k[4], const uint32_t x[4])
{ … }
static void aria_fe_xor(uint32_t r[4], const uint32_t p[4],
const uint32_t k[4], const uint32_t x[4])
{ … }
static void aria_rot128(uint32_t r[4], const uint32_t a[4],
const uint32_t b[4], uint8_t n)
{ … }
int mbedtls_aria_setkey_enc(mbedtls_aria_context *ctx,
const unsigned char *key, unsigned int keybits)
{ … }
#if !defined(MBEDTLS_BLOCK_CIPHER_NO_DECRYPT)
int mbedtls_aria_setkey_dec(mbedtls_aria_context *ctx,
const unsigned char *key, unsigned int keybits)
{ … }
#endif
int mbedtls_aria_crypt_ecb(mbedtls_aria_context *ctx,
const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
unsigned char output[MBEDTLS_ARIA_BLOCKSIZE])
{ … }
void mbedtls_aria_init(mbedtls_aria_context *ctx)
{ … }
void mbedtls_aria_free(mbedtls_aria_context *ctx)
{ … }
#if defined(MBEDTLS_CIPHER_MODE_CBC)
int mbedtls_aria_crypt_cbc(mbedtls_aria_context *ctx,
int mode,
size_t length,
unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
const unsigned char *input,
unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
int mbedtls_aria_crypt_cfb128(mbedtls_aria_context *ctx,
int mode,
size_t length,
size_t *iv_off,
unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE],
const unsigned char *input,
unsigned char *output)
{ … }
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
int mbedtls_aria_crypt_ctr(mbedtls_aria_context *ctx,
size_t length,
size_t *nc_off,
unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE],
unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE],
const unsigned char *input,
unsigned char *output)
{ … }
#endif
#endif
#if defined(MBEDTLS_SELF_TEST)
static const uint8_t aria_test1_ecb_key[32] = …
{ … };
static const uint8_t aria_test1_ecb_pt[MBEDTLS_ARIA_BLOCKSIZE] = …
{ … };
static const uint8_t aria_test1_ecb_ct[3][MBEDTLS_ARIA_BLOCKSIZE] = …
{ … };
#if (defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB) || \
defined(MBEDTLS_CIPHER_MODE_CTR))
static const uint8_t aria_test2_key[32] = …;
static const uint8_t aria_test2_pt[48] = …;
#endif
#if (defined(MBEDTLS_CIPHER_MODE_CBC) || defined(MBEDTLS_CIPHER_MODE_CFB))
static const uint8_t aria_test2_iv[MBEDTLS_ARIA_BLOCKSIZE] = …;
#endif
#if defined(MBEDTLS_CIPHER_MODE_CBC)
static const uint8_t aria_test2_cbc_ct[3][48] = …
{ … };
#endif
#if defined(MBEDTLS_CIPHER_MODE_CFB)
static const uint8_t aria_test2_cfb_ct[3][48] = …
{ … };
#endif
#if defined(MBEDTLS_CIPHER_MODE_CTR)
static const uint8_t aria_test2_ctr_ct[3][48] = …
{ … };
#endif
#define ARIA_SELF_TEST_ASSERT(cond) …
int mbedtls_aria_self_test(int verbose)
{ … }
#endif
#endif