mbed-tls / tf-psa-crypto Goto Github PK
View Code? Open in Web Editor NEWReference implementation of the PSA Cryptography API
License: Apache License 2.0
Reference implementation of the PSA Cryptography API
License: Apache License 2.0
As part of our implementation of the PSA cryptography API, we need to define macros(like configuration options), types (like operation object types) and functions that are specific to our implementation. In Mbed TLS repository where the PSA cryptography API implementation is located for the time being those symbols are prefixed with MBEDTLS_PSA_ or mbedtls_psa_ as we think about our implementation as the Mbed TLS implementation of the PSA cryptography API. With the move of the PSA cryptography implementation to its own repository named PSA-Crypto, one may wonder if this should change or not.
As we aim for a group of three repositories (mbedtls, psa-crypto, mbedtls-tf(?)) I think it makes sense to keep the PSA cryptography implementation under the Mbed TLS umbrella. We would then keep the MBEDTLS_PSA_ and mbedtls_psa_ prefixes for the symbols specific to the implementation of the PSA cryptography API. We would also keep MBEDTLS_ and mbedtls_ prefixes for macros, types and functions exposed by PSA-Crypto beyond the PSA cryptography API, thinking about LMS, asn1 (useful to implement protocols like but not restricted to TLS using PSA Crypto API), platform(?) APIs here.
Add generated file checks
DOD: Same support for generated file checking in psa-crypto as in mbedtls
The development branch of the PSA cryptography repository is aimed to contain only code specific to the repo, not the files copied from the Mbed TLS repository. That's the purpose of the main branch to contain the content of the development branch and the files copied from a given commit of the Mbed TLS repository.
The purpose of this task is to create the main branch, document it together with the development branch in a BRANCHES.md file and describe the process to update it from a new commit of the Mbed TLS repository.
Add same support for Microsoft Visual Studio as in Mbed TLS in the PSA cryptography repository.
Fixed by #28.
Similar to the MBEDTLS_DEPRECATED_REMOVED/WARNING mbedtls config options, add PSA_CRYPTO_DEPRECATED_REMOVED/WARNING config options.
Note: no all.sh component with PSA_CRYPTO_DEPRECATED_WARNING for the time being. We need to define first what is the psa-crypto full configuration is to add all.sh components involving PSA_CRYPTO_DEPRECATED_WARNING similar to the one involving
MBEDTLS_DEPRECATED_WARNING in mbedtls.
Depends on:
Investigate which Mbed TLS all.sh test and build components should have an equivalent in psa-crypto and in what form.
List of Mbed TLS test components in the below tables as of 87fe996.
Below table of the Mbed TLS all.sh test components for which it is planned to have an equivalent in psa-crypto:
Mbed TLS | psa-crypto | Issue | Comment |
---|---|---|---|
default_out_of_box | |||
default_no_deprecated | 54 | ||
default_cmake_gcc_asan | 56 | ||
default_cmake_gcc_asan_new_bignum | 56 | ||
full_cmake_gcc_asan | 59 | ||
full_cmake_gcc_asan_new_bignum | 59 | ||
full_cmake_gcc_asan_new_bignum_test_hooks | 59 | ||
full_no_deprecated | 59 | ||
full_no_deprecated_deprecated_warning | 59 | ||
full_deprecated_warning | 59 | ||
full_cmake_clang | 59 | ||
psa_compliance | psa_compliance | - | |
psa_crypto_drivers | psa_crypto_drivers | - | |
ccm_aes_sha256 | ccm_aes_sha256 | - | ref_configs? |
cmake_as_subdirectory | cmake_as_subdirectory | 33 | |
cmake_as_package | cmake_as_package | 33 | |
cmake_as_package_install | cmake_as_package_install | 33 | |
cmake_shared | cmake_shared | 33 | |
clang_latest_opt | 60 | ||
clang_earliest_opt | 60 | ||
gcc_latest_opt | 60 | ||
gcc_earliest_opt | 60 | ||
psa_crypto_config_accel_ecdsa | 61 | ||
psa_crypto_config_accel_ecdh | 62 | ||
psa_crypto_config_accel_ffdh | 62 | ||
psa_crypto_config_reference_ffdh | 62 | ||
psa_crypto_config_accel_pake | 62 | ||
psa_crypto_config_accel_ecc_ecp_light_only | 62 | ||
psa_crypto_config_reference_ecc_ecp_light_only | 62 | ||
psa_crypto_config_accel_ecc_ffdh_no_bignum | 62 | ||
psa_crypto_config_reference_ecc_ffdh_no_bignum | 62 | ||
psa_crypto_config_accel_ecc_no_ecp_at_all | 62 | ||
psa_crypto_config_reference_ecc_no_ecp_at_all | 62 | ||
psa_crypto_config_accel_ecc_no_bignum | 62 | ||
psa_crypto_config_reference_ecc_no_bignum | 62 | ||
psa_crypto_config_accel_all_curves_except_p192 | 62 | ||
psa_crypto_config_accel_all_curves_except_x25519 | 62 | ||
psa_crypto_config_accel_rsa_signature | 62 | ||
psa_crypto_config_accel_hash | 62 | ||
psa_crypto_config_accel_hash_keep_builtins | 62 | ||
psa_crypto_config_accel_hash_use_psa` | 62 | ||
psa_crypto_config_reference_hash_use_psa | 62 | ||
psa_crypto_config_accel_cipher | 62 | ||
psa_crypto_config_accel_aead | 62 | ||
psa_ecc_key_pair_no_derive | 63 | ||
psa_ecc_key_pair_no_generate | 63 | ||
new_psa_want_key_pair_symbol | 63 | ||
aead_chachapoly_disabled | 63 | ||
aead_only_ccm | 63 | ||
psa_crypto_key_id_encodes_owner | 63 | ||
crypto_for_psa_service | 63 | ||
test_psa_crypto_rsa_no_genprime | test_no_rsa_key_pair_generation | 63 | |
memsan | 64 | ||
memsan_constant_flow_psa | 64 | ||
valgrind_psa | 64 | ||
valgrind_constant_flow_psa | 64 | ||
aesni | 65 | ||
aes_only_128_bit_keys | 65 | ||
aes_only_128_bit_keys_have_builtins | 65 | ||
aes_fewer_tables | 65 | ||
aes_rom_tables | 65 | ||
aes_fewer_tables_and_rom_tables | 65 | ||
no_ctr_drbg_use_psa | hmac_drbg | 67 | |
no_ctr_drbg_aes_only_128_bit_keys | hmac_drbg_aes_only_128_bit_keys | 67 | |
ctr_drbg_aes_256_sha_256 | 67 | ||
ctr_drbg_aes_128_sha_512 | 67 | ||
ctr_drbg_aes_128_sha_256 | 67 | ||
psa_external_rng_no_drbg_use_psa | psa_external_rng | 67 | |
psa_external_rng_use_psa_crypto | psa_external_rbg | 67 | |
no_udbl_division | 68 | ||
no_64bit_multiplication | 68 | ||
m32_o0 | 68 | ||
m32_o2 | 68 | ||
mx32 | 68 | ||
min_mpi_window_size | 68 | ||
have_int32 | 68 | ||
have_int64 | 68 | ||
psa_inject_entropy | 69 | ||
depends_py_cipher_id_psa | 70 | ||
depends_py_cipher_chaining_psa | 70 | ||
depends_py_curves_psa | 70 | ||
depends_py_hashes_psa | 70 | ||
depends_py_pkalgs_psa | 70 | ||
rsa_no_crt | 73 | ||
test_memory_buffer_allocator_backtrace | 74 | ||
test_memory_buffer_allocator | 74 | ||
test_ref_configs | 75 | ||
test_tfm_config_p256m_driver_accel_ec | test_ccm_aes_sha256_secp256r1_p256m | 77 | |
TBC |
Document any differences in the release process that apply to PSA Crypto as opposed to Mbed TLS.
Note: no all.sh component for the _IF_PRESENT config options in Mbed TLS.
Update monthly the PSA crypto main branch against Mbed TLS development as described in the section "Updating the main branch" in psa-crypto-repository.md.
As part of the work to bring the testing in PSA-Crypto at the level it is in Mbed-TLS, add in tests/all_sh_components.txt
a component equivalent to component_test_psa_crypto_config_accel_ecdsa
to be the first libtestdriver1
component in PSA-Crypto.
. the cmake build system needs to be used instead of the make one.
. some adjustments to the all.sh framework (everything but the components in all.sh) is likely to be necessary.
Notes:
Define the configuration corresponding to TF-M profile small. Define an all.sh component to test the configuration.
https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git/tree/lib/ext/mbedcrypto/mbedcrypto_config/crypto_config_profile_small.h
Add in psa-crypto the equivalent of the components:
Not in scope of this issue:
Depends on:
Add file checks
DOD: Same support for file checking in psa-crypto as in mbedtls
The configuration of the PSA cryptography repository is based on the PSA cryptography configuration as described in psa-conditional-incluson-c.md. Some additional implementation (not specification) specific configuration is needed though. The goal of this task is to define and document this.
The Mbed TLS configuration file mbedtls_config.h is still used internally in builtin but not accessible to the user.
Configuration options in mbedtls_config.h relevant to the PSA implementation:
MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER
MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS
MBEDTLS_PSA_CRYPTO_CLIENT Not sure about the use cases
MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG
MBEDTLS_PSA_CRYPTO_SPM
MBEDTLS_PSA_INJECT_ENTROPY keep ?
MBEDTLS_PSA_CRYPTO_STORAGE_C
MBEDTLS_PSA_ITS_FILE_C
MBEDTLS_PSA_HMAC_DRBG_MD_TYPE MBEDTLS_MD_SHA256 ?
MBEDTLS_PSA_CRYPTO_CONFIG_FILE "psa/crypto_config.h"
MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE "/dev/null"
MBEDTLS_PSA_KEY_SLOT_COUNT 32
MBEDTLS_TEST_HOOKS
We probably need a psa_crypto_config.h with an equivalent to the above plus somehow crypto_config.h.
No equivalent of mbedtls/check_config.h, rather resolve dependencies?
Add check_recursion and check_test_cases all.sh components.
Note: recursion.pl and check_test_cases.py does not need to be adapted to psa-crypto, they just work for psa-crypto as well.
We must use the same license as Mbed TLS, so that when Mbed TLS pulls in PSA-Crypto source code, it can redistribute it under the licensing scheme used by Mbed TLS.
If Mbed TLS reverts to Apache 2.0 or GPL 2, this means that PSA-Crypto must do the same. We will have a definite decision on this in mid-October time, so it makes sense to delay making PSA-Crypto public until we know which option we will go for.
In preparation of publication, improve the documentation of the repository: add BUGS.md, SECURITY.md, files in Mbed TLS docs relevant to PSA-Crypto. Add semantic versioning documentation.
Timebox task.
Add semantic versioning in PSA-Crypto as it is in Mbed-TLS.
Three macros defining the version: PSA_CRYPTO_VERSION_MAJOR/MINOR/PATCH. Version of the prototype for its publication: 0.1.0 or 0.3.x (aligned with MbedTLS but shifted) ? bump_version.sh needs to be adapted.
The PSA cryptography repository does not inherit the platform abstraction of the Mbed TLS repository.
Platform abstraction needs (no dynamic configuration, probably not exhaustive):
psa_crypto_calloc(), psa_crypto_free(), psa_crypto_snprintf(), psa_crypto_setbuf(), psa_crypto_zeroize(), C11 like mutex, C11 like condition ...
The PSA-Crypto cmake build system is independent of the Mbed TLS ones but originates from it. It is based on the Mbed TLS cmake build system from Mbed-TLS/mbedtls@32605b24be. Since then some fixes have been applied to the Mbed TLS cmake build system. The goal of this task is to apply the relevant fixes to the PSA-Crypto cmake build system.
Not in the scope of this issue: IAR support.
Add in psa-crypto component files the equivalent of:
Demonstrate testing with libtestdriver1
by adding the equivalent of test_psa_crypto_config_accel_ecdsa
.
Add in psa-crypto the equivalent of:
Depends on:
Import the test suites of all crypto modules in PSA-Crypto as it aims to become the repository where the crypto development occurs. Check that all test suites are not at least once in all.sh.
Update monthly the PSA crypto main branch against Mbed TLS development as described in the section "Updating the main branch" in psa-crypto-repository.md. As long as the CI is not ready the testing of the update will be done by running locally all.sh.
Add code style check
DOD: Same support for code style checking in psa-crypto as in mbedtls
N.B. Depends on issue #50
We need the equivalent of the Mbed TLS component component_test_psa_compliance
as part of the validation of the PSA cryptography repository code.
Depends on:
The main branch of the PSA crypto repo is going to be synchronized regularly with the head of the Mbed TLS development branch.
The synchronization is done by pushing a pull request targeting the main branch and based on the head of the PSA crypto repo and the Mbed TLS development branches. CI jobs (based on all.sh) are run against this pull request and if all tests are run successfully the PR can be merged into the main branch and the synchronization is completed.
To build the main branch of the PSA-Crypto repository from a commit of the Mbed TLS development branch a few commits are necessary on top of the development branch commit, see https://github.com/ronald-cron-arm/mbedtls/tree/base-for-psa-crypto-PR7644. This task is about creating PR(s) against Mbed TLS development to merge into Mbed TLS the changes done on scripts.
DoD: No change on scripts needed to build the main branch of the PSA-Crypto repository from a commit of the Mbed TLS development branch.
Split all.sh into two files: everything but the components (all.sh framework) and the test components. Mbed-TLS and PSA-Crypto share the all.sh framework and both have their own test components file.
With this we should be able to get rid of replace_all_sh_components
in scripts/psa_crypto.py
.
Add support for psa-crypto repo in config.py regarding the options baremetal
,baremetal_size
,full
,full_no_deprecated
,realfull
,crypto
,crypto_baremetal
,crypto_full
.
The configuration file in psa-crypto is include/psa/crypto_config.h. It contains PSA_CRYPTO_ and PSA_WANT_ configuration options and thus config.py should be able to handle those configuration options.
We have in build_tree.py looks_like_psa_crypto_root() to detect if we are in the mbedtls or psa-crypto repo.
In psa-crypto, baremetal
and crypto_baremetal
are equivalent, as well as full
and crypto_full
. crypto does not do anything, just the default psa-crypto configuration.
Collect pro-actively and address feedback about the PSA crypto repo prototype. This issue is to reserve time (~one week) to collect feedback and address some of it (no commitment to address it all).
As part of the work to bring the testing in PSA-Crypto at the level it is in Mbed-TLS, add in tests/all_sh_components.txt the components equivalent to the component_test_cmake_* Mbed-TLS ones.
DoD: the component_test_cmake_* run successfully with equivalent testing as the Mbed-TLS ones.
Add in psa-crypto the equivalent of:
Notes:
Depends on:
Add doxygen checks
DOD: Same support for doxygen checks in psa-crypto as in mbedtls
Depends on #58
Port code from Mbed-TLS/mbedtls#7980 to the PSA Crypto repo
Add to PSA-Crypto the remaining Mbed TLS crypto modules that were not included in the first place as they are not used by the PSA implementation yet. Those are mostly modules used to import and export keys in various formats. They will be hopefully soon used by the PSA API implementation with the development of extended import/export APIs.
List of the modules to add:
base64.c, nist_kw.c, pem.c, pkcs5.c, pkcs12.c (not pkcs7.c as it currently contains things that are rather on the side on using crypto than providing crypto like TLS or x509).
Add the associated test suites and a specific all.sh component that enable them beyond the PSA-Crypto configuration and test them.
Requirement checklist
Epic checklist
To build the main branch of the PSA-Crypto repository from a commit of the Mbed TLS development branch a few commits are necessary on top of the development branch commit, see https://github.com/ronald-cron-arm/mbedtls/tree/base-for-psa-crypto-PR7644. This task is about creating PR(s) against Mbed TLS development to merge into Mbed TLS the changes done on the library.
DoD: No change on the library code needed to build the main branch of the PSA-Crypto repository from a commit of the Mbed TLS development branch.
Notes:
Depends on:
The PSA cryptography repository prototype will support less functionalities than the Mbed TLS libmbedcrypto library. The purpose of this task is to document what is supported in libmbedcrypto and will not be supported in the PSA cryptography repository prototype.
CTR_DRBG and HMAC_DRBG configuration
LMS
PK
no heap implementation
Generating coverage data in the Mbed TLS repo is done by the script lcov.sh
. In the PSA Crypto repo it is currently done inline in the lcov
target in CMake.
It would be best to unify these two approaches by using the lcov.sh
script in PSA Crypto. However, this script cannot be used directly in PSA Crypto as it refers to the library
directory, which is unique to Mbed TLS.
This task consists of 2 parts:
lcov.sh
so that it works in either the Mbed TLS or PSA Crypto repo.lcov.sh
to the PSA Crypto repo and use it in the CMake lcov
target.Notes:
Depends on:
Add name checks
DOD: Same support for name checking in psa-crypto as in mbedtls
Add change log support
DOD: Same support for change logs in psa-crypto as in mbedtls
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.