1 /*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
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.
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"
26 #include "mbedtls/error.h"
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 */
mbedtls_internal_aes_decrypt(mbedtls_aes_context * ctx,const unsigned char input[16],unsigned char output[16])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
44 return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
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 */
mbedtls_aes_setkey_dec(mbedtls_aes_context * ctx,const unsigned char * key,unsigned int keybits)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
62 return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
63 }
64 #endif
65