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 TF-PSA-Crypto implementation (successor project that split off the crypto implementation from Mbed TLS) 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 default crypto implementation TF-PSA-Crypto, using Oberon PSA Crypto instead.
To migrate an application that
a) uses the crypto part of the Mbed TLS 3.x software stack via the PSA Certified Crypto API, but does not use its TLS protocol part, or b) uses TF-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 etc. See Appendix A: Supported Crypto Features for more information.
-
Select a target configuration example from the
targets/acmefolder, e.g.,demo. -
Create an
include/psa/crypto_config.hfile based on thecrypto_config.hexample in the target configuration'sdispatch/psafolder, adapt it based on your existingcrypto_config.hand if you are migrating from Mbed TLS 3.x, also on yourmbedtls_config.h. In TF-PSA-Crypto and Oberon PSA Crypto since 2.0, configuration aspects from both files are combined intocrypto_config.h. -
Make sure that your new
crypto_config.hfile defines the "wanted" crypto features as described above and add the use directives for a DRGB driver and provide 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. -
Make sure to remove the demo hardware, the demo opaque, and the demo entropy drivers for production use.
-
Copy the driver configuration files, i.e.,
psa/crypto_driver_contexts_composites.h,psa/crypto_driver_contexts_key_derivation.h,psa/crypto_driver_contexts_primitives.h,psa/crypto_driver_config.hfrom the target configuration'sdispatchfolder to yourincludefolder of Oberon PSA Crypto or make sure they can be found in the include path of your build. -
Copy the
psa_crypto_driver_wrappers.cfrom the target configuration'sdispatchfolder to yourdispatchfolder and add the code file to your build. -
Optionally, add your own hardware drivers and adapt the driver configuration files and the dispatch logic implementation accordingly.
-
Oberon PSA Crypto provides the TF-PSA-Crypto mock implementations for
MBEDTLS_PSA_CRYPTO_STORAGE_CandMBEDTLS_PSA_ITS_FILE_Cby default. They are handy for testing, and should be replaced by hardened implementations of the PSA Storage APIs for production use.
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 of the
MbedTLS project that may have to be
configured as well. See README-SSL for more
information.
The configuration in psa/crypto_config.h contains genuine PSA Crypto
configuration options with a PSA_ prefix and inherited options from former
MBed TLS with an MBEDTLS_ prefix, that can be configured.
Relevant for Oberon PSA Crypto:
MBEDTLS_THREADING_CMBEDTLS_PSA_CRYPTO_CMBEDTLS_PSA_CRYPTO_CLIENTMBEDTLS_PSA_CRYPTO_STORAGE_CMBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNERMBEDTLS_PSA_CRYPTO_BUILTIN_KEYSMBEDTLS_PSA_ITS_FILE_CMBEDTLS_PSA_KEY_STORE_DYNAMICMBEDTLS_PSA_KEY_SLOT_COUNTMBEDTLS_PSA_STATIC_KEY_SLOTSMBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE
Should always be defined:
MBEDTLS_USE_PSA_CRYPTOMBEDTLS_PSA_CRYPTO_CONFIG
Should never be defined:
MBEDTLS_PSA_ASSUME_EXCLUSIVE_BUFFERSMBEDTLS_PSA_CRYPTO_SPM
This file by Oberon microsystems is licensed under the Creative Commons Attribution-ShareAlike 4.0 License.