Below, two scenarios are discussed relating to Mbed TLS:
- Migrate an application that uses Mbed TLS cryptography functions through the PSA Certified Crypto API from the Mbed TLS crypto implementation to Oberon PSA Crypto.
- Migrating an application that uses Mbed TLS as a TLS stack, so that it continues using the protocol implementation of Mbed TLS, but without the crypto implementation that comes with Mbed TLS, using Oberon PSA Crypto instead.
If an application that uses the crypto part of the Mbed TLS software stack via the PSA Certified Crypto API, but does not use its TLS protocol part, should be migrated to Oberon PSA Crypto:
-
Make sure that your application only uses the PSA Certified Crypto API for all crypto calls.
-
Make sure that your application only uses the modern crypto algorithms that Oberon PSA Crypto supports, e.g., not MD5. See Appendix A: Supported Crypto Features for more information.
-
Copy your existing
mbedtls/mbedtls_config.hconfiguration file to the corresponding location in Oberon PSA Crypto. Oberon PSA Crypto provides the Mbed TLS implementations forMBEDTLS_PSA_CRYPTO_STORAGE_CandMBEDTLS_PSA_ITS_FILE_Cby default, but can use other provided implementations of these PSA Storage APIs. -
Copy your existing
psa/crypto_config.hfile toinclude/psa/in Oberon PSA Crypto. -
Make sure that the
include/psa/crypto_config.hfile defines the "wanted" crypto features as described above. -
In the
include/psa/crypto_config.hfile, add the use directives for a DRGB driver and an entropy driver. Oberon PSA Crypto provides the DRBG directivesPSA_USE_CTR_DRBG_DRIVERandPSA_USE_HMAC_DRBG_DRIVERfor production, and the entropy driver directivePSA_USE_DEMO_ENTROPY_DRIVERfor testing. -
Copy the header files
include/psa/crypto_driver_contexts_composites.h,include/psa/crypto_driver_contexts_key_derivation.h,include/psa/crypto_driver_contexts_primitives.h,include/psa/crypto_driver_config.hand the driver wrapper implementationlibrary/psa_crypto_driver_wrappers.cfrom the folderoberon/platforms. Demo files for the configuration of Oberon PSA Crypto drivers are located in subfoldersdemo/include/psaanddemo/library.
If the TLS protocol part of the Mbed TLS software stack is used with Oberon
PSA Crypto, there are settings in include/mbedtls/mbedtls_config.h that may
have to be configured as well.
See README-SSL
for more information.
The following defines in mbedtls_config.h are relevant for Oberon PSA Crypto:
MBEDTLS_THREADING_CMBEDTLS_PSA_CRYPTO_CMBEDTLS_PSA_CRYPTO_CLIENTMBEDTLS_PSA_CRYPTO_STORAGE_CMBEDTLS_PSA_ITS_FILE_CMBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNERMBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
Only relevant for testing:
MBEDTLS_STATIC_TESTABLEMBEDTLS_TEST_HOOKSMBEDTLS_TEST_HOOK_TEST_ASSERTMBEDTLS_TEST_PSA_SKIP_IF_SMALL_RSA_KEY(introduced by Oberon microsystems)
Should always be defined:
MBEDTLS_USE_PSA_CRYPTOMBEDTLS_PSA_CRYPTO_CONFIG
Should never be defined:
MBEDTLS_PSA_CRYPTO_SE_CMBEDTLS_PSA_INJECT_ENTROPYMBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERSMBEDTLS_PSA_CRYPTO_SPM