Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 1 | # Mbed Crypto library |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 2 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 3 | The Mbed cryptography library is a reference implementation of the cryptography interface of the Arm Platform Security Architecture (PSA). This is a preview release of Mbed Crypto, provided for evaluation purposes only. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 4 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 5 | Mbed Crypto is distributed under the Apache License, version 2.0. See the [LICENSE](LICENSE) file for the full text of the license. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 6 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 7 | ## PSA cryptography API |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 8 | |
Gilles Peskine | 24354a7 | 2019-11-12 18:02:05 +0100 | [diff] [blame] | 9 | Arm's [Platform Security Architecture (PSA)](https://developer.arm.com/architectures/security-architectures/platform-security-architecture) is a holistic set of threat models, security analyses, hardware and firmware architecture specifications, and an open source firmware reference implementation. PSA provides a recipe, based on industry best practice, that allows security to be consistently designed in, at both a hardware and firmware level. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 10 | |
Gilles Peskine | 24354a7 | 2019-11-12 18:02:05 +0100 | [diff] [blame] | 11 | The [PSA cryptography API](https://armmbed.github.io/mbed-crypto/psa/#application-programming-interface) provides access to a set of cryptographic primitives. It has a dual purpose. First, it can be used in a PSA-compliant platform to build services, such as secure boot, secure storage and secure communication. Second, it can also be used independently of other PSA components on any platform. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 12 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 13 | The design goals of the PSA cryptography API include: |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 14 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 15 | * The API distinguishes caller memory from internal memory, which allows the library to be implemented in an isolated space for additional security. Library calls can be implemented as direct function calls if isolation is not desired, and as remote procedure calls if isolation is desired. |
| 16 | * The structure of internal data is hidden to the application, which allows substituting alternative implementations at build time or run time, for example, in order to take advantage of hardware accelerators. |
| 17 | * All access to the keys happens through handles, which allows support for external cryptoprocessors that is transparent to applications. |
| 18 | * The interface to algorithms is generic, favoring algorithm agility. |
| 19 | * The interface is designed to be easy to use and hard to accidentally misuse. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 20 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 21 | ## Mbed Crypto implementation |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 22 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 23 | Mbed Crypto is a reference implementation of the PSA cryptography API. It is written in portable C. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 24 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 25 | ## Documentation |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 26 | |
Gilles Peskine | d296e82 | 2019-11-12 18:00:51 +0100 | [diff] [blame] | 27 | The Mbed Crypto library implements both the legacy Mbed TLS interfaces to cryptographic primitives (`mbedtls_xxx`) and the new PSA Cryptography interfaces (`psa_xxx`). |
| 28 | |
| 29 | Documentation for the Mbed TLS interfaces in the default library configuration is available as part of the [Mbed TLS documentation](https://tls.mbed.org/api/). |
Gilles Peskine | ec82da4 | 2017-10-02 10:52:50 +0200 | [diff] [blame] | 30 | |
Gilles Peskine | 24354a7 | 2019-11-12 18:02:05 +0100 | [diff] [blame] | 31 | For the PSA interfaces, please refer to the PSA Cryptography API documents linked from the [PSA cryptography interfaces documentation portal](https://armmbed.github.io/mbed-crypto/psa/#application-programming-interface) for an overview of the library's interfaces and a detailed description of the types, macros and functions that it provides. The API reference is available in [PDF](https://armmbed.github.io/mbed-crypto/PSA_Cryptography_API_Specification.pdf) and [HTML](https://armmbed.github.io/mbed-crypto/html/index.html) formats. |
| 32 | |
Gilles Peskine | 7b39508 | 2019-01-31 11:56:02 +0100 | [diff] [blame] | 33 | There are currently a few deviations where the library does not yet implement the latest version of the specification. Please refer to the [compliance issues on Github](https://github.com/ARMmbed/mbed-crypto/labels/compliance) for an up-to-date list. |
| 34 | |
Gilles Peskine | 7b39508 | 2019-01-31 11:56:02 +0100 | [diff] [blame] | 35 | ### Browsable library documentation |
| 36 | |
Gilles Peskine | 7dd0b45 | 2019-11-12 18:01:51 +0100 | [diff] [blame] | 37 | To generate a local copy of the library documentation in HTML format, tailored to your compile-time configuration: |
Gilles Peskine | 7b39508 | 2019-01-31 11:56:02 +0100 | [diff] [blame] | 38 | |
| 39 | 1. Make sure that [Doxygen](http://www.doxygen.nl/) is installed. We use version 1.8.11 but slightly older or more recent versions should work. |
| 40 | 1. Run `make apidoc`. |
| 41 | 1. Browse `apidoc/index.html` or `apidoc/modules.html`. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 42 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 43 | ## Compiling |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 44 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 45 | You need the following tools to build the library with the provided makefiles: |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 46 | |
Jaeden Amero | 852dac2 | 2018-11-09 15:47:58 +0000 | [diff] [blame] | 47 | * GNU Make or a build tool that CMake supports. |
Jaeden Amero | a49ba5e | 2018-11-09 15:46:12 +0000 | [diff] [blame] | 48 | * A C99 toolchain (compiler, linker, archiver). |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 49 | * Python 2 or Python 3 (either will work) to generate the test code. |
| 50 | * Perl to run the tests. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 51 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 52 | If you have a C compiler, such as GCC or Clang, just run `make` in the top-level directory to build the library, a set of unit tests and some sample programs. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 53 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 54 | To select a different compiler, set the `CC` variable to the name or path of the compiler and linker (default: `cc`), and set `AR` to a compatible archiver (default: `ar`). For example: |
| 55 | ``` |
| 56 | make CC=arm-linux-gnueabi-gcc AR=arm-linux-gnueabi-ar |
| 57 | ``` |
| 58 | The provided makefiles pass options to the compiler that assume a GCC-like command-line syntax. To use a different compiler, you may need to pass different values for `CFLAGS`, `WARNINGS_CFLAGS` and `LDFLAGS`. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 59 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 60 | To run the unit tests on the host machine, run `make test` from the top-level directory. If you are cross-compiling, copy the test executable from the `tests` directory to the target machine. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 61 | |
Jaeden Amero | 11293cc | 2018-11-02 12:22:34 +0000 | [diff] [blame] | 62 | ### Compiling as a subproject |
| 63 | |
| 64 | Mbed Crypto supports being built as a subproject of Mbed TLS. Mbed TLS can use Mbed Crypto for its cryptography implementation by using Mbed Crypto as a subproject. |
| 65 | |
| 66 | From the Mbed TLS project repository, CMake can be invoked as follows to build Mbed TLS using Mbed Crypto's `libmbedcrypto`. |
| 67 | ``` |
| 68 | mkdir cmake |
| 69 | cd cmake |
| 70 | cmake .. -DUSE_CRYPTO_SUBMODULE=1 |
| 71 | make -j |
| 72 | make test |
| 73 | ``` |
| 74 | |
| 75 | When building Mbed Crypto as a subproject of Mbed TLS, the Mbed TLS |
| 76 | configuration file (config.h) is used, and not the Mbed Crypto configuration |
| 77 | file. |
| 78 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 79 | ## Example programs |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 80 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 81 | The `programs/` subdirectory contains sample programs that use the library. Please note that the goal of these sample programs is to demonstrate specific features of the library, and the code may need to be adapted to build a real-world application. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 82 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 83 | ## Upcoming features |
Manuel Pégourié-Gonnard | 05c9271 | 2017-12-28 09:14:47 +0100 | [diff] [blame] | 84 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 85 | Future releases of this library will include: |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 86 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 87 | * A driver programming interface, which makes it possible to use hardware accelerators instead of the default software implementation for chosen algorithms. |
| 88 | * Support for external keys to be stored and manipulated exclusively in a separate cryptoprocessor. |
| 89 | * A configuration mechanism to compile only the algorithms you need for your application. |
| 90 | * A wider set of cryptographic algorithms. |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 91 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 92 | ## Feedback welcome |
Manuel Pégourié-Gonnard | f851f14 | 2015-09-03 13:29:45 +0200 | [diff] [blame] | 93 | |
Jaeden Amero | c74fe6a | 2018-10-30 18:09:22 +0000 | [diff] [blame] | 94 | Arm welcomes feedback on the design of the API. If you think something could be improved, please open an issue on our Github repository. Alternatively, if you prefer to provide your feedback privately, please email us at [`mbed-crypto@arm.com`](mailto:mbed-crypto@arm.com). All feedback received by email is treated confidentially. |