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...
 

Variables

const CipherAlgo ariaCipherAlgo
 

Detailed Description

ARIA encryption algorithm.

License

Copyright (C) 2010-2018 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
1.9.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 a
Definition: ndp.h:407
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 120 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]; \
}
uint8_t a
Definition: ndp.h:407
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 47 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 a
Definition: ndp.h:407
uint8_t n
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 65 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]]; \
}
uint8_t a
Definition: ndp.h:407
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 74 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]]; \
}
uint8_t a
Definition: ndp.h:407
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 97 of file aria.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 36 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]; \
}
uint8_t a
Definition: ndp.h:407
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 56 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 497 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 432 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 295 of file aria.c.

Variable Documentation

◆ ariaCipherAlgo

const CipherAlgo ariaCipherAlgo
Initial value:
=
{
"ARIA",
sizeof(AriaContext),
NULL,
NULL,
}
error_t ariaInit(AriaContext *context, const uint8_t *key, size_t keyLen)
Initialize a ARIA context using the supplied key.
Definition: aria.c:295
void(* CipherAlgoDecryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:1030
void ariaEncryptBlock(AriaContext *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using ARIA algorithm.
Definition: aria.c:432
ARIA algorithm context.
Definition: aria.h:50
error_t(* CipherAlgoInit)(void *context, const uint8_t *key, size_t keyLen)
Definition: crypto.h:1026
#define ARIA_BLOCK_SIZE
Definition: aria.h:36
void ariaDecryptBlock(AriaContext *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using ARIA algorithm.
Definition: aria.c:497
void(* CipherAlgoEncryptBlock)(void *context, const uint8_t *input, uint8_t *output)
Definition: crypto.h:1029

Definition at line 235 of file aria.c.