blob: b748aac32bbbf0fd3f728493c8462d85195048c6 [file] [log] [blame] [view] [raw]
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +02001# mbed TLS
2
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +01003mbed TLS makes it trivially easy for developers to include cryptographic and SSL/TLS capabilities in their embedded products, with a minimal code footprint. It offers an SSL library with an intuitive API and readable source code.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +02004
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +01005**Note:** The current release is beta, and implements no secure source of random numbers, weakening its security.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +02006
Manuel Pégourié-Gonnardf13139a2015-10-21 18:32:34 +02007Currently the only supported yotta targets are:
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +01008- `frdm-k64f-gcc`
9- `frdm-k64f-armcc`
10- `x86-linux-native`
11- `x86-osx-native`
Manuel Pégourié-Gonnardf13139a2015-10-21 18:32:34 +020012
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020013## Sample programs
14
15This release includes the following examples:
16
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +0100171. [**Self test:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-selftest) Tests different basic functions in the mbed TLS library.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020018
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +0100192. [**Benchmark:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-benchmark) Measures the time taken to perform basic cryptographic functions used in the library.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020020
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +0100213. [**Hashing:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-hashing) Demonstrates the various APIs for computing hashes of data (also known as message digests) with SHA-256.
Manuel Pégourié-Gonnard87173fa2015-10-21 18:38:02 +020022
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +0100234. [**Authenticated encryption:**](https://github.com/ARMmbed/mbedtls/blob/development/yotta/data/example-authcrypt) Demonstrates usage of the Cipher API for encrypting and authenticating data with AES-CCM.
Manuel Pégourié-Gonnard87173fa2015-10-21 18:38:02 +020024
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010025These examples are integrated as yotta tests, so that they are built automatically when you build mbed TLS. Each of them comes with complete usage instructions as a Readme file in the repository.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020026
Manuel Pégourié-Gonnardf45fd732015-10-21 17:54:11 +020027## Performing TLS and DTLS connections
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020028
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010029A high-level API for performing TLS and DTLS connections with mbed TLS in mbed OS is provided in a separate yotta module: [mbed-tls-sockets](https://github.com/ARMmbed/mbed-tls-sockets). We recommend this API for TLS and DTLS connections. It is very similar to the API provided by the [sockets](https://github.com/ARMmbed/sockets) module for unencrypted TCP and UDP connections.
Manuel Pégourié-Gonnardf45fd732015-10-21 17:54:11 +020030
31The `mbed-tls-sockets` module includes a complete [example TLS client](https://github.com/ARMmbed/mbed-tls-sockets/blob/master/test/tls-client/main.cpp) with [usage instructions](https://github.com/ARMmbed/mbed-tls-sockets/blob/master/test/tls-client/README.md).
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020032
Manuel Pégourié-Gonnard32da9f62015-07-31 15:52:30 +020033## Configuring mbed TLS features
34
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010035mbed TLS makes it easy to disable any feature during compilation, if that feature isn't required for a particular project. The default configuration enables all modern and widely-used features, which should meet the needs of new projects, and disables all features that are older or less common, to minimize the code footprint.
Manuel Pégourié-Gonnard32da9f62015-07-31 15:52:30 +020036
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010037The list of available compilation flags is available in the fully documented [config.h file](https://github.com/ARMmbed/mbedtls/blob/development/include/mbedtls/config.h).
Irit Arkin4d8edd52015-08-24 13:50:25 +010038
Manuel Pégourié-Gonnardac121732015-10-21 18:33:07 +020039If you need to adjust those flags, you can provide your own configuration-adjustment file with suitable `#define` and `#undef` statements. These will be included between the default definitions and the sanity checks. Your configuration file should be in your application's include directory, and can be named freely; you just need to let mbed TLS know the file's name. To do that, use yotta's [configuration system](http://docs.yottabuild.org/reference/config.html). The file's name should be in your `config.json` file, under mbedtls, as the key `user-config-file`.
40
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010041For example, in an application called `myapp`, if you want to enable the EC J-PAKE key exchange and disable the CBC cipher mode, you can create a file named `mbedtls-config-changes.h` in the `myapp` directory containing the following lines:
Manuel Pégourié-Gonnardac121732015-10-21 18:33:07 +020042
43 #define MBEDTLS_ECJPAKE_C
44 #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
45
46 #undef MBEDTLS_CIPHER_MODE_CBC
47
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010048And then create a file named `config.json` at the root of your application with the following contents:
Manuel Pégourié-Gonnard32da9f62015-07-31 15:52:30 +020049
50 {
51 "mbedtls": {
Manuel Pégourié-Gonnardac121732015-10-21 18:33:07 +020052 "user-config-file": "\"myapp/mbedtls-config-changes.h\""
Manuel Pégourié-Gonnard32da9f62015-07-31 15:52:30 +020053 }
54 }
55
Irit Arkin4d8edd52015-08-24 13:50:25 +010056Please note: you need to provide the exact name that will be used in the `#include` directive, including the `<>` or quotes around the name.
Manuel Pégourié-Gonnard32da9f62015-07-31 15:52:30 +020057
Manuel Pégourié-Gonnard79800962015-10-22 10:48:47 +020058## Getting mbed TLS from GitHub
59
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010060Like most components of mbed OS, mbed TLS is developed in the open and its source can be found on GitHub: [ARMmbed/mbedtls](https://github.com/ARMmbed/mbedtls). Unlike most other mbed OS components, however, you cannot just clone the repository and run `yotta build` from its root. This is because mbed TLS also exists as an independent component, so its repository includes things that are not relevant for mbed OS, as well as other build systems.
Manuel Pégourié-Gonnard79800962015-10-22 10:48:47 +020061
62The way to use mbed TLS from a clone of the GitHub repository is to run the following commands from the root of a checkout:
63
64 yotta/create-module.sh
65 cd yotta/module
66
67You can then run any yotta command you would normally run, such as `yotta build` or `yotta link`.
68
69## Differences between the standalone and mbed OS editions
70
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010071While the two editions share the same code base, there are still a number of differences, mainly in configuration and integration. You should keep in mind those differences when reading some articles in our [knowledge base](https://tls.mbed.org/kb), as currently all the articles are about the standalone edition.
Manuel Pégourié-Gonnard79800962015-10-22 10:48:47 +020072
73* The mbed OS edition has a smaller set of features enabled by default in `config.h`, in order to reduce footprint. While the default configuration of the standalone edition puts more emphasize on maintaining interoperability with old peers, the mbed OS edition only enables the most modern ciphers and the latest version of (D)TLS.
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010074
Andres AG788aa4a2016-09-14 14:32:09 +010075* The following components of mbed TLS are disabled in the mbed OS edition: `net_sockets.c` and `timing.c`. This is because mbed OS include their equivalents.
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +010076
77* The mbed OS edition comes with a fully integrated API for (D)TLS connections in a companion module: [mbed-tls-sockets](https://github.com/ARMmbed/mbed-tls-sockets). See "Performing TLS and DTLS connections" above.
78
79## Other resources
80
81The [mbed TLS website](https://tls.mbed.org) contains many other useful
82resources for the developer, such as [developer
83documentation](https://tls.mbed.org/dev-corner), [knowledgebase
84articles](https://tls.mbed.org/kb), and a [support forum](https://tls.mbed.org/discussions).
Manuel Pégourié-Gonnard79800962015-10-22 10:48:47 +020085
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020086## Contributing
87
Manuel Pégourié-Gonnard3dce9ec2015-08-27 10:07:09 +020088We 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:
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020089
Manuel Pégourié-Gonnard324fc022015-08-20 11:51:53 +020090* Simple bug fixes to existing code do not contain copyright themselves and we can integrate without issue. The same is true of trivial contributions.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020091
Irit Arkin4d8edd52015-08-24 13:50:25 +010092* For larger contributions, such as a new feature, the code can possibly fall under copyright law. We then need your consent to share in the ownership of the copyright. We have a form for this, which we will send to you in case you submit a contribution or pull request that we deem this necessary for.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020093
94To contribute, please:
95
96* [Check for open issues](https://github.com/ARMmbed/mbedtls/issues) or [start a discussion](https://tls.mbed.org/discussions) around a feature idea or a bug.
97
Irit Arkin4d8edd52015-08-24 13:50:25 +010098* 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 as a basis.
Manuel Pégourié-Gonnard63e7eba2015-07-28 14:17:48 +020099
100* Write a test that shows that the bug was fixed or that the feature works as expected.
101
Manuel Pégourié-Gonnard231a0652015-10-26 17:50:04 +0100102* Send a pull request and bug us until it gets merged and published. We will include your name in the ChangeLog.
103