aria.h
Go to the documentation of this file.
1 /**
2  * @file aria.h
3  * @brief ARIA encryption algorithm
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _ARIA_H
32 #define _ARIA_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //ARIA block size
38 #define ARIA_BLOCK_SIZE 16
39 //Common interface for encryption algorithms
40 #define ARIA_CIPHER_ALGO (&ariaCipherAlgo)
41 
42 //C++ guard
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 
48 /**
49  * @brief ARIA algorithm context
50  **/
51 
52 typedef struct
53 {
55  uint32_t k[16];
56  uint32_t ek[68];
57  uint32_t dk[68];
58 } AriaContext;
59 
60 
61 //ARIA related constants
62 extern const uint8_t ARIA128_ECB_OID[9];
63 extern const uint8_t ARIA128_CBC_OID[9];
64 extern const uint8_t ARIA128_CFB_OID[9];
65 extern const uint8_t ARIA128_OFB_OID[9];
66 extern const uint8_t ARIA128_CTR_OID[9];
67 extern const uint8_t ARIA192_ECB_OID[9];
68 extern const uint8_t ARIA192_CBC_OID[9];
69 extern const uint8_t ARIA192_CFB_OID[9];
70 extern const uint8_t ARIA192_OFB_OID[9];
71 extern const uint8_t ARIA192_CTR_OID[9];
72 extern const uint8_t ARIA256_ECB_OID[9];
73 extern const uint8_t ARIA256_CBC_OID[9];
74 extern const uint8_t ARIA256_CFB_OID[9];
75 extern const uint8_t ARIA256_OFB_OID[9];
76 extern const uint8_t ARIA256_CTR_OID[9];
77 extern const uint8_t ARIA128_GCM_OID[9];
78 extern const uint8_t ARIA192_GCM_OID[9];
79 extern const uint8_t ARIA256_GCM_OID[9];
80 extern const uint8_t ARIA128_CCM_OID[9];
81 extern const uint8_t ARIA192_CCM_OID[9];
82 extern const uint8_t ARIA256_CCM_OID[9];
83 extern const CipherAlgo ariaCipherAlgo;
84 
85 //ARIA related functions
86 error_t ariaInit(AriaContext *context, const uint8_t *key, size_t keyLen);
87 
88 void ariaEncryptBlock(AriaContext *context, const uint8_t *input,
89  uint8_t *output);
90 
91 void ariaDecryptBlock(AriaContext *context, const uint8_t *input,
92  uint8_t *output);
93 
94 void ariaDeinit(AriaContext *context);
95 
96 //C++ guard
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif
const uint8_t ARIA256_CTR_OID[9]
Definition: aria.c:267
const uint8_t ARIA192_ECB_OID[9]
Definition: aria.c:248
const uint8_t ARIA128_CFB_OID[9]
Definition: aria.c:241
const uint8_t ARIA128_CBC_OID[9]
Definition: aria.c:239
const uint8_t ARIA192_CFB_OID[9]
Definition: aria.c:252
const uint8_t ARIA256_CCM_OID[9]
Definition: aria.c:281
const uint8_t ARIA128_ECB_OID[9]
Definition: aria.c:237
const uint8_t ARIA192_OFB_OID[9]
Definition: aria.c:254
void ariaDeinit(AriaContext *context)
Release ARIA context.
Definition: aria.c:625
const uint8_t ARIA192_CTR_OID[9]
Definition: aria.c:256
const uint8_t ARIA256_CBC_OID[9]
Definition: aria.c:261
error_t
Error codes.
Definition: error.h:43
const uint8_t ARIA256_CFB_OID[9]
Definition: aria.c:263
const uint8_t ARIA128_CTR_OID[9]
Definition: aria.c:245
const uint8_t ARIA192_CCM_OID[9]
Definition: aria.c:279
const uint8_t ARIA256_ECB_OID[9]
Definition: aria.c:259
error_t ariaInit(AriaContext *context, const uint8_t *key, size_t keyLen)
Initialize a ARIA context using the supplied key.
Definition: aria.c:345
General definitions for cryptographic algorithms.
uint_t nr
Definition: aria.h:54
void ariaDecryptBlock(AriaContext *context, const uint8_t *input, uint8_t *output)
Decrypt a 16-byte block using ARIA algorithm.
Definition: aria.c:560
const uint8_t ARIA192_GCM_OID[9]
Definition: aria.c:272
const uint8_t ARIA128_OFB_OID[9]
Definition: aria.c:243
const uint8_t ARIA192_CBC_OID[9]
Definition: aria.c:250
const uint8_t ARIA128_CCM_OID[9]
Definition: aria.c:277
const uint8_t ARIA256_OFB_OID[9]
Definition: aria.c:265
void ariaEncryptBlock(AriaContext *context, const uint8_t *input, uint8_t *output)
Encrypt a 16-byte block using ARIA algorithm.
Definition: aria.c:493
const CipherAlgo ariaCipherAlgo
Definition: aria.c:284
Common interface for encryption algorithms.
Definition: crypto.h:1068
const uint8_t ARIA128_GCM_OID[9]
Definition: aria.c:270
const uint8_t ARIA256_GCM_OID[9]
Definition: aria.c:274
ARIA algorithm context.
Definition: aria.h:53
unsigned int uint_t
Definition: compiler_port.h:50