aria.c File Reference

ARIA encryption algorithm. More...

#include "core/crypto.h"
#include "cipher/aria.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 
#define MOV128(b, a)
 
#define XOR128(b, a)
 
#define ROL128(b, a, n)
 
#define SL1(b, a)
 
#define SL2(b, a)
 
#define A(b, a)
 

Functions

error_t ariaInit (AriaContext *context, const uint8_t *key, size_t keyLen)
 Initialize a ARIA context using the supplied key. More...
 
void ariaEncryptBlock (AriaContext *context, const uint8_t *input, uint8_t *output)
 Encrypt a 16-byte block using ARIA algorithm. More...
 
void ariaDecryptBlock (AriaContext *context, const uint8_t *input, uint8_t *output)
 Decrypt a 16-byte block using ARIA algorithm. More...
 
void ariaDeinit (AriaContext *context)
 Release ARIA context. More...
 

Variables

const uint8_t ARIA128_ECB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x01}
 
const uint8_t ARIA128_CBC_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x02}
 
const uint8_t ARIA128_CFB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x03}
 
const uint8_t ARIA128_OFB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x04}
 
const uint8_t ARIA128_CTR_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x05}
 
const uint8_t ARIA192_ECB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x06}
 
const uint8_t ARIA192_CBC_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x07}
 
const uint8_t ARIA192_CFB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x08}
 
const uint8_t ARIA192_OFB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x09}
 
const uint8_t ARIA192_CTR_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0A}
 
const uint8_t ARIA256_ECB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0B}
 
const uint8_t ARIA256_CBC_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0C}
 
const uint8_t ARIA256_CFB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0D}
 
const uint8_t ARIA256_OFB_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0E}
 
const uint8_t ARIA256_CTR_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0F}
 
const uint8_t ARIA128_GCM_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x22}
 
const uint8_t ARIA192_GCM_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x23}
 
const uint8_t ARIA256_GCM_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x24}
 
const uint8_t ARIA128_CCM_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x25}
 
const uint8_t ARIA192_CCM_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x26}
 
const uint8_t ARIA256_CCM_OID [9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x27}
 
const CipherAlgo ariaCipherAlgo
 

Detailed Description

ARIA encryption algorithm.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCRYPTO Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

ARIA is a 128-bit block cipher with 128-, 192-, and 256-bit keys. The algorithm consists of a key scheduling part and data randomizing part. Refer to RFC 5794 for more details

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file aria.c.

Macro Definition Documentation

◆ A

#define A (   b,
  a 
)
Value:
{ \
uint8_t *x = (uint8_t *) (a); \
uint8_t *y = (uint8_t *) (b); \
y[0] = x[3] ^ x[4] ^ x[6] ^ x[8] ^ x[9] ^ x[13] ^ x[14]; \
y[1] = x[2] ^ x[5] ^ x[7] ^ x[8] ^ x[9] ^ x[12] ^ x[15]; \
y[2] = x[1] ^ x[4] ^ x[6] ^ x[10] ^ x[11] ^ x[12] ^ x[15]; \
y[3] = x[0] ^ x[5] ^ x[7] ^ x[10] ^ x[11] ^ x[13] ^ x[14]; \
y[4] = x[0] ^ x[2] ^ x[5] ^ x[8] ^ x[11] ^ x[14] ^ x[15]; \
y[5] = x[1] ^ x[3] ^ x[4] ^ x[9] ^ x[10] ^ x[14] ^ x[15]; \
y[6] = x[0] ^ x[2] ^ x[7] ^ x[9] ^ x[10] ^ x[12] ^ x[13]; \
y[7] = x[1] ^ x[3] ^ x[6] ^ x[8] ^ x[11] ^ x[12] ^ x[13]; \
y[8] = x[0] ^ x[1] ^ x[4] ^ x[7] ^ x[10] ^ x[13] ^ x[15]; \
y[9] = x[0] ^ x[1] ^ x[5] ^ x[6] ^ x[11] ^ x[12] ^ x[14]; \
y[10] = x[2] ^ x[3] ^ x[5] ^ x[6] ^ x[8] ^ x[13] ^ x[15]; \
y[11] = x[2] ^ x[3] ^ x[4] ^ x[7] ^ x[9] ^ x[12] ^ x[14]; \
y[12] = x[1] ^ x[2] ^ x[6] ^ x[7] ^ x[9] ^ x[11] ^ x[12]; \
y[13] = x[0] ^ x[3] ^ x[6] ^ x[7] ^ x[8] ^ x[10] ^ x[13]; \
y[14] = x[0] ^ x[3] ^ x[4] ^ x[5] ^ x[9] ^ x[11] ^ x[14]; \
y[15] = x[1] ^ x[2] ^ x[4] ^ x[5] ^ x[8] ^ x[10] ^ x[15]; \
}
uint8_t x
Definition: lldp_ext_med.h:211
uint8_t b
Definition: nbns_common.h:104
uint8_t a
Definition: ndp.h:411

Definition at line 122 of file aria.c.

◆ MOV128

#define MOV128 (   b,
  a 
)
Value:
{ \
(b)[0] = (a)[0]; \
(b)[1] = (a)[1]; \
(b)[2] = (a)[2]; \
(b)[3] = (a)[3]; \
}

Definition at line 49 of file aria.c.

◆ ROL128

#define ROL128 (   b,
  a,
  n 
)
Value:
{ \
(b)[0] = ((a)[((n) / 32 + 0) % 4] << ((n) % 32)) | ((a)[((n) / 32 + 1) % 4] >> (32 - ((n) % 32))); \
(b)[1] = ((a)[((n) / 32 + 1) % 4] << ((n) % 32)) | ((a)[((n) / 32 + 2) % 4] >> (32 - ((n) % 32))); \
(b)[2] = ((a)[((n) / 32 + 2) % 4] << ((n) % 32)) | ((a)[((n) / 32 + 3) % 4] >> (32 - ((n) % 32))); \
(b)[3] = ((a)[((n) / 32 + 3) % 4] << ((n) % 32)) | ((a)[((n) / 32 + 0) % 4] >> (32 - ((n) % 32))); \
}
uint8_t n

Definition at line 67 of file aria.c.

◆ SL1

#define SL1 (   b,
  a 
)
Value:
{ \
uint8_t *x = (uint8_t *) (a); \
uint8_t *y = (uint8_t *) (b); \
y[0] = sb1[x[0]]; \
y[1] = sb2[x[1]]; \
y[2] = sb3[x[2]]; \
y[3] = sb4[x[3]]; \
y[4] = sb1[x[4]]; \
y[5] = sb2[x[5]]; \
y[6] = sb3[x[6]]; \
y[7] = sb4[x[7]]; \
y[8] = sb1[x[8]]; \
y[9] = sb2[x[9]]; \
y[10] = sb3[x[10]]; \
y[11] = sb4[x[11]]; \
y[12] = sb1[x[12]]; \
y[13] = sb2[x[13]]; \
y[14] = sb3[x[14]]; \
y[15] = sb4[x[15]]; \
}

Definition at line 76 of file aria.c.

◆ SL2

#define SL2 (   b,
  a 
)
Value:
{ \
uint8_t *x = (uint8_t *) (a); \
uint8_t *y = (uint8_t *) (b); \
y[0] = sb3[x[0]]; \
y[1] = sb4[x[1]]; \
y[2] = sb1[x[2]]; \
y[3] = sb2[x[3]]; \
y[4] = sb3[x[4]]; \
y[5] = sb4[x[5]]; \
y[6] = sb1[x[6]]; \
y[7] = sb2[x[7]]; \
y[8] = sb3[x[8]]; \
y[9] = sb4[x[9]]; \
y[10] = sb1[x[10]]; \
y[11] = sb2[x[11]]; \
y[12] = sb3[x[12]]; \
y[13] = sb4[x[13]]; \
y[14] = sb1[x[14]]; \
y[15] = sb2[x[15]]; \
}

Definition at line 99 of file aria.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 38 of file aria.c.

◆ XOR128

#define XOR128 (   b,
  a 
)
Value:
{ \
(b)[0] ^= (a)[0]; \
(b)[1] ^= (a)[1]; \
(b)[2] ^= (a)[2]; \
(b)[3] ^= (a)[3]; \
}

Definition at line 58 of file aria.c.

Function Documentation

◆ ariaDecryptBlock()

void ariaDecryptBlock ( AriaContext context,
const uint8_t *  input,
uint8_t *  output 
)

Decrypt a 16-byte block using ARIA algorithm.

Parameters
[in]contextPointer to the ARIA context
[in]inputCiphertext block to decrypt
[out]outputPlaintext block resulting from decryption

Definition at line 560 of file aria.c.

◆ ariaDeinit()

void ariaDeinit ( AriaContext context)

Release ARIA context.

Parameters
[in]contextPointer to the ARIA context

Definition at line 625 of file aria.c.

◆ ariaEncryptBlock()

void ariaEncryptBlock ( AriaContext context,
const uint8_t *  input,
uint8_t *  output 
)

Encrypt a 16-byte block using ARIA algorithm.

Parameters
[in]contextPointer to the ARIA context
[in]inputPlaintext block to encrypt
[out]outputCiphertext block resulting from encryption

Definition at line 493 of file aria.c.

◆ ariaInit()

error_t ariaInit ( AriaContext context,
const uint8_t *  key,
size_t  keyLen 
)

Initialize a ARIA context using the supplied key.

Parameters
[in]contextPointer to the ARIA context to initialize
[in]keyPointer to the key
[in]keyLenLength of the key
Returns
Error code

Definition at line 345 of file aria.c.

Variable Documentation

◆ ARIA128_CBC_OID

const uint8_t ARIA128_CBC_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x02}

Definition at line 239 of file aria.c.

◆ ARIA128_CCM_OID

const uint8_t ARIA128_CCM_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x25}

Definition at line 277 of file aria.c.

◆ ARIA128_CFB_OID

const uint8_t ARIA128_CFB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x03}

Definition at line 241 of file aria.c.

◆ ARIA128_CTR_OID

const uint8_t ARIA128_CTR_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x05}

Definition at line 245 of file aria.c.

◆ ARIA128_ECB_OID

const uint8_t ARIA128_ECB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x01}

Definition at line 237 of file aria.c.

◆ ARIA128_GCM_OID

const uint8_t ARIA128_GCM_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x22}

Definition at line 270 of file aria.c.

◆ ARIA128_OFB_OID

const uint8_t ARIA128_OFB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x04}

Definition at line 243 of file aria.c.

◆ ARIA192_CBC_OID

const uint8_t ARIA192_CBC_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x07}

Definition at line 250 of file aria.c.

◆ ARIA192_CCM_OID

const uint8_t ARIA192_CCM_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x26}

Definition at line 279 of file aria.c.

◆ ARIA192_CFB_OID

const uint8_t ARIA192_CFB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x08}

Definition at line 252 of file aria.c.

◆ ARIA192_CTR_OID

const uint8_t ARIA192_CTR_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0A}

Definition at line 256 of file aria.c.

◆ ARIA192_ECB_OID

const uint8_t ARIA192_ECB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x06}

Definition at line 248 of file aria.c.

◆ ARIA192_GCM_OID

const uint8_t ARIA192_GCM_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x23}

Definition at line 272 of file aria.c.

◆ ARIA192_OFB_OID

const uint8_t ARIA192_OFB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x09}

Definition at line 254 of file aria.c.

◆ ARIA256_CBC_OID

const uint8_t ARIA256_CBC_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0C}

Definition at line 261 of file aria.c.

◆ ARIA256_CCM_OID

const uint8_t ARIA256_CCM_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x27}

Definition at line 281 of file aria.c.

◆ ARIA256_CFB_OID

const uint8_t ARIA256_CFB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0D}

Definition at line 263 of file aria.c.

◆ ARIA256_CTR_OID

const uint8_t ARIA256_CTR_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0F}

Definition at line 267 of file aria.c.

◆ ARIA256_ECB_OID

const uint8_t ARIA256_ECB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0B}

Definition at line 259 of file aria.c.

◆ ARIA256_GCM_OID

const uint8_t ARIA256_GCM_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x24}

Definition at line 274 of file aria.c.

◆ ARIA256_OFB_OID

const uint8_t ARIA256_OFB_OID[9] = {0x2A, 0x83, 0x1A, 0x8C, 0x9A, 0x6E, 0x01, 0x01, 0x0E}

Definition at line 265 of file aria.c.

◆ ariaCipherAlgo

const CipherAlgo ariaCipherAlgo
Initial value:
=
{
"ARIA",
sizeof(AriaContext),
NULL,
NULL,
}
void ariaDeinit(AriaContext *context)
Release ARIA context.
Definition: aria.c:625
void ariaDecryptBlock(AriaContext *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using ARIA algorithm.
Definition: aria.c:560
void ariaEncryptBlock(AriaContext *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using ARIA algorithm.
Definition: aria.c:493
error_t ariaInit(AriaContext *context, const uint8_t *key, size_t keyLen)
Initialize a ARIA context using the supplied key.
Definition: aria.c:345
#define ARIA_BLOCK_SIZE
Definition: aria.h:38
void(* CipherAlgoDeinit)(void *context)
Definition: crypto.h:983
void(* CipherAlgoDecryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:980
error_t(* CipherAlgoInit)(void *context, const uint8_t *key, size_t keyLen)
Definition: crypto.h:968
void(* CipherAlgoEncryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:977
@ CIPHER_ALGO_TYPE_BLOCK
Definition: crypto.h:932
ARIA algorithm context.
Definition: aria.h:53

Definition at line 284 of file aria.c.