Skip to content

Commit

Permalink
Introduce MBEDTLS_PRIVATE macro.
Browse files Browse the repository at this point in the history
Public structs members are considered private and should not
be used by users application.

MBEDTLS_PRIVATE(member) macro is intended to clearly indicate
which members are private.

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
  • Loading branch information
mstarzyk-mobica committed May 14, 2021
1 parent b680078 commit 599a086
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 8 deletions.
7 changes: 7 additions & 0 deletions library/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@
#define MBEDTLS_STATIC_TESTABLE static
#endif

/** Allow library to access it's structs' private members.
*
* Although structs defined in header files are publicly available,
* their members are private and should not be accessed by the user.
*/
#define MBEDTLS_ALLOW_PRIVATE_ACCESS

#endif /* MBEDTLS_LIBRARY_COMMON_H */
1 change: 1 addition & 0 deletions library/psa_crypto_driver_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* limitations under the License.
*/

#include "common.h"
#include "psa_crypto_aead.h"
#include "psa_crypto_cipher.h"
#include "psa_crypto_core.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/include/test/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#ifndef TEST_HELPERS_H
#define TEST_HELPERS_H

#define MBEDTLS_ALLOW_PRIVATE_ACCESS

#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
Expand Down
2 changes: 2 additions & 0 deletions tests/src/drivers/test_driver_aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include MBEDTLS_CONFIG_FILE
#endif

#include <test/helpers.h>

#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST)
#include "psa_crypto_aead.h"

Expand Down
2 changes: 2 additions & 0 deletions tests/src/drivers/test_driver_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include MBEDTLS_CONFIG_FILE
#endif

#include <test/helpers.h>

#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST)
#include "psa/crypto.h"
#include "psa_crypto_cipher.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/src/drivers/test_driver_signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include MBEDTLS_CONFIG_FILE
#endif

#include <test/helpers.h>

#if defined(MBEDTLS_PSA_CRYPTO_DRIVERS) && defined(PSA_CRYPTO_DRIVER_TEST)
#include "psa/crypto.h"
#include "psa_crypto_core.h"
Expand Down
2 changes: 2 additions & 0 deletions tests/suites/helpers.function
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/*----------------------------------------------------------------------------*/
/* Headers */

#define MBEDTLS_ALLOW_PRIVATE_ACCESS

#include <test/macros.h>
#include <test/helpers.h>
#include <test/random.h>
Expand Down
8 changes: 0 additions & 8 deletions tests/suites/main_test.function
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@
#include MBEDTLS_CONFIG_FILE
#endif

#if defined(MBEDTLS_USE_PSA_CRYPTO)
#include "psa/crypto.h"
#endif /* MBEDTLS_USE_PSA_CRYPTO */

#if defined(MBEDTLS_TEST_HOOKS)
#include "mbedtls/error.h"
#endif

/* Test code may use deprecated identifiers only if the preprocessor symbol
* MBEDTLS_TEST_DEPRECATED is defined. When building tests, set
* MBEDTLS_TEST_DEPRECATED explicitly if MBEDTLS_DEPRECATED_WARNING is
Expand Down

0 comments on commit 599a086

Please sign in to comment.