blob: 3275766e218268d1e377631470eb76eb09037632 [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
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 Qin359167d2021-07-05 18:11:50 +080021#include "mbedtls/error.h"
David Hue954d6b2020-04-23 13:06:00 +080022#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 */
31int 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 Qin359167d2021-07-05 18:11:50 +080039 return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
David Hue954d6b2020-04-23 13:06:00 +080040}
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 */
50int 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 Qin359167d2021-07-05 18:11:50 +080057 return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
David Hue954d6b2020-04-23 13:06:00 +080058}
59#endif