blob: 48a2f7537ece559fda668a6d97e43e27b4c62ab4 [file] [log] [blame]
Gilles Peskine6c723a22020-04-17 16:57:52 +02001.. _design-goals:
2
3Design goals
4------------
5
6Suitable for constrained devices
7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8
9The interface is suitable for a vast range of devices: from special-purpose
10cryptographic processors that process data with a built-in key, to constrained
11devices running custom application code, such as microcontrollers, and
12multi-application devices, such as servers. Consequentially, the interface is
13scalable and modular.
14
15- *Scalable*: devices only need to implement the functionality that they will
16 use.
17- *Modular*: larger devices implement larger subsets of the same interface,
18 rather than different interfaces.
19
20In this interface, all operations on unbounded amounts of data
21allow *multi-part* processing, as long as the calculations on the data are
22performed in a streaming manner. This means that the application does not need
23to store the whole message in memory at one time. As a result, this
24specification is suitable for very constrained devices, including those where
25memory is very limited.
26
27Memory outside the keystore boundary is managed by the application. An
28implementation of the interface is not required to retain any state between
29function calls, apart from the content of the keystore and other data that must
30be kept inside the keystore security boundary.
31
32The interface does not expose the representation of keys and intermediate data,
33except when required for interchange. This allows each implementation to choose
34optimal data representations. Implementations with multiple components are also
35free to choose which memory area to use for internal data.
36
37A keystore interface
38~~~~~~~~~~~~~~~~~~~~
39
40The specification allows cryptographic operations to be performed on a key to
41which the application does not have direct access. Except where required for
42interchange, applications access all keys indirectly, by an identifier. The key
43material corresponding to that identifier can reside inside a security boundary
44that prevents it from being extracted, except as permitted by a policy that is
45defined when the key is created.
46
47.. _isolation:
48
49Optional isolation
50~~~~~~~~~~~~~~~~~~
51
52Implementations can isolate the cryptoprocessor from the calling application,
53and can further isolate multiple calling applications. The interface allows the
54implementation to be separated between a frontend and a backend. In an isolated
55implementation, the frontend is the part of the implementation that is located
56in the same isolation boundary as the application, which the application
57accesses by function calls. The backend is the part of the implementation that
58is located in a different environment, which is protected from the frontend.
59Various technologies can provide protection, for example:
60
61- Process isolation in an operating system.
62- Partition isolation, either with a virtual machine or a partition manager.
63- Physical separation between devices.
64
65Communication between the frontend and backend is beyond the scope of this
66specification.
67
68In an isolated implementation, the backend can serve more than one
69implementation instance. In this case, a single backend communicates with
70multiple instances of the frontend. The backend must enforce **caller
71isolation**: it must ensure that assets of one frontend are not visible to any
72other frontend. The mechanism for identifying callers is beyond the scope of this
73specification. An implementation that provides caller isolation must document
74the identification mechanism. An implementation that provides isolation must
75document any implementation-specific extension of the API that enables frontend
76instances to share data in any form.
77
78In summary, there are three types of implementation:
79
80- No isolation: there is no security boundary between the application and the
81 cryptoprocessor. For example, a statically or dynamically linked library is
82 an implementation with no isolation.
83- Cryptoprocessor isolation: there is a security boundary between the
84 application and the cryptoprocessor, but the cryptoprocessor does not
85 communicate with other applications. For example, a cryptoprocessor chip that
86 is a companion to an application processor is an implementation with
87 cryptoprocessor isolation.
88- Caller isolation: there are multiple application instances, with a security
89 boundary between the application instances among themselves, as well as
90 between the cryptoprocessor and the application instances. For example, a
91 cryptography service in a multiprocess environment is an implementation with
92 caller and cryptoprocessor isolation.
93
94Choice of algorithms
95~~~~~~~~~~~~~~~~~~~~
96
97The specification defines a low-level cryptographic interface, where the caller
98explicitly chooses which algorithm and which security parameters they use. This
99is necessary to implement protocols that are inescapable in various use cases.
100The design of the interface enables applications to implement widely-used
101protocols and data exchange formats, as well as custom ones.
102
103As a consequence, all cryptographic functionality operates according to the
104precise algorithm specified by the caller. However, this does not apply to
105device-internal functionality, which does not involve any form of
106interoperability, such as random number generation. The specification does not
107include generic higher-level interfaces, where the implementation chooses the
108best algorithm for a purpose. However, higher-level libraries can be built on
109top of the PSA Crypto API.
110
111Another consequence is that the specification permits the use of algorithms, key
112sizes and other parameters that, while known to be insecure, might be necessary to
113support legacy protocols or legacy data. Where major weaknesses are known, the
114algorithm descriptions give applicable warnings. However, the lack of a warning
115both does not and cannot indicate that an algorithm is secure in all circumstances.
116Application developers need to research the security of the protocols and
117algorithms that they plan to use to determine if these meet their requirements.
118
119The interface facilitates algorithm agility. As a consequence, cryptographic
120primitives are presented through generic functions with a parameter indicating
121the specific choice of algorithm. For example, there is a single function to
122calculate a message digest, which takes a parameter that identifies the specific
123hash algorithm.
124
125Ease of use
126~~~~~~~~~~~
127
128The interface is designed to be as user-friendly as possible, given the
129aforementioned constraints on suitability for various types of devices and on
130the freedom to choose algorithms.
131
132In particular, the code flows are designed to reduce the risk of dangerous
133misuse. The interface is designed in part to make it harder to misuse. Where
134possible, it is designed so that
135typical mistakes result in test failures, rather than subtle security issues.
136Implementations avoid leaking data when a function is called with invalid
137parameters, to the extent allowed by the C language and by implementation size
138constraints.
139
140Example use cases
141~~~~~~~~~~~~~~~~~
142
143This section lists some of the use cases that were considered during the design
144of this API. This list is not exhaustive, nor are all implementations required to
145support all use cases.
146
147Network Security (TLS)
148^^^^^^^^^^^^^^^^^^^^^^
149
150The API provides all of the cryptographic primitives needed to establish TLS
151connections.
152
153Secure Storage
154^^^^^^^^^^^^^^
155
156The API provides all primitives related to storage encryption, block or
157file-based, with master encryption keys stored inside a key store.
158
159Network Credentials
160^^^^^^^^^^^^^^^^^^^
161
162The API provides network credential management inside a key store, for example,
163for X.509-based authentication or pre-shared keys on enterprise networks.
164
165Device Pairing
166^^^^^^^^^^^^^^
167
168The API provides support for key agreement protocols that are often used for
169secure pairing of devices over wireless channels. For example, the pairing of an
170NFC token or a Bluetooth device might use key agreement protocols upon
171first use.
172
173Secure Boot
174^^^^^^^^^^^
175
176The API provides primitives for use during firmware integrity and authenticity
177validation, during a secure or trusted boot process.
178
179Attestation
180^^^^^^^^^^^
181
182The API provides primitives used in attestation activities. Attestation is the
183ability for a device to sign an array of bytes with a device private key and
184return the result to the caller. There are several use cases; ranging from attestation
185of the device state, to the ability to generate a key pair and prove that it has
186been generated inside a secure key store. The API provides access to the
187algorithms commonly used for attestation.
188
189Factory Provisioning
190^^^^^^^^^^^^^^^^^^^^
191
192Most IoT devices receive a unique identity during the factory provisioning
193process, or once they have been deployed to the field. This API provides the APIs necessary for
194populating a device with keys that represent that identity.