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 | |
| 8 | /* |
| 9 | * 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 | |
| 14 | /* |
| 15 | * A dummy include. Just add a dependency to make sure this file is compiled |
| 16 | * after all crypto header files are installed and configuration flags are set. |
| 17 | */ |
| 18 | #include "tfm_mbedcrypto_include.h" |
| 19 | #if defined(MBEDTLS_AES_DECRYPT_ALT) || defined(MBEDTLS_AES_SETKEY_DEC_ALT) |
| 20 | #include "mbedtls/aes.h" |
Summer Qin | 359167d | 2021-07-05 18:11:50 +0800 | [diff] [blame^] | 21 | #include "mbedtls/error.h" |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 22 | #endif |
| 23 | |
| 24 | #if defined(MBEDTLS_AES_DECRYPT_ALT) && defined(MBEDTLS_CCM_C) |
| 25 | #pragma message("mbedtls_internal_aes_decrypt() is replaced by an empty wrapper to decrease memory footprint") |
| 26 | /* |
| 27 | * Replace the decryption process with an empty wrapper in AES-CCM mode. |
| 28 | * The decryption process is exactly the same as encryption process. Skip |
| 29 | * the decryption implementation to decrease memory footprint. |
| 30 | */ |
| 31 | int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx, |
| 32 | const unsigned char input[16], |
| 33 | unsigned char output[16]) |
| 34 | { |
| 35 | (void)ctx; |
| 36 | (void)input; |
| 37 | (void)output; |
| 38 | |
Summer Qin | 359167d | 2021-07-05 18:11:50 +0800 | [diff] [blame^] | 39 | return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 40 | } |
| 41 | #endif |
| 42 | |
| 43 | #if defined(MBEDTLS_AES_SETKEY_DEC_ALT) && defined(MBEDTLS_CCM_C) |
| 44 | #pragma message("mbedtls_aes_setkey_dec() is replaced by an empty wrapper to decrease memory footprint") |
| 45 | /* |
| 46 | * Replace the decryption process with an empty wrapper in AES-CCM mode. |
| 47 | * The decryption process is exactly the same as encryption process. Skip |
| 48 | * the decryption key setting to decrease memory footprint. |
| 49 | */ |
| 50 | int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, |
| 51 | unsigned int keybits) |
| 52 | { |
| 53 | (void)ctx; |
| 54 | (void)key; |
| 55 | (void)keybits; |
| 56 | |
Summer Qin | 359167d | 2021-07-05 18:11:50 +0800 | [diff] [blame^] | 57 | return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; |
David Hu | e954d6b | 2020-04-23 13:06:00 +0800 | [diff] [blame] | 58 | } |
| 59 | #endif |