TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_mbedcrypto_alt.c
Go to the documentation of this file.
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"
21 #endif
22 
23 #if defined(MBEDTLS_AES_DECRYPT_ALT) && defined(MBEDTLS_CCM_C)
24 #pragma message("mbedtls_internal_aes_decrypt() is replaced by an empty wrapper to decrease memory footprint")
25 /*
26  * Replace the decryption process with an empty wrapper in AES-CCM mode.
27  * The decryption process is exactly the same as encryption process. Skip
28  * the decryption implementation to decrease memory footprint.
29  */
30 int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx,
31  const unsigned char input[16],
32  unsigned char output[16])
33 {
34  (void)ctx;
35  (void)input;
36  (void)output;
37 
38  return MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE;
39 }
40 #endif
41 
42 #if defined(MBEDTLS_AES_SETKEY_DEC_ALT) && defined(MBEDTLS_CCM_C)
43 #pragma message("mbedtls_aes_setkey_dec() is replaced by an empty wrapper to decrease memory footprint")
44 /*
45  * Replace the decryption process with an empty wrapper in AES-CCM mode.
46  * The decryption process is exactly the same as encryption process. Skip
47  * the decryption key setting to decrease memory footprint.
48  */
49 int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key,
50  unsigned int keybits)
51 {
52  (void)ctx;
53  (void)key;
54  (void)keybits;
55 
56  return MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE;
57 }
58 #endif