Skip to content
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

Document (with examples) how to integrate a third-party driver with Mbed TLS #6915

Merged

Conversation

aditya-deshpande-arm
Copy link
Contributor

@aditya-deshpande-arm aditya-deshpande-arm commented Jan 12, 2023

Description

There is not much documentation on how a driver or software accelerator can be integrated alongside Mbed TLS. The proposed PSA Driver Interface, which aims to auto-generate driver wrappers, has only been partially implemented. It would be useful to have a guide in the interim which shows how to integrate drivers for operations for whom auto code-gen has not been implemented.

p256-m has been used as an example driver to show how a third party driver can be used with Mbed TLS.

TODO before merge

Note: all_u16-check_files is expected to fail on PR-Head . This is because the version of check_files.py on this branch does not allow for box drawings characters. PR #6982 allows these characters and has been merged. all_u16-check_files should pass on PR-Merge.

Gatekeeper checklist

  • changelog not required, documentation changes only (unless addition of a new config option warrants one?)
  • backport not required
  • testsnot required

@aditya-deshpande-arm aditya-deshpande-arm added the needs-preceding-pr Requires another PR to be merged first label Jan 17, 2023
@aditya-deshpande-arm aditya-deshpande-arm force-pushed the example-driver-post-codestyle branch 2 times, most recently from 07aedf0 to 5e93e5c Compare February 6, 2023 17:09
@aditya-deshpande-arm aditya-deshpande-arm added needs-review Every commit must be reviewed by at least two team members, component-docs Docs / website issues filed here for tracking needs-reviewer This PR needs someone to pick it up for review and removed needs-work needs-preceding-pr Requires another PR to be merged first labels Feb 6, 2023
/*
* Interface of curve P-256 (ECDH and ECDSA)
*
* Author: Manuel Pégourié-Gonnard.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this explicitly state copyright? @mpg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you mention it, I think it should.

@daverodgman
Copy link
Contributor

Please include a short readme in 3rdparty/p-256m/README.md, similar to the one for Everest, that explains where the code comes from, license, etc, and a brief explanation of what it's for.

@mpg mpg self-requested a review February 8, 2023 09:21
@aditya-deshpande-arm
Copy link
Contributor Author

Please include a short readme in 3rdparty/p-256m/README.md, similar to the one for Everest, that explains where the code comes from, license, etc, and a brief explanation of what it's for.

Done

@daverodgman
Copy link
Contributor

daverodgman commented Feb 10, 2023

Reminder: we need to check the process defined in https://confluence.arm.com/display/OSS/Including+third+party+open+source+in+an+Arm+OSS+project

Discussed with Aditya and agreed:

  • licenses are compatible (both Apache 2)
  • this does not change the scope of approval for Mbed TLS (it does not add new features, only new implementations of existing features)
  • the changes to p256-m are minor configuration changes (adding a RNG)

As per the checklist

  • all license files, notices and headers are retained - no, missing the README. Maybe cleaner to rename the license file to LICENSE as per the original.
  • Add a note to the main project README - not done
  • nice-to-have: put third party code in separate directory
  • extra-nice-to-have: create a top-level SPDX document - out of scope for this PR

When these are all concluded, please email OSRB as an FYI, linking them to this PR, and give them the opportunity to respond (let's say 2 weeks) before we merge. I don't expect they will request any changes or have any concerns, but best to keep them informed.

@aditya-deshpande-arm
Copy link
Contributor Author

Reminder: we need to check the process defined in https://confluence.arm.com/display/OSS/Including+third+party+open+source+in+an+Arm+OSS+project

Discussed with Aditya and agreed:

  • licenses are compatible (both Apache 2)
  • this does not change the scope of approval for Mbed TLS (it does not add new features, only new implementations of existing features)
  • the changes to p256-m are minor configuration changes (adding a RNG)

As per the checklist

  • all license files, notices and headers are retained - no, missing the README. Maybe cleaner to rename the license file to LICENSE as per the original.
  • Add a note to the main project README - not done
  • nice-to-have: put third party code in separate directory
  • extra-nice-to-have: create a top-level SPDX document - out of scope for this PR

When these are all concluded, please email OSRB as an FYI, linking them to this PR, and give them the opportunity to respond (let's say 2 weeks) before we merge. I don't expect they will request any changes or have any concerns, but best to keep them informed.

Added the README from the p256-m repo in its original form. It should be noted however that it mentions scripts/files from the original repo that were not copied to mbedtls (should we edit these out?). I've also renamed the license file to LICENSE.

The License section of the mbedtls project README has been updated so that it mentions both everest and p256-m.

@daverodgman
Copy link
Contributor

daverodgman commented Mar 16, 2023

Added the README from the p256-m repo in its original form. It should be noted however that it mentions scripts/files from the original repo that were not copied to mbedtls (should we edit these out?). I've also renamed the license file to LICENSE.

I think the simplest thing is just to add a short note at the top of the README that explains this.

README.md Outdated Show resolved Hide resolved
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
…on based on mbedtls_ctr_drbg

Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
…date with upstream, plus other minor grammatical fixes.

Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Also check if p256-m is enabled in the config before including the contents of p256-m.c

Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
Signed-off-by: Aditya Deshpande <aditya.deshpande@arm.com>
@aditya-deshpande-arm
Copy link
Contributor Author

Had to make a few further changes to make the CI happy, but it's ready to go now.

Copy link
Contributor

@daverodgman daverodgman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mpg mpg added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels May 2, 2023
@mpg mpg merged commit 8e076e4 into Mbed-TLS:development May 2, 2023
@mpg
Copy link
Contributor

mpg commented Aug 7, 2023

  • tests not required

Really? This PR contains a non-trivial amount of code in p256-m_driver_entrypoints.c and I can't see any reason why this code shouldn't be tested.

@daverodgman I think you and I failed to notice, as reviewers, that this PR lacks testing. Two things should have alerted us:

  1. a non-trivial amount of C code is introduced, so we should have made sure it was covered (ideally even measured its coverage);
  2. a new config option was added, so we should have made sure that all.sh tests at least one config when it's disabled (OK, default and full) and one config where it's enabled (none currently).

Not the end of the world, but let's be more careful in the future. Tests are being added in #8032 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports component-docs Docs / website issues filed here for tracking priority-medium Medium priority - this can be reviewed as time permits size-m Estimated task size: medium (~1w)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants