David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Antonio de Angelis | 44e1e9e | 2022-12-01 13:50:24 +0000 | [diff] [blame^] | 8 | /** |
| 9 | * \file This file collects the alternative functions to replace the |
| 10 | * implementations in mbed-crypto if the corresponding mbed-crypto |
| 11 | * MBEDTLS__FUNCTION_NAME__ALT is selected. |
| 12 | * |
| 13 | * \note This applies only when the legacy driver API based on the _ALT |
| 14 | * implementations is selected, and has no effect when the PSA driver |
| 15 | * interface is used. This is going to be deprecated in a future version |
| 16 | * of mbed TLS. |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | /* |
| 20 | * A dummy include. Just add a dependency to make sure this file is compiled |
| 21 | * after all crypto header files are installed and configuration flags are set. |
| 22 | */ |
| 23 | #include "tfm_mbedcrypto_include.h" |
| 24 | #if defined(MBEDTLS_AES_DECRYPT_ALT) || defined(MBEDTLS_AES_SETKEY_DEC_ALT) |
| 25 | #include "mbedtls/aes.h" |
Summer Qin | 359167d | 2021-07-05 18:11:50 +0800 | [diff] [blame] | 26 | #include "mbedtls/error.h" |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 27 | #endif |
| 28 | |
| 29 | #if defined(MBEDTLS_AES_DECRYPT_ALT) && defined(MBEDTLS_CCM_C) |
| 30 | #pragma message("mbedtls_internal_aes_decrypt() is replaced by an empty wrapper to decrease memory footprint") |
| 31 | /* |
| 32 | * Replace the decryption process with an empty wrapper in AES-CCM mode. |
| 33 | * The decryption process is exactly the same as encryption process. Skip |
| 34 | * the decryption implementation to decrease memory footprint. |
| 35 | */ |
| 36 | int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx, |
| 37 | const unsigned char input[16], |
| 38 | unsigned char output[16]) |
| 39 | { |
| 40 | (void)ctx; |
| 41 | (void)input; |
| 42 | (void)output; |
| 43 | |
Summer Qin | 359167d | 2021-07-05 18:11:50 +0800 | [diff] [blame] | 44 | return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 45 | } |
| 46 | #endif |
| 47 | |
| 48 | #if defined(MBEDTLS_AES_SETKEY_DEC_ALT) && defined(MBEDTLS_CCM_C) |
| 49 | #pragma message("mbedtls_aes_setkey_dec() is replaced by an empty wrapper to decrease memory footprint") |
| 50 | /* |
| 51 | * Replace the decryption process with an empty wrapper in AES-CCM mode. |
| 52 | * The decryption process is exactly the same as encryption process. Skip |
| 53 | * the decryption key setting to decrease memory footprint. |
| 54 | */ |
| 55 | int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, |
| 56 | unsigned int keybits) |
| 57 | { |
| 58 | (void)ctx; |
| 59 | (void)key; |
| 60 | (void)keybits; |
| 61 | |
Summer Qin | 359167d | 2021-07-05 18:11:50 +0800 | [diff] [blame] | 62 | return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 63 | } |
| 64 | #endif |