xref: /optee_os/lib/libmbedtls/mbedtls/CONTRIBUTING.md (revision b0563631928755fe864b97785160fb3088e9efdc)
13d3b0591SJens WiklanderContributing
23d3b0591SJens Wiklander============
332b31808SJens WiklanderWe gratefully accept bug reports and contributions from the community. All PRs are reviewed by the project team / community, and may need some modifications to
432b31808SJens Wiklanderbe accepted.
53d3b0591SJens Wiklander
632b31808SJens WiklanderQuick Checklist for PR contributors
732b31808SJens Wiklander-----------------------------------
832b31808SJens WiklanderMore details on all of these points may be found in the sections below.
932b31808SJens Wiklander
1032b31808SJens Wiklander- [Sign-off](#license-and-copyright): all commits must be signed off.
1132b31808SJens Wiklander- [Tests](#tests): please ensure the PR includes adequate tests.
1232b31808SJens Wiklander- [Changelog](#documentation): if needed, please provide a changelog entry.
1332b31808SJens Wiklander- [Backports](#long-term-support-branches): provide a backport if needed (it's fine to wait until the main PR is accepted).
143d3b0591SJens Wiklander
153d3b0591SJens WiklanderCoding Standards
163d3b0591SJens Wiklander----------------
1732b31808SJens Wiklander- Contributions should include tests, as mentioned in the [Tests](#tests) and [Continuous Integration](#continuous-integration-tests) sections. Please check that your contribution passes basic tests before submission, and check the CI results after making a pull request.
1832b31808SJens Wiklander- The code should be written in a clean and readable style, and must follow [our coding standards](https://mbed-tls.readthedocs.io/en/latest/kb/development/mbedtls-coding-standards/).
193d3b0591SJens Wiklander- The code should be written in a portable generic way, that will benefit the whole community, and not only your own needs.
203d3b0591SJens Wiklander- The code should be secure, and will be reviewed from a security point of view as well.
213d3b0591SJens Wiklander
223d3b0591SJens WiklanderMaking a Contribution
233d3b0591SJens Wiklander---------------------
24039e02dfSJerome Forissier1. [Check for open issues](https://github.com/Mbed-TLS/mbedtls/issues) or [start a discussion](https://lists.trustedfirmware.org/mailman3/lists/mbed-tls.lists.trustedfirmware.org) around a feature idea or a bug.
25039e02dfSJerome Forissier1. Fork the [Mbed TLS repository on GitHub](https://github.com/Mbed-TLS/mbedtls) to start making your changes. As a general rule, you should use the ["development" branch](https://github.com/Mbed-TLS/mbedtls/tree/development) as a basis.
263d3b0591SJens Wiklander1. Write a test which shows that the bug was fixed or that the feature works as expected.
27*b0563631STom Van Eyck1. Send a pull request (PR) and work with us until it gets merged and published. Contributions may need some modifications, so a few rounds of review and fixing may be necessary. See our [review process guidelines](https://mbed-tls.readthedocs.io/en/latest/reviews/review-for-contributors/).
283d3b0591SJens Wiklander1. For quick merging, the contribution should be short, and concentrated on a single feature or topic. The larger the contribution is, the longer it would take to review it and merge it.
293d3b0591SJens Wiklander
307901324dSJerome ForissierBackwards Compatibility
317901324dSJerome Forissier-----------------------
327901324dSJerome Forissier
337901324dSJerome ForissierThe project aims to minimise the impact on users upgrading to newer versions of the library and it should not be necessary for a user to make any changes to their own code to work with a newer version of the library. Unless the user has made an active decision to use newer features, a newer generation of the library or a change has been necessary due to a security issue or other significant software defect, no modifications to their own code should be necessary. To achieve this, API compatibility is maintained between different versions of Mbed TLS on the main development branch and in LTS (Long Term Support) branches, as described in [BRANCHES.md](BRANCHES.md).
343d3b0591SJens Wiklander
3532b31808SJens WiklanderTo minimise such disruption to users, where a change to the interface is required, all changes to the ABI or API, even on the main development branch where new features are added, need to be justifiable by either being a significant enhancement, new feature or bug fix which is best resolved by an interface change. If there is an API change, the contribution, if accepted, will be merged only when there is a major release.
363d3b0591SJens Wiklander
3732b31808SJens WiklanderNo changes are permitted to the definition of functions in the public interface which will change the API. Instead the interface can only be changed by its extension. Where changes to an existing interface are necessary, functions in the public interface which need to be changed are marked as 'deprecated'. If there is a strong reason to replace an existing function with one that has a slightly different interface (different prototype, or different documented behavior), create a new function with a new name with the desired interface. Keep the old function, but mark it as deprecated.
383d3b0591SJens Wiklander
393d3b0591SJens WiklanderPeriodically, the library will remove deprecated functions from the library which will be a breaking change in the API, but such changes will be made only in a planned, structured way that gives sufficient notice to users of the library.
403d3b0591SJens Wiklander
413d3b0591SJens WiklanderLong Term Support Branches
423d3b0591SJens Wiklander--------------------------
433d3b0591SJens WiklanderMbed TLS maintains several LTS (Long Term Support) branches, which are maintained continuously for a given period. The LTS branches are provided to allow users of the library to have a maintained, stable version of the library which contains only security fixes and fixes for other defects, without encountering additional features or API extensions which may introduce issues or change the code size or RAM usage, which can be significant considerations on some platforms. To allow users to take advantage of the LTS branches, these branches maintain backwards compatibility for both the public API and ABI.
443d3b0591SJens Wiklander
453d3b0591SJens WiklanderWhen backporting to these branches please observe the following rules:
463d3b0591SJens Wiklander
473d3b0591SJens Wiklander1. Any change to the library which changes the API or ABI cannot be backported.
4811fa71b9SJerome Forissier1. All bug fixes that correct a defect that is also present in an LTS branch must be backported to that LTS branch. If a bug fix introduces a change to the API such as a new function, the fix should be reworked to avoid the API change. API changes without very strong justification are unlikely to be accepted.
4911fa71b9SJerome Forissier1. If a contribution is a new feature or enhancement, no backporting is required. Exceptions to this may be additional test cases or quality improvements such as changes to build or test scripts.
503d3b0591SJens Wiklander
51039e02dfSJerome ForissierIt would be highly appreciated if contributions are backported to LTS branches in addition to the [development branch](https://github.com/Mbed-TLS/mbedtls/tree/development) by contributors.
523d3b0591SJens Wiklander
537901324dSJerome ForissierThe list of maintained branches can be found in the [Current Branches section
547901324dSJerome Forissierof BRANCHES.md](BRANCHES.md#current-branches).
557901324dSJerome Forissier
563d3b0591SJens WiklanderTests
573d3b0591SJens Wiklander-----
583d3b0591SJens WiklanderAs mentioned, tests that show the correctness of the feature or bug fix should be added to the pull request, if no such tests exist.
593d3b0591SJens Wiklander
6032b31808SJens WiklanderMbed TLS includes a comprehensive set of test suites in the `tests/` directory that are dynamically generated to produce the actual test source files (e.g. `test_suite_rsa.c`). These files are generated from a `function file` (e.g. `suites/test_suite_rsa.function`) and a `data file` (e.g. `suites/test_suite_rsa.data`). The function file contains the test functions. The data file contains the test cases, specified as parameters that will be passed to the test function.
613d3b0591SJens Wiklander
6232b31808SJens Wiklander[A Knowledge Base article describing how to add additional tests is available on the Mbed TLS website](https://mbed-tls.readthedocs.io/en/latest/kb/development/test_suites/).
633d3b0591SJens Wiklander
643d3b0591SJens WiklanderA test script `tests/scripts/basic-build-test.sh` is available to show test coverage of the library. New code contributions should provide a similar level of code coverage to that which already exists for the library.
653d3b0591SJens Wiklander
663d3b0591SJens WiklanderSample applications, if needed, should be modified as well.
673d3b0591SJens Wiklander
683d3b0591SJens WiklanderContinuous Integration Tests
693d3b0591SJens Wiklander----------------------------
703d3b0591SJens WiklanderOnce a PR has been made, the Continuous Integration (CI) tests are triggered and run. You should follow the result of the CI tests, and fix failures.
713d3b0591SJens Wiklander
72039e02dfSJerome ForissierIt is advised to enable the [githooks scripts](https://github.com/Mbed-TLS/mbedtls/tree/development/tests/git-scripts) prior to pushing your changes, for catching some of the issues as early as possible.
733d3b0591SJens Wiklander
743d3b0591SJens WiklanderDocumentation
753d3b0591SJens Wiklander-------------
763d3b0591SJens WiklanderMbed TLS is well documented, but if you think documentation is needed, speak out!
773d3b0591SJens Wiklander
783d3b0591SJens Wiklander1. All interfaces should be documented through Doxygen. New APIs should introduce Doxygen documentation.
7911fa71b9SJerome Forissier1. Complex parts in the code should include comments.
8011fa71b9SJerome Forissier1. If needed, a Readme file is advised.
8132b31808SJens Wiklander1. If a [Knowledge Base (KB)](https://mbed-tls.readthedocs.io/en/latest/kb/) article should be added, write this as a comment in the PR description.
82039e02dfSJerome Forissier1. A [ChangeLog](https://github.com/Mbed-TLS/mbedtls/blob/development/ChangeLog.d/00README.md) entry should be added for this contribution.
8332b31808SJens Wiklander
8432b31808SJens WiklanderLicense and Copyright
8532b31808SJens Wiklander---------------------
8632b31808SJens Wiklander
87*b0563631STom Van EyckUnless specifically indicated otherwise in a file, Mbed TLS files are provided under a dual [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) OR [GPL-2.0-or-later](https://spdx.org/licenses/GPL-2.0-or-later.html) license. See the [LICENSE](LICENSE) file for the full text of these licenses. This means that users may choose which of these licenses they take the code under.
88*b0563631STom Van Eyck
89*b0563631STom Van EyckContributors must accept that their contributions are made under both the Apache-2.0 AND [GPL-2.0-or-later](https://spdx.org/licenses/GPL-2.0-or-later.html) licenses.
90*b0563631STom Van Eyck
91*b0563631STom Van EyckAll new files should include the standard SPDX license identifier where possible, i.e. "SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later".
9232b31808SJens Wiklander
9332b31808SJens WiklanderThe copyright on contributions is retained by the original authors of the code. Where possible for new files, this should be noted in a comment at the top of the file in the form: "Copyright The Mbed TLS Contributors".
9432b31808SJens Wiklander
95*b0563631STom Van EyckWhen contributing code to us, the committer and all authors are required to make the submission under the terms of the [Developer Certificate of Origin](dco.txt), confirming that the code submitted can (legally) become part of the project, and is submitted under both the Apache-2.0 AND GPL-2.0-or-later licenses.
96*b0563631STom Van Eyck
97*b0563631STom Van EyckThis is done by including the standard Git `Signed-off-by:` line in every commit message. If more than one person contributed to the commit, they should also add their own `Signed-off-by:` line.
98