blob: 9699ca3d4bff9f9384a6ee3d2d2485f18de9e985 [file] [log] [blame] [view]
Gilles Peskine674038a2018-07-18 18:25:30 +02001# Mbed Crypto library
2
Jen Andruska517e7372018-08-07 12:31:32 +01003The 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.
Gilles Peskine674038a2018-07-18 18:25:30 +02004
5Mbed Crypto is distributed under the Apache License, version 2.0. See the [LICENSE](LICENSE) file for the full text of the license.
6
7## PSA cryptography API
8
9Arm'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.
10
Jen Andruska517e7372018-08-07 12:31:32 +010011The 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.
Gilles Peskine674038a2018-07-18 18:25:30 +020012
Jen Andruska517e7372018-08-07 12:31:32 +010013The design goals of the PSA cryptography API include:
Gilles Peskine674038a2018-07-18 18:25:30 +020014
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.
Jen Andruska517e7372018-08-07 12:31:32 +010016* 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.
Gilles Peskine674038a2018-07-18 18:25:30 +020018* The interface to algorithms is generic, favoring algorithm agility.
Jen Andruska517e7372018-08-07 12:31:32 +010019* The interface is designed to be easy to use and hard to accidentally misuse.
Gilles Peskine674038a2018-07-18 18:25:30 +020020
21## Mbed Crypto implementation
22
Jen Andruska517e7372018-08-07 12:31:32 +010023Mbed Crypto is a reference implementation of the PSA cryptography API. It is written in portable C.
Gilles Peskine674038a2018-07-18 18:25:30 +020024
25## Documentation
26
Jen Andruska517e7372018-08-07 12:31:32 +010027Since the Mbed Crypto library is a reference implementation of the PSA cryptography API, the library's API documentation is the PSA cryptography API specification. The PSA cryptography API specification consists of the following documents:
Gilles Peskine674038a2018-07-18 18:25:30 +020028
29* The [PSA Cryptography API overview](docs/PSA_Crypto_API_Overview.pdf).
30* The [PSA Cryptography API detailed function reference](docs/PSA_Crypto_API_Reference.pdf), which you can also browse in [HTML format](docs/html/modules.html).
31
32## Compiling
33
34You need the following tools to build the library with the provided makefiles:
35
36* GNU Make.
37* A C toolchain (compiler, linker, archiver).
38* Python 2 or Python 3 (either will work) to generate the test code.
39* Perl to run the tests.
40
Jen Andruska517e7372018-08-07 12:31:32 +010041If 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.
Gilles Peskine674038a2018-07-18 18:25:30 +020042
Jen Andruska517e7372018-08-07 12:31:32 +010043To 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:
Gilles Peskine674038a2018-07-18 18:25:30 +020044```
45make CC=arm-linux-gnueabi-gcc AR=arm-linux-gnueabi-ar
46```
Jen Andruska517e7372018-08-07 12:31:32 +010047The 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`.
Gilles Peskine674038a2018-07-18 18:25:30 +020048
Jen Andruska517e7372018-08-07 12:31:32 +010049To 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.
Gilles Peskine674038a2018-07-18 18:25:30 +020050
51## Example programs
52
Jen Andruska517e7372018-08-07 12:31:32 +010053The `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.
Gilles Peskine674038a2018-07-18 18:25:30 +020054
55## Upcoming features
56
57Future releases of this library will include:
58
Jen Andruska517e7372018-08-07 12:31:32 +010059* A driver programming interface, which makes it possible to use hardware accelerators instead of the default software implementation for chosen algorithms.
60* Support for external keys to be stored and manipulated exclusively in a separate cryptoprocessor.
Gilles Peskine674038a2018-07-18 18:25:30 +020061* A configuration mechanism to compile only the algorithms you need for your application.
62* A wider set of cryptographic algorithms.
63
64## Feedback welcome
65
Jen Andruska517e7372018-08-07 12:31:32 +010066Arm 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.