Modified mbed TLS headers for AES functionality only to reduce build size
Dependents: BLE_Gateway_Linker_fix BLE_Gateway
Fork of mbedtls by
mbedtls/aes.h@5:f09f5ed830ca, 2017-07-10 (annotated)
- Committer:
- electronichamsters
- Date:
- Mon Jul 10 04:00:25 2017 +0000
- Revision:
- 5:f09f5ed830ca
- Parent:
- 1:24750b9ad5ef
working gateway
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Christopher Haster |
1:24750b9ad5ef | 1 | /** |
Christopher Haster |
1:24750b9ad5ef | 2 | * \file aes.h |
Christopher Haster |
1:24750b9ad5ef | 3 | * |
Christopher Haster |
1:24750b9ad5ef | 4 | * \brief AES block cipher |
Christopher Haster |
1:24750b9ad5ef | 5 | * |
Christopher Haster |
1:24750b9ad5ef | 6 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Christopher Haster |
1:24750b9ad5ef | 7 | * SPDX-License-Identifier: Apache-2.0 |
Christopher Haster |
1:24750b9ad5ef | 8 | * |
Christopher Haster |
1:24750b9ad5ef | 9 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
Christopher Haster |
1:24750b9ad5ef | 10 | * not use this file except in compliance with the License. |
Christopher Haster |
1:24750b9ad5ef | 11 | * You may obtain a copy of the License at |
Christopher Haster |
1:24750b9ad5ef | 12 | * |
Christopher Haster |
1:24750b9ad5ef | 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
Christopher Haster |
1:24750b9ad5ef | 14 | * |
Christopher Haster |
1:24750b9ad5ef | 15 | * Unless required by applicable law or agreed to in writing, software |
Christopher Haster |
1:24750b9ad5ef | 16 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
Christopher Haster |
1:24750b9ad5ef | 17 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Christopher Haster |
1:24750b9ad5ef | 18 | * See the License for the specific language governing permissions and |
Christopher Haster |
1:24750b9ad5ef | 19 | * limitations under the License. |
Christopher Haster |
1:24750b9ad5ef | 20 | * |
Christopher Haster |
1:24750b9ad5ef | 21 | * This file is part of mbed TLS (https://tls.mbed.org) |
Christopher Haster |
1:24750b9ad5ef | 22 | */ |
Christopher Haster |
1:24750b9ad5ef | 23 | #ifndef MBEDTLS_AES_H |
Christopher Haster |
1:24750b9ad5ef | 24 | #define MBEDTLS_AES_H |
Christopher Haster |
1:24750b9ad5ef | 25 | |
Christopher Haster |
1:24750b9ad5ef | 26 | #if !defined(MBEDTLS_CONFIG_FILE) |
Christopher Haster |
1:24750b9ad5ef | 27 | #include "config.h" |
Christopher Haster |
1:24750b9ad5ef | 28 | #else |
Christopher Haster |
1:24750b9ad5ef | 29 | #include MBEDTLS_CONFIG_FILE |
Christopher Haster |
1:24750b9ad5ef | 30 | #endif |
Christopher Haster |
1:24750b9ad5ef | 31 | |
Christopher Haster |
1:24750b9ad5ef | 32 | #include <stddef.h> |
Christopher Haster |
1:24750b9ad5ef | 33 | #include <stdint.h> |
Christopher Haster |
1:24750b9ad5ef | 34 | |
Christopher Haster |
1:24750b9ad5ef | 35 | /* padlock.c and aesni.c rely on these values! */ |
Christopher Haster |
1:24750b9ad5ef | 36 | #define MBEDTLS_AES_ENCRYPT 1 |
Christopher Haster |
1:24750b9ad5ef | 37 | #define MBEDTLS_AES_DECRYPT 0 |
Christopher Haster |
1:24750b9ad5ef | 38 | |
Christopher Haster |
1:24750b9ad5ef | 39 | #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */ |
Christopher Haster |
1:24750b9ad5ef | 40 | #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */ |
Christopher Haster |
1:24750b9ad5ef | 41 | |
Christopher Haster |
1:24750b9ad5ef | 42 | #if !defined(MBEDTLS_AES_ALT) |
Christopher Haster |
1:24750b9ad5ef | 43 | // Regular implementation |
Christopher Haster |
1:24750b9ad5ef | 44 | // |
Christopher Haster |
1:24750b9ad5ef | 45 | |
Christopher Haster |
1:24750b9ad5ef | 46 | #ifdef __cplusplus |
Christopher Haster |
1:24750b9ad5ef | 47 | extern "C" { |
Christopher Haster |
1:24750b9ad5ef | 48 | #endif |
Christopher Haster |
1:24750b9ad5ef | 49 | |
Christopher Haster |
1:24750b9ad5ef | 50 | /** |
Christopher Haster |
1:24750b9ad5ef | 51 | * \brief AES context structure |
Christopher Haster |
1:24750b9ad5ef | 52 | * |
Christopher Haster |
1:24750b9ad5ef | 53 | * \note buf is able to hold 32 extra bytes, which can be used: |
Christopher Haster |
1:24750b9ad5ef | 54 | * - for alignment purposes if VIA padlock is used, and/or |
Christopher Haster |
1:24750b9ad5ef | 55 | * - to simplify key expansion in the 256-bit case by |
Christopher Haster |
1:24750b9ad5ef | 56 | * generating an extra round key |
Christopher Haster |
1:24750b9ad5ef | 57 | */ |
Christopher Haster |
1:24750b9ad5ef | 58 | typedef struct |
Christopher Haster |
1:24750b9ad5ef | 59 | { |
Christopher Haster |
1:24750b9ad5ef | 60 | int nr; /*!< number of rounds */ |
Christopher Haster |
1:24750b9ad5ef | 61 | uint32_t *rk; /*!< AES round keys */ |
Christopher Haster |
1:24750b9ad5ef | 62 | uint32_t buf[68]; /*!< unaligned data */ |
Christopher Haster |
1:24750b9ad5ef | 63 | } |
Christopher Haster |
1:24750b9ad5ef | 64 | mbedtls_aes_context; |
Christopher Haster |
1:24750b9ad5ef | 65 | |
Christopher Haster |
1:24750b9ad5ef | 66 | /** |
Christopher Haster |
1:24750b9ad5ef | 67 | * \brief Initialize AES context |
Christopher Haster |
1:24750b9ad5ef | 68 | * |
Christopher Haster |
1:24750b9ad5ef | 69 | * \param ctx AES context to be initialized |
Christopher Haster |
1:24750b9ad5ef | 70 | */ |
Christopher Haster |
1:24750b9ad5ef | 71 | void mbedtls_aes_init( mbedtls_aes_context *ctx ); |
Christopher Haster |
1:24750b9ad5ef | 72 | |
Christopher Haster |
1:24750b9ad5ef | 73 | /** |
Christopher Haster |
1:24750b9ad5ef | 74 | * \brief Clear AES context |
Christopher Haster |
1:24750b9ad5ef | 75 | * |
Christopher Haster |
1:24750b9ad5ef | 76 | * \param ctx AES context to be cleared |
Christopher Haster |
1:24750b9ad5ef | 77 | */ |
Christopher Haster |
1:24750b9ad5ef | 78 | void mbedtls_aes_free( mbedtls_aes_context *ctx ); |
Christopher Haster |
1:24750b9ad5ef | 79 | |
Christopher Haster |
1:24750b9ad5ef | 80 | /** |
Christopher Haster |
1:24750b9ad5ef | 81 | * \brief AES key schedule (encryption) |
Christopher Haster |
1:24750b9ad5ef | 82 | * |
Christopher Haster |
1:24750b9ad5ef | 83 | * \param ctx AES context to be initialized |
Christopher Haster |
1:24750b9ad5ef | 84 | * \param key encryption key |
Christopher Haster |
1:24750b9ad5ef | 85 | * \param keybits must be 128, 192 or 256 |
Christopher Haster |
1:24750b9ad5ef | 86 | * |
Christopher Haster |
1:24750b9ad5ef | 87 | * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH |
Christopher Haster |
1:24750b9ad5ef | 88 | */ |
Christopher Haster |
1:24750b9ad5ef | 89 | int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key, |
Christopher Haster |
1:24750b9ad5ef | 90 | unsigned int keybits ); |
Christopher Haster |
1:24750b9ad5ef | 91 | |
Christopher Haster |
1:24750b9ad5ef | 92 | /** |
Christopher Haster |
1:24750b9ad5ef | 93 | * \brief AES key schedule (decryption) |
Christopher Haster |
1:24750b9ad5ef | 94 | * |
Christopher Haster |
1:24750b9ad5ef | 95 | * \param ctx AES context to be initialized |
Christopher Haster |
1:24750b9ad5ef | 96 | * \param key decryption key |
Christopher Haster |
1:24750b9ad5ef | 97 | * \param keybits must be 128, 192 or 256 |
Christopher Haster |
1:24750b9ad5ef | 98 | * |
Christopher Haster |
1:24750b9ad5ef | 99 | * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH |
Christopher Haster |
1:24750b9ad5ef | 100 | */ |
Christopher Haster |
1:24750b9ad5ef | 101 | int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key, |
Christopher Haster |
1:24750b9ad5ef | 102 | unsigned int keybits ); |
Christopher Haster |
1:24750b9ad5ef | 103 | |
Christopher Haster |
1:24750b9ad5ef | 104 | /** |
Christopher Haster |
1:24750b9ad5ef | 105 | * \brief AES-ECB block encryption/decryption |
Christopher Haster |
1:24750b9ad5ef | 106 | * |
Christopher Haster |
1:24750b9ad5ef | 107 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 108 | * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT |
Christopher Haster |
1:24750b9ad5ef | 109 | * \param input 16-byte input block |
Christopher Haster |
1:24750b9ad5ef | 110 | * \param output 16-byte output block |
Christopher Haster |
1:24750b9ad5ef | 111 | * |
Christopher Haster |
1:24750b9ad5ef | 112 | * \return 0 if successful |
Christopher Haster |
1:24750b9ad5ef | 113 | */ |
Christopher Haster |
1:24750b9ad5ef | 114 | int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 115 | int mode, |
Christopher Haster |
1:24750b9ad5ef | 116 | const unsigned char input[16], |
Christopher Haster |
1:24750b9ad5ef | 117 | unsigned char output[16] ); |
Christopher Haster |
1:24750b9ad5ef | 118 | |
Christopher Haster |
1:24750b9ad5ef | 119 | #if defined(MBEDTLS_CIPHER_MODE_CBC) |
Christopher Haster |
1:24750b9ad5ef | 120 | /** |
Christopher Haster |
1:24750b9ad5ef | 121 | * \brief AES-CBC buffer encryption/decryption |
Christopher Haster |
1:24750b9ad5ef | 122 | * Length should be a multiple of the block |
Christopher Haster |
1:24750b9ad5ef | 123 | * size (16 bytes) |
Christopher Haster |
1:24750b9ad5ef | 124 | * |
Christopher Haster |
1:24750b9ad5ef | 125 | * \note Upon exit, the content of the IV is updated so that you can |
Christopher Haster |
1:24750b9ad5ef | 126 | * call the function same function again on the following |
Christopher Haster |
1:24750b9ad5ef | 127 | * block(s) of data and get the same result as if it was |
Christopher Haster |
1:24750b9ad5ef | 128 | * encrypted in one call. This allows a "streaming" usage. |
Christopher Haster |
1:24750b9ad5ef | 129 | * If on the other hand you need to retain the contents of the |
Christopher Haster |
1:24750b9ad5ef | 130 | * IV, you should either save it manually or use the cipher |
Christopher Haster |
1:24750b9ad5ef | 131 | * module instead. |
Christopher Haster |
1:24750b9ad5ef | 132 | * |
Christopher Haster |
1:24750b9ad5ef | 133 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 134 | * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT |
Christopher Haster |
1:24750b9ad5ef | 135 | * \param length length of the input data |
Christopher Haster |
1:24750b9ad5ef | 136 | * \param iv initialization vector (updated after use) |
Christopher Haster |
1:24750b9ad5ef | 137 | * \param input buffer holding the input data |
Christopher Haster |
1:24750b9ad5ef | 138 | * \param output buffer holding the output data |
Christopher Haster |
1:24750b9ad5ef | 139 | * |
Christopher Haster |
1:24750b9ad5ef | 140 | * \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH |
Christopher Haster |
1:24750b9ad5ef | 141 | */ |
Christopher Haster |
1:24750b9ad5ef | 142 | int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 143 | int mode, |
Christopher Haster |
1:24750b9ad5ef | 144 | size_t length, |
Christopher Haster |
1:24750b9ad5ef | 145 | unsigned char iv[16], |
Christopher Haster |
1:24750b9ad5ef | 146 | const unsigned char *input, |
Christopher Haster |
1:24750b9ad5ef | 147 | unsigned char *output ); |
Christopher Haster |
1:24750b9ad5ef | 148 | #endif /* MBEDTLS_CIPHER_MODE_CBC */ |
Christopher Haster |
1:24750b9ad5ef | 149 | |
Christopher Haster |
1:24750b9ad5ef | 150 | #if defined(MBEDTLS_CIPHER_MODE_CFB) |
Christopher Haster |
1:24750b9ad5ef | 151 | /** |
Christopher Haster |
1:24750b9ad5ef | 152 | * \brief AES-CFB128 buffer encryption/decryption. |
Christopher Haster |
1:24750b9ad5ef | 153 | * |
Christopher Haster |
1:24750b9ad5ef | 154 | * Note: Due to the nature of CFB you should use the same key schedule for |
Christopher Haster |
1:24750b9ad5ef | 155 | * both encryption and decryption. So a context initialized with |
Christopher Haster |
1:24750b9ad5ef | 156 | * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT. |
Christopher Haster |
1:24750b9ad5ef | 157 | * |
Christopher Haster |
1:24750b9ad5ef | 158 | * \note Upon exit, the content of the IV is updated so that you can |
Christopher Haster |
1:24750b9ad5ef | 159 | * call the function same function again on the following |
Christopher Haster |
1:24750b9ad5ef | 160 | * block(s) of data and get the same result as if it was |
Christopher Haster |
1:24750b9ad5ef | 161 | * encrypted in one call. This allows a "streaming" usage. |
Christopher Haster |
1:24750b9ad5ef | 162 | * If on the other hand you need to retain the contents of the |
Christopher Haster |
1:24750b9ad5ef | 163 | * IV, you should either save it manually or use the cipher |
Christopher Haster |
1:24750b9ad5ef | 164 | * module instead. |
Christopher Haster |
1:24750b9ad5ef | 165 | * |
Christopher Haster |
1:24750b9ad5ef | 166 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 167 | * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT |
Christopher Haster |
1:24750b9ad5ef | 168 | * \param length length of the input data |
Christopher Haster |
1:24750b9ad5ef | 169 | * \param iv_off offset in IV (updated after use) |
Christopher Haster |
1:24750b9ad5ef | 170 | * \param iv initialization vector (updated after use) |
Christopher Haster |
1:24750b9ad5ef | 171 | * \param input buffer holding the input data |
Christopher Haster |
1:24750b9ad5ef | 172 | * \param output buffer holding the output data |
Christopher Haster |
1:24750b9ad5ef | 173 | * |
Christopher Haster |
1:24750b9ad5ef | 174 | * \return 0 if successful |
Christopher Haster |
1:24750b9ad5ef | 175 | */ |
Christopher Haster |
1:24750b9ad5ef | 176 | int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 177 | int mode, |
Christopher Haster |
1:24750b9ad5ef | 178 | size_t length, |
Christopher Haster |
1:24750b9ad5ef | 179 | size_t *iv_off, |
Christopher Haster |
1:24750b9ad5ef | 180 | unsigned char iv[16], |
Christopher Haster |
1:24750b9ad5ef | 181 | const unsigned char *input, |
Christopher Haster |
1:24750b9ad5ef | 182 | unsigned char *output ); |
Christopher Haster |
1:24750b9ad5ef | 183 | |
Christopher Haster |
1:24750b9ad5ef | 184 | /** |
Christopher Haster |
1:24750b9ad5ef | 185 | * \brief AES-CFB8 buffer encryption/decryption. |
Christopher Haster |
1:24750b9ad5ef | 186 | * |
Christopher Haster |
1:24750b9ad5ef | 187 | * Note: Due to the nature of CFB you should use the same key schedule for |
Christopher Haster |
1:24750b9ad5ef | 188 | * both encryption and decryption. So a context initialized with |
Christopher Haster |
1:24750b9ad5ef | 189 | * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT. |
Christopher Haster |
1:24750b9ad5ef | 190 | * |
Christopher Haster |
1:24750b9ad5ef | 191 | * \note Upon exit, the content of the IV is updated so that you can |
Christopher Haster |
1:24750b9ad5ef | 192 | * call the function same function again on the following |
Christopher Haster |
1:24750b9ad5ef | 193 | * block(s) of data and get the same result as if it was |
Christopher Haster |
1:24750b9ad5ef | 194 | * encrypted in one call. This allows a "streaming" usage. |
Christopher Haster |
1:24750b9ad5ef | 195 | * If on the other hand you need to retain the contents of the |
Christopher Haster |
1:24750b9ad5ef | 196 | * IV, you should either save it manually or use the cipher |
Christopher Haster |
1:24750b9ad5ef | 197 | * module instead. |
Christopher Haster |
1:24750b9ad5ef | 198 | * |
Christopher Haster |
1:24750b9ad5ef | 199 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 200 | * \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT |
Christopher Haster |
1:24750b9ad5ef | 201 | * \param length length of the input data |
Christopher Haster |
1:24750b9ad5ef | 202 | * \param iv initialization vector (updated after use) |
Christopher Haster |
1:24750b9ad5ef | 203 | * \param input buffer holding the input data |
Christopher Haster |
1:24750b9ad5ef | 204 | * \param output buffer holding the output data |
Christopher Haster |
1:24750b9ad5ef | 205 | * |
Christopher Haster |
1:24750b9ad5ef | 206 | * \return 0 if successful |
Christopher Haster |
1:24750b9ad5ef | 207 | */ |
Christopher Haster |
1:24750b9ad5ef | 208 | int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 209 | int mode, |
Christopher Haster |
1:24750b9ad5ef | 210 | size_t length, |
Christopher Haster |
1:24750b9ad5ef | 211 | unsigned char iv[16], |
Christopher Haster |
1:24750b9ad5ef | 212 | const unsigned char *input, |
Christopher Haster |
1:24750b9ad5ef | 213 | unsigned char *output ); |
Christopher Haster |
1:24750b9ad5ef | 214 | #endif /*MBEDTLS_CIPHER_MODE_CFB */ |
Christopher Haster |
1:24750b9ad5ef | 215 | |
Christopher Haster |
1:24750b9ad5ef | 216 | #if defined(MBEDTLS_CIPHER_MODE_CTR) |
Christopher Haster |
1:24750b9ad5ef | 217 | /** |
Christopher Haster |
1:24750b9ad5ef | 218 | * \brief AES-CTR buffer encryption/decryption |
Christopher Haster |
1:24750b9ad5ef | 219 | * |
Christopher Haster |
1:24750b9ad5ef | 220 | * Warning: You have to keep the maximum use of your counter in mind! |
Christopher Haster |
1:24750b9ad5ef | 221 | * |
Christopher Haster |
1:24750b9ad5ef | 222 | * Note: Due to the nature of CTR you should use the same key schedule for |
Christopher Haster |
1:24750b9ad5ef | 223 | * both encryption and decryption. So a context initialized with |
Christopher Haster |
1:24750b9ad5ef | 224 | * mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT. |
Christopher Haster |
1:24750b9ad5ef | 225 | * |
Christopher Haster |
1:24750b9ad5ef | 226 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 227 | * \param length The length of the data |
Christopher Haster |
1:24750b9ad5ef | 228 | * \param nc_off The offset in the current stream_block (for resuming |
Christopher Haster |
1:24750b9ad5ef | 229 | * within current cipher stream). The offset pointer to |
Christopher Haster |
1:24750b9ad5ef | 230 | * should be 0 at the start of a stream. |
Christopher Haster |
1:24750b9ad5ef | 231 | * \param nonce_counter The 128-bit nonce and counter. |
Christopher Haster |
1:24750b9ad5ef | 232 | * \param stream_block The saved stream-block for resuming. Is overwritten |
Christopher Haster |
1:24750b9ad5ef | 233 | * by the function. |
Christopher Haster |
1:24750b9ad5ef | 234 | * \param input The input data stream |
Christopher Haster |
1:24750b9ad5ef | 235 | * \param output The output data stream |
Christopher Haster |
1:24750b9ad5ef | 236 | * |
Christopher Haster |
1:24750b9ad5ef | 237 | * \return 0 if successful |
Christopher Haster |
1:24750b9ad5ef | 238 | */ |
Christopher Haster |
1:24750b9ad5ef | 239 | int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 240 | size_t length, |
Christopher Haster |
1:24750b9ad5ef | 241 | size_t *nc_off, |
Christopher Haster |
1:24750b9ad5ef | 242 | unsigned char nonce_counter[16], |
Christopher Haster |
1:24750b9ad5ef | 243 | unsigned char stream_block[16], |
Christopher Haster |
1:24750b9ad5ef | 244 | const unsigned char *input, |
Christopher Haster |
1:24750b9ad5ef | 245 | unsigned char *output ); |
Christopher Haster |
1:24750b9ad5ef | 246 | #endif /* MBEDTLS_CIPHER_MODE_CTR */ |
Christopher Haster |
1:24750b9ad5ef | 247 | |
Christopher Haster |
1:24750b9ad5ef | 248 | /** |
Christopher Haster |
1:24750b9ad5ef | 249 | * \brief Internal AES block encryption function |
Christopher Haster |
1:24750b9ad5ef | 250 | * (Only exposed to allow overriding it, |
Christopher Haster |
1:24750b9ad5ef | 251 | * see MBEDTLS_AES_ENCRYPT_ALT) |
Christopher Haster |
1:24750b9ad5ef | 252 | * |
Christopher Haster |
1:24750b9ad5ef | 253 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 254 | * \param input Plaintext block |
Christopher Haster |
1:24750b9ad5ef | 255 | * \param output Output (ciphertext) block |
Christopher Haster |
1:24750b9ad5ef | 256 | */ |
Christopher Haster |
1:24750b9ad5ef | 257 | void mbedtls_aes_encrypt( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 258 | const unsigned char input[16], |
Christopher Haster |
1:24750b9ad5ef | 259 | unsigned char output[16] ); |
Christopher Haster |
1:24750b9ad5ef | 260 | |
Christopher Haster |
1:24750b9ad5ef | 261 | /** |
Christopher Haster |
1:24750b9ad5ef | 262 | * \brief Internal AES block decryption function |
Christopher Haster |
1:24750b9ad5ef | 263 | * (Only exposed to allow overriding it, |
Christopher Haster |
1:24750b9ad5ef | 264 | * see MBEDTLS_AES_DECRYPT_ALT) |
Christopher Haster |
1:24750b9ad5ef | 265 | * |
Christopher Haster |
1:24750b9ad5ef | 266 | * \param ctx AES context |
Christopher Haster |
1:24750b9ad5ef | 267 | * \param input Ciphertext block |
Christopher Haster |
1:24750b9ad5ef | 268 | * \param output Output (plaintext) block |
Christopher Haster |
1:24750b9ad5ef | 269 | */ |
Christopher Haster |
1:24750b9ad5ef | 270 | void mbedtls_aes_decrypt( mbedtls_aes_context *ctx, |
Christopher Haster |
1:24750b9ad5ef | 271 | const unsigned char input[16], |
Christopher Haster |
1:24750b9ad5ef | 272 | unsigned char output[16] ); |
Christopher Haster |
1:24750b9ad5ef | 273 | |
Christopher Haster |
1:24750b9ad5ef | 274 | #ifdef __cplusplus |
Christopher Haster |
1:24750b9ad5ef | 275 | } |
Christopher Haster |
1:24750b9ad5ef | 276 | #endif |
Christopher Haster |
1:24750b9ad5ef | 277 | |
Christopher Haster |
1:24750b9ad5ef | 278 | #else /* MBEDTLS_AES_ALT */ |
Christopher Haster |
1:24750b9ad5ef | 279 | #include "aes_alt.h" |
Christopher Haster |
1:24750b9ad5ef | 280 | #endif /* MBEDTLS_AES_ALT */ |
Christopher Haster |
1:24750b9ad5ef | 281 | |
Christopher Haster |
1:24750b9ad5ef | 282 | #ifdef __cplusplus |
Christopher Haster |
1:24750b9ad5ef | 283 | extern "C" { |
Christopher Haster |
1:24750b9ad5ef | 284 | #endif |
Christopher Haster |
1:24750b9ad5ef | 285 | |
Christopher Haster |
1:24750b9ad5ef | 286 | /** |
Christopher Haster |
1:24750b9ad5ef | 287 | * \brief Checkup routine |
Christopher Haster |
1:24750b9ad5ef | 288 | * |
Christopher Haster |
1:24750b9ad5ef | 289 | * \return 0 if successful, or 1 if the test failed |
Christopher Haster |
1:24750b9ad5ef | 290 | */ |
Christopher Haster |
1:24750b9ad5ef | 291 | int mbedtls_aes_self_test( int verbose ); |
Christopher Haster |
1:24750b9ad5ef | 292 | |
Christopher Haster |
1:24750b9ad5ef | 293 | #ifdef __cplusplus |
Christopher Haster |
1:24750b9ad5ef | 294 | } |
Christopher Haster |
1:24750b9ad5ef | 295 | #endif |
Christopher Haster |
1:24750b9ad5ef | 296 | |
Christopher Haster |
1:24750b9ad5ef | 297 | #endif /* aes.h */ |