blob: b3a9547a5127bc913ad7749bc1d9e99277820fd2 [file] [log] [blame] [view]
Ron Eldorea24d752017-08-31 17:02:01 +03001Contributing
2============
Ron Eldorb5e6a772017-08-16 11:23:31 +03003We gratefully accept bug reports and contributions from the community. There are some requirements we need to fulfill in order to be able to integrate contributions:
4
Ron Eldor7f888982017-08-16 16:05:52 +03005 - As with any open source project, contributions will be reviewed by the project team and community and may need some modifications to be accepted.
6 - The contribution should not break API or ABI, unless there is a real justification for that. If there is an API change, the contribution, if accepted, will be merged only when there will be a major release.
7
Ron Eldorea24d752017-08-31 17:02:01 +03008Coding Standards
9----------------
Ron Eldorb2231fc2017-09-10 17:32:05 +030010- We would ask that contributions conform to [our coding standards](https://tls.mbed.org/kb/development/mbedtls-coding-standards), and that contributions are fully tested before submission, as mentioned in the [Tests](#tests) and [Continuous Integration](#continuous-integration-tests) sections.
Ron Eldor7f888982017-08-16 16:05:52 +030011- The code should be written in a clean and readable style.
12- The code should be written in a portable generic way, that will benefit the whole community, and not only your own needs.
Ron Eldorea24d752017-08-31 17:02:01 +030013- The code should be secure, and will be reviewed from a security point of view as well.
Ron Eldorb5e6a772017-08-16 11:23:31 +030014
Ron Eldorea24d752017-08-31 17:02:01 +030015Making a Contribution
16---------------------
Janos Follatha85c2b22020-05-06 11:11:39 +0100171. [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://lists.trustedfirmware.org/mailman/listinfo/mbed-tls) around a feature idea or a bug.
Ron Eldorb2231fc2017-09-10 17:32:05 +0300181. Fork the [Mbed TLS repository on GitHub](https://github.com/ARMmbed/mbedtls) to start making your changes. As a general rule, you should use the ["development" branch](https://github.com/ARMmbed/mbedtls/tree/development) as a basis.
Ron Eldorea24d752017-08-31 17:02:01 +0300191. Write a test which shows that the bug was fixed or that the feature works as expected.
Ron Eldorb2231fc2017-09-10 17:32:05 +0300201. 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. We will include your name in the ChangeLog :)
Ron Eldorea24d752017-08-31 17:02:01 +0300211. 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.
Dan Handleyc76a5452020-02-18 17:58:20 +0000221. All new files should include the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) standard license header where possible.
231. Ensure that each commit has at least one `Signed-off-by:` line from the committer. If anyone else contributes to the commit, they should also add their own `Signed-off-by:` line. By adding this line, contributor(s) certify that the contribution is made under the terms of the [Developer Certificate of Origin](dco.txt). The contribution licensing is described in the [License section of the README](README.md#License).
Ron Eldorb5e6a772017-08-16 11:23:31 +030024
Manuel Pégourié-Gonnard80c02af2021-02-25 12:34:58 +010025Backwards Compatibility
26-----------------------
27
28The 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).
Simon Butcher7870ec12018-07-20 19:39:10 +010029
Simon Butcher10f96632018-07-23 16:10:36 +010030To 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.
Simon Butcher7870ec12018-07-20 19:39:10 +010031
Simon Butcher10f96632018-07-23 16:10:36 +010032Where changes to an existing interface are necessary, functions in the public interface which need to be changed, are marked as 'deprecated'. This is done with the preprocessor symbols `MBEDTLS_DEPRECATED_WARNING` and `MBEDTLS_DEPRECATED_REMOVED`. Then, a new function with a new name but similar if not identical behaviour to the original function containing the necessary changes should be created alongside the existing deprecated function.
Simon Butcher7870ec12018-07-20 19:39:10 +010033
Simon Butcher10f96632018-07-23 16:10:36 +010034When a build is made with the deprecation preprocessor symbols defined, a compiler warning will be generated to warn a user that the function will be removed at some point in the future, notifying users that they should change from the older deprecated function to the newer function at their own convenience.
Simon Butcher7870ec12018-07-20 19:39:10 +010035
Simon Butcher10f96632018-07-23 16:10:36 +010036Therefore, no 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. As described above, if a function needs to be changed, a new function needs to be created alongside it, with a new name, and whatever change is necessary, such as a new parameter or the addition of a return value.
Simon Butcher7870ec12018-07-20 19:39:10 +010037
Simon Butcher10f96632018-07-23 16:10:36 +010038Periodically, 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.
Simon Butcher7870ec12018-07-20 19:39:10 +010039
Simon Butcherd50f7862018-07-03 16:11:44 +010040Long Term Support Branches
41--------------------------
Simon Butcher7870ec12018-07-20 19:39:10 +010042Mbed 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.
Ron Eldorb5e6a772017-08-16 11:23:31 +030043
Simon Butcherd50f7862018-07-03 16:11:44 +010044When backporting to these branches please observe the following rules:
45
Dan Handley16a98852020-02-18 18:00:05 +0000461. Any change to the library which changes the API or ABI cannot be backported.
471. 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.
481. 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.
Simon Butcher7870ec12018-07-20 19:39:10 +010049
Simon Butcher269e9992018-07-24 14:41:02 +010050It would be highly appreciated if contributions are backported to LTS branches in addition to the [development branch](https://github.com/ARMmbed/mbedtls/tree/development) by contributors.
Simon Butcherd50f7862018-07-03 16:11:44 +010051
Manuel Pégourié-Gonnard80c02af2021-02-25 12:34:58 +010052The list of maintained branches can be found in the [Current Branches section
53of BRANCHES.md](BRANCHES.md#current-branches).
54
Simon Butcherd50f7862018-07-03 16:11:44 +010055Currently maintained LTS branches are:
Ron Eldor0caddf72019-01-02 10:58:25 +0200561. [mbedtls-2.7](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.7)
Ron Eldor0caddf72019-01-02 10:58:25 +0200571. [mbedtls-2.16](https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.16)
Simon Butcher7870ec12018-07-20 19:39:10 +010058
Ron Eldorb5e6a772017-08-16 11:23:31 +030059
Ron Eldorea24d752017-08-31 17:02:01 +030060Tests
61-----
Simon Butcher7870ec12018-07-20 19:39:10 +010062As mentioned, tests that show the correctness of the feature or bug fix should be added to the pull request, if no such tests exist.
63
64Mbed 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_mpi.c`). These files are generated from a `function file` (e.g. `suites/test_suite_mpi.function`) and a `data file` (e.g. `suites/test_suite_mpi.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.
65
Simon Butcher6965f772018-07-23 23:57:07 +010066[A Knowledge Base article describing how to add additional tests is available on the Mbed TLS website](https://tls.mbed.org/kb/development/test_suites).
Simon Butcher5a5d03f2018-07-23 16:16:04 +010067
Simon Butcher269e9992018-07-24 14:41:02 +010068A 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.
Ron Eldorb5e6a772017-08-16 11:23:31 +030069
Ron Eldor7f888982017-08-16 16:05:52 +030070Sample applications, if needed, should be modified as well.
71
Ron Eldorea24d752017-08-31 17:02:01 +030072Continuous Integration Tests
73----------------------------
Simon Butcher7870ec12018-07-20 19:39:10 +010074Once 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.
75
Ron Eldor1680d3d2017-08-16 17:28:21 +030076It is advised to enable the [githooks scripts](https://github.com/ARMmbed/mbedtls/tree/development/tests/git-scripts) prior to pushing your changes, for catching some of the issues as early as possible.
Ron Eldor7f888982017-08-16 16:05:52 +030077
Ron Eldorea24d752017-08-31 17:02:01 +030078Documentation
79-------------
Simon Butcher10f96632018-07-23 16:10:36 +010080Mbed TLS is well documented, but if you think documentation is needed, speak out!
Ron Eldor7f888982017-08-16 16:05:52 +030081
821. All interfaces should be documented through Doxygen. New APIs should introduce Doxygen documentation.
Dan Handley16a98852020-02-18 18:00:05 +0000831. Complex parts in the code should include comments.
841. If needed, a Readme file is advised.
851. If a [Knowledge Base (KB)](https://tls.mbed.org/kb) article should be added, write this as a comment in the PR description.
Paul Elliott8c4fd402020-05-21 15:46:43 +0100861. A [ChangeLog](https://github.com/ARMmbed/mbedtls/blob/development/ChangeLog.d/00README.md) entry should be added for this contribution.