blob: 5c321476e41b95191b1ad9667e04f85a46678272 [file] [log] [blame]
David Hue954d6b2020-04-23 13:06:00 +08001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Antonio de Angelis44e1e9e2022-12-01 13:50:24 +00008/**
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 Hue954d6b2020-04-23 13:06:00 +080017 */
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 Qin359167d2021-07-05 18:11:50 +080026#include "mbedtls/error.h"
David Hue954d6b2020-04-23 13:06:00 +080027#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 */
36int 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 Qin359167d2021-07-05 18:11:50 +080044 return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
David Hue954d6b2020-04-23 13:06:00 +080045}
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 */
55int 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 Qin359167d2021-07-05 18:11:50 +080062 return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
David Hue954d6b2020-04-23 13:06:00 +080063}
64#endif