Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PSA_CRYPTO_DEPRECATED_REMOVED/WARNING config options from Mbed TLS #95

Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#ifndef MBEDTLS_CONFIG_ADJUST_MBEDTLS_FROM_TF_PSA_CRYPTO_H
#define MBEDTLS_CONFIG_ADJUST_MBEDTLS_FROM_TF_PSA_CRYPTO_H

/* General configuration options. */

#if defined(TF_PSA_CRYPTO_KEY_ID_ENCODES_OWNER)
#define MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
#endif
Expand Down Expand Up @@ -50,6 +52,14 @@
#define mbedtls_platform_zeroize tf_psa_crypto_platform_zeroize
#endif

#if defined(PSA_CRYPTO_DEPRECATED_WARNING)
#define MBEDTLS_DEPRECATED_WARNING
#endif

#if defined(PSA_CRYPTO_DEPRECATED_REMOVED)
#define MBEDTLS_DEPRECATED_REMOVED
#endif

#if defined(TF_PSA_CRYPTO_BUILTIN_KEYS)
#define MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
#endif
Expand Down Expand Up @@ -195,4 +205,6 @@
#define MBEDTLS_LMS_C
#endif



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for extra newlines.

#endif /* MBEDTLS_CONFIG_ADJUST_MBEDTLS_FROM_TF_PSA_CRYPTO_H */
27 changes: 27 additions & 0 deletions include/psa/crypto_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,33 @@
*/
//#define TF_PSA_CRYPTO_PLATFORM_ZEROIZE

/**
* \def PSA_CRYPTO_DEPRECATED_WARNING
*
* Mark deprecated functions and features so that they generate a warning if
* used. Functionality deprecated in one version will usually be removed in the
* next version. You can enable this to help you prepare the transition to a
* new major version by making sure your code is not using this functionality.
*
* This only works with GCC and Clang. With other compilers, you may want to
* use PSA_CRYPTO_DEPRECATED_REMOVED
*
* Uncomment to get warnings on using deprecated functions and features.
*/
//#define PSA_CRYPTO_DEPRECATED_WARNING

/**
* \def PSA_CRYPTO_DEPRECATED_REMOVED
*
* Remove deprecated functions and features so that they generate an error if
* used. Functionality deprecated in one version will usually be removed in the
* next version. You can enable this to help you prepare the transition to a
* new major version by making sure your code is not using this functionality.
*
* Uncomment to get errors on using deprecated functions and features.
*/
//#define PSA_CRYPTO_DEPRECATED_REMOVED

/*
* Platform exit macros
*/
Expand Down
20 changes: 20 additions & 0 deletions tests/all_sh_components.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,23 @@ component_test_cmake_shared () {
cd "$TF_PSA_CRYPTO_ROOT_DIR"
rm -rf "$OUT_OF_SOURCE_DIR"
}

component_test_default_no_deprecated () {
# Test that removing the deprecated features from the default
# configuration leaves something consistent.
msg "build: make, default + PSA_CRYPTO_DEPRECATED_REMOVED" # ~ 30s
scripts/config.py -f "include/psa/crypto_config.h" set PSA_CRYPTO_DEPRECATED_REMOVED

TF_PSA_CRYPTO_ROOT_DIR="$PWD"
mkdir "$OUT_OF_SOURCE_DIR"
cd "$OUT_OF_SOURCE_DIR"

CC=gcc cmake -DCMAKE_C_FLAGS="-O -Werror -Wall -Wextra" ..
make

msg "test: make, default + PSA_CRYPTO_DEPRECATED_REMOVED" # ~ 5s
make test

cd "$TF_PSA_CRYPTO_ROOT_DIR"
rm -rf "$OUT_OF_SOURCE_DIR"
}