Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file aria.h |
| 3 | * |
| 4 | * \brief ARIA block cipher |
| 5 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 6 | * The ARIA algorithm is a symmetric block cipher that can encrypt and |
| 7 | * decrypt information. It is defined by the Korean Agency for |
| 8 | * Technology and Standards (KATS) in <em>KS X 1213:2004</em> (in |
| 9 | * Korean, but see http://210.104.33.10/ARIA/index-e.html in English) |
| 10 | * and also described by the IETF in <em>RFC 5794</em>. |
| 11 | */ |
| 12 | /* Copyright (C) 2006-2018, ARM Limited, All Rights Reserved |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 13 | * SPDX-License-Identifier: Apache-2.0 |
| 14 | * |
| 15 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 16 | * not use this file except in compliance with the License. |
| 17 | * You may obtain a copy of the License at |
| 18 | * |
| 19 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 20 | * |
| 21 | * Unless required by applicable law or agreed to in writing, software |
| 22 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 23 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 24 | * See the License for the specific language governing permissions and |
| 25 | * limitations under the License. |
| 26 | * |
| 27 | * This file is part of mbed TLS (https://tls.mbed.org) |
| 28 | */ |
| 29 | |
| 30 | #ifndef MBEDTLS_ARIA_H |
| 31 | #define MBEDTLS_ARIA_H |
| 32 | |
| 33 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 34 | #include "config.h" |
| 35 | #else |
| 36 | #include MBEDTLS_CONFIG_FILE |
| 37 | #endif |
| 38 | |
| 39 | #include <stddef.h> |
| 40 | #include <stdint.h> |
| 41 | |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 42 | #define MBEDTLS_ARIA_ENCRYPT 1 /**< ARIA encryption. */ |
| 43 | #define MBEDTLS_ARIA_DECRYPT 0 /**< ARIA decryption. */ |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 44 | |
Manuel Pégourié-Gonnard | 8abc349 | 2018-03-01 10:02:47 +0100 | [diff] [blame] | 45 | #define MBEDTLS_ARIA_BLOCKSIZE 16 /**< ARIA block size in bytes. */ |
| 46 | #define MBEDTLS_ARIA_MAX_ROUNDS 16 /**< Maxiumum number of rounds in ARIA. */ |
| 47 | #define MBEDTLS_ARIA_MAX_KEYSIZE 32 /**< Maximum size of an ARIA key in bytes. */ |
Manuel Pégourié-Gonnard | 5ad88b6 | 2018-03-01 09:20:47 +0100 | [diff] [blame] | 48 | |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 49 | #define MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH -0x005C /**< Invalid key length. */ |
| 50 | #define MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH -0x005E /**< Invalid data input length. */ |
Manuel Pégourié-Gonnard | 3c80009 | 2018-03-01 09:02:16 +0100 | [diff] [blame] | 51 | #define MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE -0x005A /**< Feature not available. For example, an unsupported ARIA key size. */ |
| 52 | #define MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED -0x0058 /**< ARIA hardware accelerator failed. */ |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 53 | |
| 54 | #if !defined(MBEDTLS_ARIA_ALT) |
| 55 | // Regular implementation |
| 56 | // |
| 57 | |
| 58 | #ifdef __cplusplus |
| 59 | extern "C" { |
| 60 | #endif |
| 61 | |
| 62 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 63 | * \brief The ARIA context-type definition. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 64 | */ |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 65 | typedef struct |
| 66 | { |
Manuel Pégourié-Gonnard | 906bc90 | 2018-03-01 09:39:01 +0100 | [diff] [blame] | 67 | unsigned char nr; /*!< The number of rounds (12, 14 or 16) */ |
Manuel Pégourié-Gonnard | 5ad88b6 | 2018-03-01 09:20:47 +0100 | [diff] [blame] | 68 | /*! The ARIA round keys. */ |
| 69 | uint32_t rk[MBEDTLS_ARIA_MAX_ROUNDS + 1][MBEDTLS_ARIA_BLOCKSIZE / 4]; |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 70 | } |
| 71 | mbedtls_aria_context; |
| 72 | |
| 73 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 74 | * \brief This function initializes the specified ARIA context. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 75 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 76 | * It must be the first API called before using |
| 77 | * the context. |
| 78 | * |
| 79 | * \param ctx The ARIA context to initialize. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 80 | */ |
| 81 | void mbedtls_aria_init( mbedtls_aria_context *ctx ); |
| 82 | |
| 83 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 84 | * \brief This function releases and clears the specified ARIA context. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 85 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 86 | * \param ctx The ARIA context to clear. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 87 | */ |
| 88 | void mbedtls_aria_free( mbedtls_aria_context *ctx ); |
| 89 | |
| 90 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 91 | * \brief This function sets the encryption key. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 92 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 93 | * \param ctx The ARIA context to which the key should be bound. |
| 94 | * \param key The encryption key. |
| 95 | * \param keybits The size of data passed in bits. Valid options are: |
| 96 | * <ul><li>128 bits</li> |
| 97 | * <li>192 bits</li> |
| 98 | * <li>256 bits</li></ul> |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 99 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 100 | * \return \c 0 on success or #MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH |
| 101 | * on failure. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 102 | */ |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 103 | int mbedtls_aria_setkey_enc( mbedtls_aria_context *ctx, |
| 104 | const unsigned char *key, |
| 105 | unsigned int keybits ); |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 106 | |
| 107 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 108 | * \brief This function sets the decryption key. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 109 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 110 | * \param ctx The ARIA context to which the key should be bound. |
| 111 | * \param key The decryption key. |
| 112 | * \param keybits The size of data passed. Valid options are: |
| 113 | * <ul><li>128 bits</li> |
| 114 | * <li>192 bits</li> |
| 115 | * <li>256 bits</li></ul> |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 116 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 117 | * \return \c 0 on success, or #MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH on failure. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 118 | */ |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 119 | int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx, |
| 120 | const unsigned char *key, |
| 121 | unsigned int keybits ); |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 122 | |
| 123 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 124 | * \brief This function performs an ARIA single-block encryption or |
| 125 | * decryption operation. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 126 | * |
Manuel Pégourié-Gonnard | 08c337d | 2018-05-22 13:18:01 +0200 | [diff] [blame] | 127 | * It performs encryption or decryption (depending on whether |
| 128 | * the key was set for encryption on decryption) on the input |
| 129 | * data buffer defined in the \p input parameter. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 130 | * |
Manuel Pégourié-Gonnard | 9d41073 | 2018-05-22 12:49:22 +0200 | [diff] [blame] | 131 | * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or |
| 132 | * mbedtls_aria_setkey_dec() must be called before the first |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 133 | * call to this API with the same context. |
| 134 | * |
| 135 | * \param ctx The ARIA context to use for encryption or decryption. |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 136 | * \param input The 16-Byte buffer holding the input data. |
| 137 | * \param output The 16-Byte buffer holding the output data. |
| 138 | |
| 139 | * \return \c 0 on success. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 140 | */ |
| 141 | int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, |
Manuel Pégourié-Gonnard | 5ad88b6 | 2018-03-01 09:20:47 +0100 | [diff] [blame] | 142 | const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], |
| 143 | unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] ); |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 144 | |
| 145 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
| 146 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 147 | * \brief This function performs an ARIA-CBC encryption or decryption operation |
| 148 | * on full blocks. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 149 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 150 | * It performs the operation defined in the \p mode |
| 151 | * parameter (encrypt/decrypt), on the input data buffer defined in |
| 152 | * the \p input parameter. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 153 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 154 | * It can be called as many times as needed, until all the input |
Manuel Pégourié-Gonnard | 9d41073 | 2018-05-22 12:49:22 +0200 | [diff] [blame] | 155 | * data is processed. mbedtls_aria_init(), and either |
| 156 | * mbedtls_aria_setkey_enc() or mbedtls_aria_setkey_dec() must be called |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 157 | * before the first call to this API with the same context. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 158 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 159 | * \note This function operates on aligned blocks, that is, the input size |
| 160 | * must be a multiple of the ARIA block size of 16 Bytes. |
| 161 | * |
| 162 | * \note Upon exit, the content of the IV is updated so that you can |
| 163 | * call the same function again on the next |
| 164 | * block(s) of data and get the same result as if it was |
| 165 | * encrypted in one call. This allows a "streaming" usage. |
| 166 | * If you need to retain the contents of the IV, you should |
| 167 | * either save it manually or use the cipher module instead. |
| 168 | * |
| 169 | * |
| 170 | * \param ctx The ARIA context to use for encryption or decryption. |
| 171 | * \param mode The ARIA operation: #MBEDTLS_ARIA_ENCRYPT or |
| 172 | * #MBEDTLS_ARIA_DECRYPT. |
| 173 | * \param length The length of the input data in Bytes. This must be a |
| 174 | * multiple of the block size (16 Bytes). |
| 175 | * \param iv Initialization vector (updated after use). |
| 176 | * \param input The buffer holding the input data. |
| 177 | * \param output The buffer holding the output data. |
| 178 | * |
| 179 | * \return \c 0 on success, or #MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH |
| 180 | * on failure. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 181 | */ |
| 182 | int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx, |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 183 | int mode, |
| 184 | size_t length, |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 185 | unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 186 | const unsigned char *input, |
| 187 | unsigned char *output ); |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 188 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
| 189 | |
| 190 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
| 191 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 192 | * \brief This function performs an ARIA-CFB128 encryption or decryption |
| 193 | * operation. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 194 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 195 | * It performs the operation defined in the \p mode |
| 196 | * parameter (encrypt or decrypt), on the input data buffer |
| 197 | * defined in the \p input parameter. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 198 | * |
Manuel Pégourié-Gonnard | 9d41073 | 2018-05-22 12:49:22 +0200 | [diff] [blame] | 199 | * For CFB, you must set up the context with mbedtls_aria_setkey_enc(), |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 200 | * regardless of whether you are performing an encryption or decryption |
| 201 | * operation, that is, regardless of the \p mode parameter. This is |
| 202 | * because CFB mode uses the same key schedule for encryption and |
| 203 | * decryption. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 204 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 205 | * \note Upon exit, the content of the IV is updated so that you can |
| 206 | * call the same function again on the next |
| 207 | * block(s) of data and get the same result as if it was |
| 208 | * encrypted in one call. This allows a "streaming" usage. |
| 209 | * If you need to retain the contents of the |
| 210 | * IV, you must either save it manually or use the cipher |
| 211 | * module instead. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 212 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 213 | * |
| 214 | * \param ctx The ARIA context to use for encryption or decryption. |
| 215 | * \param mode The ARIA operation: #MBEDTLS_ARIA_ENCRYPT or |
| 216 | * #MBEDTLS_ARIA_DECRYPT. |
| 217 | * \param length The length of the input data. |
| 218 | * \param iv_off The offset in IV (updated after use). |
| 219 | * \param iv The initialization vector (updated after use). |
| 220 | * \param input The buffer holding the input data. |
| 221 | * \param output The buffer holding the output data. |
| 222 | * |
| 223 | * \return \c 0 on success. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 224 | */ |
| 225 | int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx, |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 226 | int mode, |
| 227 | size_t length, |
| 228 | size_t *iv_off, |
Manuel Pégourié-Gonnard | 5ad88b6 | 2018-03-01 09:20:47 +0100 | [diff] [blame] | 229 | unsigned char iv[MBEDTLS_ARIA_BLOCKSIZE], |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 230 | const unsigned char *input, |
| 231 | unsigned char *output ); |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 232 | #endif /* MBEDTLS_CIPHER_MODE_CFB */ |
| 233 | |
| 234 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
| 235 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 236 | * \brief This function performs an ARIA-CTR encryption or decryption |
| 237 | * operation. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 238 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 239 | * This function performs the operation defined in the \p mode |
| 240 | * parameter (encrypt/decrypt), on the input data buffer |
| 241 | * defined in the \p input parameter. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 242 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 243 | * Due to the nature of CTR, you must use the same key schedule |
| 244 | * for both encryption and decryption operations. Therefore, you |
Manuel Pégourié-Gonnard | 9d41073 | 2018-05-22 12:49:22 +0200 | [diff] [blame] | 245 | * must use the context initialized with mbedtls_aria_setkey_enc() |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 246 | * for both #MBEDTLS_ARIA_ENCRYPT and #MBEDTLS_ARIA_DECRYPT. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 247 | * |
Manuel Pégourié-Gonnard | 22997b7 | 2018-02-28 12:29:41 +0100 | [diff] [blame] | 248 | * \warning You must never reuse a nonce value with the same key. Doing so |
| 249 | * would void the encryption for the two messages encrypted with |
| 250 | * the same nonce and key. |
| 251 | * |
| 252 | * There are two common strategies for managing nonces with CTR: |
| 253 | * |
| 254 | * 1. Use a counter starting at 0 or a random value. With this |
| 255 | * strategy, this function will increment the counter for you, so |
| 256 | * you only need to preserve the \p nonce_counter buffer between |
| 257 | * calls. With this strategy, you must not encrypt more than |
| 258 | * 2**128 blocks of data. |
| 259 | * 2. Use a randomly-generated \p nonce_counter for each call. |
| 260 | * With this strategy, you need to ensure the nonce is generated |
| 261 | * in an unbiased way and you must not encrypt more than 2**64 |
Manuel Pégourié-Gonnard | f6b787c | 2018-03-01 13:48:21 +0100 | [diff] [blame] | 262 | * blocks of data. |
Manuel Pégourié-Gonnard | 22997b7 | 2018-02-28 12:29:41 +0100 | [diff] [blame] | 263 | * |
| 264 | * Note that for both stategies, the limit is in number of blocks |
| 265 | * and that an ARIA block is 16 bytes. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 266 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 267 | * \param ctx The ARIA context to use for encryption or decryption. |
| 268 | * \param length The length of the input data. |
| 269 | * \param nc_off The offset in the current \p stream_block, for |
| 270 | * resuming within the current cipher stream. The |
| 271 | * offset pointer should be 0 at the start of a stream. |
| 272 | * \param nonce_counter The 128-bit nonce and counter. |
| 273 | * \param stream_block The saved stream block for resuming. This is |
| 274 | * overwritten by the function. |
| 275 | * \param input The buffer holding the input data. |
| 276 | * \param output The buffer holding the output data. |
| 277 | * |
| 278 | * \return \c 0 on success. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 279 | */ |
| 280 | int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx, |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 281 | size_t length, |
| 282 | size_t *nc_off, |
Manuel Pégourié-Gonnard | 5ad88b6 | 2018-03-01 09:20:47 +0100 | [diff] [blame] | 283 | unsigned char nonce_counter[MBEDTLS_ARIA_BLOCKSIZE], |
| 284 | unsigned char stream_block[MBEDTLS_ARIA_BLOCKSIZE], |
Manuel Pégourié-Gonnard | 4231e7f | 2018-02-28 10:54:31 +0100 | [diff] [blame] | 285 | const unsigned char *input, |
| 286 | unsigned char *output ); |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 287 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
| 288 | |
| 289 | #ifdef __cplusplus |
| 290 | } |
| 291 | #endif |
| 292 | |
| 293 | #else /* MBEDTLS_ARIA_ALT */ |
| 294 | #include "aria_alt.h" |
| 295 | #endif /* MBEDTLS_ARIA_ALT */ |
| 296 | |
| 297 | #ifdef __cplusplus |
| 298 | extern "C" { |
| 299 | #endif |
| 300 | |
| 301 | /** |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 302 | * \brief Checkup routine. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 303 | * |
Manuel Pégourié-Gonnard | 5aa4e3b | 2018-02-28 11:55:49 +0100 | [diff] [blame] | 304 | * \return \c 0 on success, or \c 1 on failure. |
Markku-Juhani O. Saarinen | 41efbaa | 2017-11-30 11:37:55 +0000 | [diff] [blame] | 305 | */ |
| 306 | int mbedtls_aria_self_test( int verbose ); |
| 307 | |
| 308 | #ifdef __cplusplus |
| 309 | } |
| 310 | #endif |
| 311 | |
| 312 | #endif /* aria.h */ |