blob: 785584a62221f089fb917fe521a7cdc80fe7bd90 [file] [log] [blame] [view]
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +00001# Mbed Crypto library
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +02002
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +00003The 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é-Gonnardf851f142015-09-03 13:29:45 +02004
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +00005Mbed 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é-Gonnardf851f142015-09-03 13:29:45 +02006
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +00007## PSA cryptography API
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +02008
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +00009Arm's Platform Security Architecture (PSA) 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é-Gonnardf851f142015-09-03 13:29:45 +020010
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000011The PSA cryptography API 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é-Gonnardf851f142015-09-03 13:29:45 +020012
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000013The design goals of the PSA cryptography API include:
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020014
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000015* 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é-Gonnardf851f142015-09-03 13:29:45 +020020
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000021## Mbed Crypto implementation
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020022
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000023Mbed Crypto is a reference implementation of the PSA cryptography API. It is written in portable C.
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020024
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000025## Documentation
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020026
Gilles Peskine7b395082019-01-31 11:56:02 +010027The Mbed Crypto library is a reference implementation of the PSA cryptography API. Please refer to the PSA Cryptography API documents for an overview of the library's interfaces and a detailed description of the types, macros and functions that it provides.
Gilles Peskineec82da42017-10-02 10:52:50 +020028
Gilles Peskine7b395082019-01-31 11:56:02 +010029There 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.
30
31### PSA Cryptography API
32
33The PSA cryptography API specification consists of the following documents:
34
35* The [PSA Cryptography API overview](https://github.com/ARMmbed/mbed-crypto/blob/psa-crypto-api/docs/PSA_Cryptography_API_Specification.pdf).
36* The [PSA Cryptography API detailed function reference](https://github.com/ARMmbed/mbed-crypto/blob/psa-crypto-api/docs/PSA_Cryptography_API_Reference.pdf), which you can also browse in [HTML format](https://htmlpreview.github.io/?https://github.com/ARMmbed/mbed-crypto/blob/psa-crypto-api/docs/html/modules.html).
37
38### Browsable library documentation
39
40To generate a local copy of the library documentation in HTML format:
41
421. 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.
431. Run `make apidoc`.
441. Browse `apidoc/index.html` or `apidoc/modules.html`.
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020045
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000046## Compiling
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020047
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000048You need the following tools to build the library with the provided makefiles:
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020049
Jaeden Amero852dac22018-11-09 15:47:58 +000050* GNU Make or a build tool that CMake supports.
Jaeden Ameroa49ba5e2018-11-09 15:46:12 +000051* A C99 toolchain (compiler, linker, archiver).
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000052* Python 2 or Python 3 (either will work) to generate the test code.
53* Perl to run the tests.
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020054
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000055If 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é-Gonnardf851f142015-09-03 13:29:45 +020056
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000057To 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:
58```
59make CC=arm-linux-gnueabi-gcc AR=arm-linux-gnueabi-ar
60```
61The 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é-Gonnardf851f142015-09-03 13:29:45 +020062
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000063To 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é-Gonnardf851f142015-09-03 13:29:45 +020064
Jaeden Amero11293cc2018-11-02 12:22:34 +000065### Compiling as a subproject
66
67Mbed 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.
68
69From the Mbed TLS project repository, CMake can be invoked as follows to build Mbed TLS using Mbed Crypto's `libmbedcrypto`.
70```
71mkdir cmake
72cd cmake
73cmake .. -DUSE_CRYPTO_SUBMODULE=1
74make -j
75make test
76```
77
78When building Mbed Crypto as a subproject of Mbed TLS, the Mbed TLS
79configuration file (config.h) is used, and not the Mbed Crypto configuration
80file.
81
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000082## Example programs
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020083
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000084The `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é-Gonnardf851f142015-09-03 13:29:45 +020085
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000086## Upcoming features
Manuel Pégourié-Gonnard05c92712017-12-28 09:14:47 +010087
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000088Future releases of this library will include:
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020089
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000090* A driver programming interface, which makes it possible to use hardware accelerators instead of the default software implementation for chosen algorithms.
91* Support for external keys to be stored and manipulated exclusively in a separate cryptoprocessor.
92* A configuration mechanism to compile only the algorithms you need for your application.
93* A wider set of cryptographic algorithms.
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020094
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000095## Feedback welcome
Manuel Pégourié-Gonnardf851f142015-09-03 13:29:45 +020096
Jaeden Ameroc74fe6a2018-10-30 18:09:22 +000097Arm 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.