-
Notifications
You must be signed in to change notification settings - Fork 3k
Update mbedtls importer to import mbed-crypto #8723
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What testing has been done so far? What's left to test?
features/mbedtls/importer/Makefile
Outdated
TARGET_SRC:=$(TARGET_PREFIX)src | ||
TARGET_INC:=$(TARGET_PREFIX)inc | ||
TARGET_TESTS:=$(TARGET_PREFIX)TESTS | ||
TARGET_SRV_IMPL:=$(TARGET_PREFIX_CRYPTO)/platform/COMPONENT_PSA_SRV_IMPL | ||
TARGET_SPE:=$(TARGET_PREFIX_CRYPTO)/platform/COMPONENT_SPE | ||
TARGETS_PSA_ACCELARATION:=$(TARGET_PREFIX_CRYPTO)/targets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix spelling of "ACCELARATION"
features/mbedtls/importer/Makefile
Outdated
TARGET_SRV_IMPL:=$(TARGET_PREFIX_CRYPTO)/platform/COMPONENT_PSA_SRV_IMPL | ||
TARGET_SPE:=$(TARGET_PREFIX_CRYPTO)/platform/COMPONENT_SPE | ||
TARGETS_PSA_ACCELARATION:=$(TARGET_PREFIX_CRYPTO)/targets | ||
COMPONENT_NSPE:=$(TARGET_SRV_IMPL)/COMPONENT_NSPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be "COMPONENT_" or "TARGET_". It isn't consistent with the previous things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am moving them back to component as a variable in the file, to be consistent with the other variables' names
features/mbedtls/importer/Makefile
Outdated
@@ -62,6 +71,20 @@ rsync: | |||
cp $(MBED_TLS_DIR)/LICENSE $(TARGET_PREFIX) | |||
cp $(MBED_TLS_DIR)/apache-2.0.txt $(TARGET_PREFIX) | |||
# | |||
# Copying mbed Crypto into mbed library.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use capital "Mbed". Probably also should say "Mbed OS" instead of "Mbed library".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
features/mbedtls/importer/Makefile
Outdated
TARGET_SRC:=$(TARGET_PREFIX)src | ||
TARGET_INC:=$(TARGET_PREFIX)inc | ||
TARGET_TESTS:=$(TARGET_PREFIX)TESTS | ||
TARGET_SRV_IMPL:=$(TARGET_PREFIX_CRYPTO)/platform/COMPONENT_PSA_SRV_IMPL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be prefixed with "COMPONENT_" or "TARGET_"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as here #8723 (comment)
features/mbedtls/importer/Makefile
Outdated
# Updating checked out version tag | ||
echo $(MBED_TLS_RELEASE) > $(TARGET_PREFIX)VERSION.txt | ||
# | ||
# Create mbed Crypto target folder | ||
mkdir -p $(TARGET_PREFIX_CRYPTO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be done in "update" or perhaps "rsync"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
@@ -107,4 +136,5 @@ clean: | |||
rm -rf $(TARGET_SRC) | |||
rm -rf $(TARGET_INC) | |||
rm -rf $(MBED_TLS_DIR) | |||
|
|||
rm -rf $(TARGET_SRV_IMPL) | |||
rm -rf $(TARGET_SPE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about COMPONENT_NSPE or others? Should we remove those as well here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMPONENT_NSPE
will be deleted with TARGET_SRV_IMPL
since it is an inner folder.
As I understood from @alzix that the acceleration
folder and TARGET_PREFIX_CRYPTO
folder should be always there and not deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dependent on Mbed TLS tag that contains Mbed Crypto
features/mbedtls/importer/Makefile
Outdated
@@ -27,20 +27,29 @@ | |||
# | |||
|
|||
# Set the mbed TLS release to import (this can/should be edited before import) | |||
MBED_TLS_RELEASE ?= mbedtls-2.13.1 | |||
MBED_TLS_RELEASE ?= mbedtls-2.14.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tag we use for the Mbed OS 5.11 release will be later than mbedtls-2.14.0
. Not known yet what we'll use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions and some requested changes.
features/mbedtls/importer/Makefile
Outdated
@@ -27,20 +27,29 @@ | |||
# | |||
|
|||
# Set the mbed TLS release to import (this can/should be edited before import) | |||
MBED_TLS_RELEASE ?= mbedtls-2.13.1 | |||
MBED_TLS_RELEASE ?= mbedtls-2.14.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be changed yet. 2.14.0 hasn't been released, doesn't reflect the version in the library, and won't be the version shipping in Mbed OS 5.11. Please revert.
features/mbedtls/importer/Makefile
Outdated
|
||
# Translate between mbed TLS namespace and mbed namespace | ||
TARGET_PREFIX:=../ | ||
TARGET_PREFIX_CRYPTO:=../crypto/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name we agreed for the directory was mbed-crypto
, not crypto
. Why the change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was based on: Mbed-TLS/mbedtls#2146
I followed the submodule folder name.
cc @Patater
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @sbutcher-arm ,
i hope it's not crucial for you. since the PR into mbedTLS also follows the 'crypto' naming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the target folder was renamed to mbed-crypto
features/mbedtls/importer/Makefile
Outdated
TARGET_SRC:=$(TARGET_PREFIX)src | ||
TARGET_INC:=$(TARGET_PREFIX)inc | ||
TARGET_TESTS:=$(TARGET_PREFIX)TESTS | ||
TARGET_SRV_IMPL:=$(TARGET_PREFIX_CRYPTO)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL | ||
TARGET_SPE:=$(TARGET_PREFIX_CRYPTO)/platform/TARGET_PSA/COMPONENT_SPE | ||
TARGET_PSA_ACCELERATION:=$(TARGET_PREFIX_CRYPTO)/targets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calling it 'acceleration' is a mistake, and it should be 'drivers' or 'hardware'. Not all driver code/hardware support will speed up crypto operations, and may instead just offer additional security.
@@ -92,6 +118,9 @@ update: $(MBED_TLS_GIT_CFG) $(MBED_TLS_HA_GIT_CFG) | |||
# Checking out the required release | |||
git -C $(MBED_TLS_DIR) checkout $(MBED_TLS_RELEASE) | |||
# | |||
# Update and checkout git submodules | |||
git -C $(MBED_TLS_DIR) submodule update --init --recursive | |||
# | |||
# Updating checked out version tag | |||
echo $(MBED_TLS_RELEASE) > $(TARGET_PREFIX)VERSION.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also capture the Crypto version? Or is the commit id of the submodule enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The submodule ties down the Mbed Crypto version, but I think it'd be nice to add to the VERSION.txt file for humans so they don't have to go dig it up themselves.
pushd $(MBED_TLS_DIR)/crypto
git describe --tags --abbrev=12 --dirty --always >> $(TARGET_PREFIX)VERSION.txt
popd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
# Create Mbed Crypto target folder | ||
mkdir -p $(TARGET_PREFIX_CRYPTO) | ||
# | ||
# Copying Mbed Crypto into Mbed OS.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what's going on here is a bit opaque to outsiders and other teams. There needs to be explanation here, (or pointers to documentation elsewhere) what these directories are and what they mean.
We need to explain what SPE, NSPE are, and what the other directories are and what they mean.
And most of all, we need to explain why we have so many directories. It will seem bizarre and unnecessarily complicated to outsiders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this directory hierarchy is exist in mbed-os I don't know how adding explanation here will help outsiders.
#8680 PR description explains that but not the merged code.
This PR: ARMmbed/mbed-os-5-docs#815 explains more about that and i think it will be helpful for outsiders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - Mbed TLS is my project that I work on daily, and these directories mean nothing to me. What do they do? What are they for? There's no explanation.
I think we need to either:
- add comments to explain these directories, either in this file or in another file in this directory
- tell me where there's other existing documentation that explains the structure elsewhere in the repository
- add a comment that points the reader to documentation somewhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the required documentation in the importer.
rm -rf $(TARGET_SPE) | ||
rm -rf $(TARGET_PSA_ACCELERATION) | ||
|
||
mkdir -p $(TARGET_SRV_IMPL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing and making these directories? Unlike the other directories being made, won't there be other files in these directories which aren't being imported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think only $(TARGET_PSA_ACCELERATION)
shouldn't be removed, the others are created and only the importer copies files into them.
@andresag01 - Can you please review this? Note to maintainers - please don't merge this until the TLS team have signed off on it. |
783f884
to
506e5c7
Compare
506e5c7
to
8b8990d
Compare
TARGET_SRC:=$(TARGET_PREFIX)src | ||
TARGET_INC:=$(TARGET_PREFIX)inc | ||
TARGET_TESTS:=$(TARGET_PREFIX)TESTS | ||
TARGET_SRV_IMPL:=$(TARGET_PREFIX_CRYPTO)/platform/TARGET_PSA/COMPONENT_PSA_SRV_IMPL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orenc17 does the build system recognize the PSA_TARGET
folder?
It will after #8744 will be merged. Till then mbed-cli will ignore this folder. |
set crypto storage related defines.
(cherry picked from commit 296001a)
@sbutcher-arm All the comments were treated can you please re review. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with the changes I requested.
@@ -140,3 +140,6 @@ conf unset MBEDTLS_SSL_TRUNCATED_HMAC | |||
|
|||
conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO | |||
|
|||
conf set MBEDTLS_PSA_CRYPTO_STORAGE_C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will be configurations of the crypto config.h
. At this point we share a config.h
, but that won't be true in the next release.
Therefore, I suggest putting a comment in to identify these as Crypto configs, as they have no meaning outside the Crypto submodule, and possibly structuring this to make the transition easier later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added documentation for the configurations
# Create Mbed Crypto target folder | ||
mkdir -p $(TARGET_PREFIX_CRYPTO) | ||
# | ||
# Copying Mbed Crypto into Mbed OS.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - Mbed TLS is my project that I work on daily, and these directories mean nothing to me. What do they do? What are they for? There's no explanation.
I think we need to either:
- add comments to explain these directories, either in this file or in another file in this directory
- tell me where there's other existing documentation that explains the structure elsewhere in the repository
- add a comment that points the reader to documentation somewhere else
* Introduce the new folders' structure for the mbed crypto target folder. * Explain about the need of the new configuration added to adjust-config.sh script
@Patater @sbutcher-arm please see the fixes. |
@@ -140,6 +140,8 @@ conf unset MBEDTLS_SSL_TRUNCATED_HMAC | |||
|
|||
conf unset MBEDTLS_PLATFORM_TIME_TYPE_MACRO | |||
|
|||
# The following configurations are a needed for Mbed Crypto submodule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker - but it should be:
The following configurations are needed
# New folder structure is introduced here for targets with Secured-Partition-Environment | ||
# and Non-Secured-Partition-Environment, below documentation for each folder: | ||
# COMPONENT_PSA_SRV_IMPL - include secure service business logic implementation | ||
# code. For example mbedCrytpo or secure time core logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker - there are a few typos here, and the phrasing can be better. You don't need to say "New folder". In a year's time, the comment will still be there, and it won't be new! Revising the language I'd suggest:
# The folder structure is for targets that compile to the Secured-Partition-Environment
# and Non-Secured-Partition-Environments. Documentation for each folder:
# COMPONENT_PSA_SRV_IMPL - includes secure service business logic implementation
# code. For example Mbed Crypto or the secure time core logic
There's also a few typos in the following lines. eg. "includes" not "include"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new documentation changes are good enough. Thanks @mohammad1603!
Let's do it in one (there are still some CI issues being fixed) |
Agree with @0xc0170 |
Ok - we can do that if it's easier for you. If you wish, you can label this as 'DO NOT MERGE' and I'll include it in my TLS release PR later in the day. |
This should be closed in favor of #8859 |
closed in favor of #8859 which contains all changes from this PR. |
Description
Update the mbedtls importer to import the implementation of PSA Crypto APIs given by Mbed Crypto library.
In addition, it import the files to folders' structure as designed in #8680.
This PR depends on #8680 and the new version of mbedtls (Mbed TLS 2.14.0).
Pull request type