You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/crypto/api/keys/attributes.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,7 +159,7 @@ Managing key attributes
159
159
.. retval:: PSA_ERROR_DATA_CORRUPT
160
160
.. retval:: PSA_ERROR_DATA_INVALID
161
161
.. retval:: PSA_ERROR_BAD_STATE
162
-
The library requires initializing by a call to `psa_crypto_init()`.
162
+
The library requires initializing. See :secref:`library-init`.
163
163
164
164
This function first resets the attribute object as with `psa_reset_key_attributes()`. It then copies the attributes of the given key into the given attribute object.
Copy file name to clipboardExpand all lines: doc/crypto/api/keys/management.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ When creating a key, the attributes for the new key are specified in a `psa_key_
86
86
.. retval:: PSA_ERROR_DATA_INVALID
87
87
.. retval:: PSA_ERROR_CORRUPTION_DETECTED
88
88
.. retval:: PSA_ERROR_BAD_STATE
89
-
The library requires initializing by a call to `psa_crypto_init()`.
89
+
The library requires initializing, see :secref:`library-init`.
90
90
91
91
This function supports any output from `psa_export_key()`. Each key type in :secref:`key-types` describes the expected format of keys.
92
92
@@ -149,7 +149,7 @@ When creating a key, the attributes for the new key are specified in a `psa_key_
149
149
.. retval:: PSA_ERROR_DATA_CORRUPT
150
150
.. retval:: PSA_ERROR_DATA_INVALID
151
151
.. retval:: PSA_ERROR_BAD_STATE
152
-
The library requires initializing by a call to `psa_crypto_init()`.
152
+
The library requires initializing, see :secref:`library-init`.
153
153
154
154
The key is generated randomly. Its location, policy, type and size are taken from ``attributes``.
155
155
@@ -214,7 +214,7 @@ When creating a key, the attributes for the new key are specified in a `psa_key_
214
214
.. retval:: PSA_ERROR_DATA_INVALID
215
215
.. retval:: PSA_ERROR_CORRUPTION_DETECTED
216
216
.. retval:: PSA_ERROR_BAD_STATE
217
-
The library requires initializing by a call to `psa_crypto_init()`.
217
+
The library requires initializing, see :secref:`library-init`.
218
218
219
219
Copy key material from one location to another.
220
220
@@ -267,7 +267,7 @@ Key destruction
267
267
.. retval:: PSA_ERROR_CORRUPTION_DETECTED
268
268
An unexpected condition which is not a storage corruption or a communication failure occurred. The cryptoprocessor might have been compromised.
269
269
.. retval:: PSA_ERROR_BAD_STATE
270
-
The library requires initializing by a call to `psa_crypto_init()`.
270
+
The library requires initializing, see :secref:`library-init`.
271
271
272
272
This function destroys a key from both volatile memory and, if applicable, non-volatile storage. Implementations must make a best effort to ensure that that the key material cannot be recovered.
273
273
@@ -297,7 +297,7 @@ Key destruction
297
297
.. retval:: PSA_ERROR_DATA_INVALID
298
298
.. retval:: PSA_ERROR_CORRUPTION_DETECTED
299
299
.. retval:: PSA_ERROR_BAD_STATE
300
-
The library requires initializing by a call to `psa_crypto_init()`.
300
+
The library requires initializing, see :secref:`library-init`.
301
301
302
302
For keys that have been created with the `PSA_KEY_USAGE_CACHE` usage flag, an implementation is permitted to make additional copies of the key material that are not in storage and not for the purpose of ongoing operations.
303
303
@@ -362,7 +362,7 @@ Key export
362
362
.. retval:: PSA_ERROR_DATA_INVALID
363
363
.. retval:: PSA_ERROR_INSUFFICIENT_MEMORY
364
364
.. retval:: PSA_ERROR_BAD_STATE
365
-
The library requires initializing by a call to `psa_crypto_init()`.
365
+
The library requires initializing, see :secref:`library-init`.
366
366
367
367
The output of this function can be passed to `psa_import_key()` to create an equivalent object.
368
368
@@ -414,7 +414,7 @@ Key export
414
414
.. retval:: PSA_ERROR_DATA_INVALID
415
415
.. retval:: PSA_ERROR_INSUFFICIENT_MEMORY
416
416
.. retval:: PSA_ERROR_BAD_STATE
417
-
The library requires initializing by a call to `psa_crypto_init()`.
417
+
The library requires initializing, see :secref:`library-init`.
418
418
419
419
The output of this function can be passed to `psa_import_key()` to create an object that is equivalent to the public key.
It is recommended that applications initialize the |API| implementation, before calling any other function, except as otherwise indicated.
44
+
This is typically achieved by calling `psa_crypto_init()`.
45
+
46
+
Some implementations provide the ability to selectively initialize a subset of the functionality, using calls to `psa_crypto_init_subsystem()`.
47
+
For example, this permits use cases such as early-stage bootloaders, that need to decrypt or authenticate firmware, where it is unnecessary to wait for an RNG to collect enough entropy.
48
+
In these implementations, calling `psa_crypto_init()` is equivalent to calling `psa_crypto_init_subsystem()` for all available subsystems.
49
+
50
+
Applications are permitted to call these functions more than once.
51
+
Once a subsystem is successfully initialized, subsequent calls to initialize the same subsystem are guaranteed to succeed.
52
+
53
+
If the application calls any function that returns a :code:`psa_status_t` result code before initializing the related subsystems, the following will occur:
54
+
55
+
* If initialization of the library is essential for secure operation of the function, the implementation must return :code:`PSA_ERROR_BAD_STATE` or other appropriate error.
56
+
57
+
* If failure to initialize the library does not compromise the security of the function, the implementation must either provide the expected result for the function, or return :code:`PSA_ERROR_BAD_STATE` or other appropriate error.
58
+
59
+
.. note::
60
+
61
+
The following scenarios are examples where an implementation can require that the library has been initialized:
62
+
63
+
* A client-server implementation, in which `psa_crypto_init()`, or :code:`psa_crypto_init_subsystem(PSA_CRYPTO_SUBSYSTEM_COMMUNICATION)`, establishes the communication with the server.
64
+
No key management or cryptographic operation can be performed until this is done.
65
+
66
+
* An implementation in which `psa_crypto_init()`, or :code:`psa_crypto_init_subsystem(PSA_CRYPTO_SUBSYSTEM_RANDOM)`, initializes the random bit generator, and no operations that require the RNG can be performed until this is done.
67
+
For example, random data, key, IV, or nonce generation; randomized signature or encryption; and algorithms that are implemented with blinding.
68
+
69
+
.. warning::
70
+
71
+
The set of functions that depend on successful initialization of specific subsystems, is :scterm:`IMPLEMENTATION DEFINED`.
72
+
Applications that rely on calling functions before initializing the library might not be portable to other implementations.
73
+
43
74
.. function:: psa_crypto_init
44
75
45
76
.. summary::
@@ -52,24 +83,156 @@ Library initialization
52
83
.. retval:: PSA_ERROR_COMMUNICATION_FAILURE
53
84
.. retval:: PSA_ERROR_CORRUPTION_DETECTED
54
85
.. retval:: PSA_ERROR_INSUFFICIENT_ENTROPY
86
+
.. retval:: PSA_ERROR_INSUFFICIENT_STORAGE
87
+
.. retval:: PSA_ERROR_HARDWARE_FAILURE
88
+
.. retval:: PSA_ERROR_STORAGE_FAILURE
89
+
.. retval:: PSA_ERROR_DATA_INVALID
90
+
.. retval:: PSA_ERROR_DATA_CORRUPT
55
91
56
-
It is recommended that applications call this function before calling any other function in this module.
92
+
It is recommended that applications call this function before calling any other function in this module, except as otherwise indicated.
57
93
58
94
Applications are permitted to call this function more than once. Once a call succeeds, subsequent calls are guaranteed to succeed.
59
95
60
-
If the application calls any function that returns a :code:`psa_status_t` result code before calling `psa_crypto_init()`, the following will occur:
96
+
For finer control over initialization, see `psa_crypto_init_subsystem()`.
61
97
62
-
* If initialization of the library is essential for secure operation of the function, the implementation must return :code:`PSA_ERROR_BAD_STATE` or other appropriate error.
98
+
See also :secref:`library-init`.
63
99
64
-
* If failure to initialize the library does not compromise the security of the function, the implementation must either provide the expected result for the function, or return :code:`PSA_ERROR_BAD_STATE` or other appropriate error.
100
+
.. typedef:: uint32_t psa_crypto_subsystem_t
65
101
66
-
.. note::
102
+
.. summary::
103
+
Encoding of a subsystem of the |API| implementation.
104
+
105
+
This type is used to specify implementation subsystems in a call to `psa_crypto_init_subsystem()`.
106
+
Values of this type are ``PSA_CRYPTO_SUBSYSTEM_xxx`` constants, or a bitwise-or of two or more of them.
107
+
108
+
.. admonition:: Implementation note
109
+
110
+
An implementation can define additional subsystem identifier values for use with `psa_crypto_init_subsystem()`.
111
+
112
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_COMMUNICATION
113
+
:definition: /* implementation-defined value */
114
+
115
+
.. summary::
116
+
Crypto subsystem identifier for the communication with the server, if this is a client that communicates with a server where the key store is located.
117
+
118
+
In a client-server implementation, initializing this subsystem is necessary before any API function other than library initialization, deinitialization and functions accessing local data structures such as key attributes.
119
+
120
+
In a library implementation, initializing this subsystem has no effect, and always succeeds.
121
+
122
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_KEYS
123
+
:definition: /* implementation-defined value */
124
+
125
+
.. summary::
126
+
Crypto subsystem identifier for the key store in memory.
127
+
128
+
Initializing this subsystem allows creating, accessing and destroying volatile keys in the default location, that is, keys with the lifetime `PSA_KEY_LIFETIME_VOLATILE`.
129
+
130
+
Persistent keys also require `PSA_CRYPTO_SUBSYSTEM_STORAGE`.
131
+
Keys in other locations also require `PSA_CRYPTO_SUBSYSTEM_SECURE_ELEMENTS`.
67
132
68
-
The following scenarios are examples where an implementation can require that the library has been initialized by calling `psa_crypto_init()`:
69
133
70
-
* A client-server implementation, in which `psa_crypto_init()` establishes the communication with the server. No key management or cryptographic operation can be performed until this is done.
134
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_STORAGE
135
+
:definition: /* implementation-defined value */
136
+
137
+
.. summary::
138
+
Crypto subsystem identifier for access to keys in storage.
71
139
72
-
* An implementation in which `psa_crypto_init()` initializes the random bit generator, and no operations that require the RNG can be performed until this is done. For example, random data, key, IV, or nonce generation; randomized signature or encryption; and algorithms that are implemented with blinding.
140
+
Initializing this subsystem and the `PSA_CRYPTO_SUBSYSTEM_KEYS` subsystem allows creating, accessing, and destroying persistent keys.
141
+
142
+
Persistent keys in secure elements also require `PSA_CRYPTO_SUBSYSTEM_SECURE_ELEMENTS`.
143
+
144
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_ACCELERATORS
145
+
:definition: /* implementation-defined value */
146
+
147
+
.. summary::
148
+
Crypto subsystem identifier for accelerator drivers.
149
+
150
+
Initializing this subsystem results in initialization of all registered accelerator drivers.
151
+
152
+
Initializing this subsystem allows cryptographic operations that are implemented via an accelerator driver.
153
+
154
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_SECURE_ELEMENTS
155
+
:definition: /* implementation-defined value */
156
+
157
+
.. summary::
158
+
Crypto subsystem identifier for secure element drivers.
159
+
160
+
Initializing this subsystem results in initialization of all registered secure element drivers.
161
+
162
+
Initializing this subsystem as well as `PSA_CRYPTO_SUBSYSTEM_KEYS` allows creating, accessing, and destroying keys in a secure element. That is, keys whose location is not `PSA_KEY_LOCATION_LOCAL_STORAGE`.
163
+
164
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_RANDOM
165
+
:definition: /* implementation-defined value */
166
+
167
+
.. summary::
168
+
Crypto subsystem identifier for the random generator.
169
+
170
+
Initializing this subsystem initializes all registered entropy drivers, and accesses the registered entropy sources.
171
+
172
+
Initializing this subsystem is necessary for `psa_generate_random()`, `psa_generate_key()`, and some operations using private or secret keys.
173
+
174
+
It is guaranteed that the following operations do not to require this subsystem:
175
+
176
+
* Hash operations.
177
+
* Signature verification operations.
178
+
179
+
Is it :scterm:`implementation defined` whether other operations require the initialization of this subsystem.
180
+
181
+
.. macro:: PSA_CRYPTO_SUBSYSTEM_BUILTIN_KEYS
182
+
:definition: /* implementation-defined value */
183
+
184
+
.. summary::
185
+
Crypto subsystem identifier for access to built-in keys.
186
+
187
+
Initializing this subsystem as well as `PSA_CRYPTO_SUBSYSTEM_KEYS` allows access to built-in keys.
188
+
189
+
.. macro:: PSA_CRYPTO_ALL_SUBSYSTEMS
190
+
:definition: /* implementation-defined value */
191
+
192
+
.. summary::
193
+
Crypto subsystem identifier for all available subsystems.
194
+
195
+
Using this value in a call to `psa_crypto_init_subsystem()` is equivalent to calling `psa_crypto_init()`.
196
+
197
+
.. function:: psa_crypto_init_subsystem
198
+
199
+
.. summary::
200
+
Partial library initialization.
201
+
202
+
.. param:: psa_crypto_subsystem_t subsystem
203
+
The subsystem, or set of subsystems, to initialize.
204
+
This must be one of the ``PSA_CRYPTO_SUBSYSTEM_xxx`` values, one of the implementation-specific subsystem values, or a bitwise-or of them.
205
+
206
+
.. return:: psa_status_t
207
+
.. retval:: PSA_SUCCESS
208
+
Success.
209
+
.. retval:: PSA_ERROR_INVALID_ARGUMENT
210
+
``subsystem`` is not a bitwise-or of one or more of the crypto subsystem identifier values.
211
+
These values can be defined in this specification or by the implementation.
212
+
.. retval:: PSA_ERROR_INSUFFICIENT_MEMORY
213
+
.. retval:: PSA_ERROR_COMMUNICATION_FAILURE
214
+
.. retval:: PSA_ERROR_CORRUPTION_DETECTED
215
+
.. retval:: PSA_ERROR_INSUFFICIENT_ENTROPY
216
+
.. retval:: PSA_ERROR_INSUFFICIENT_STORAGE
217
+
.. retval:: PSA_ERROR_HARDWARE_FAILURE
218
+
.. retval:: PSA_ERROR_STORAGE_FAILURE
219
+
.. retval:: PSA_ERROR_DATA_INVALID
220
+
.. retval:: PSA_ERROR_DATA_CORRUPT
221
+
222
+
Applications may call this function on the same subsystem more than once.
223
+
Once a call succeeds, subsequent calls with the same subsystem are guaranteed to succeed.
224
+
225
+
Initializing a subsystem may initialize other subsystems if the implementations needs them internally.
226
+
For example, in a typical client-server implementation, `PSA_CRYPTO_SUBSYSTEM_COMMUNICATION` is required for all other subsystems, and therefore initializing any other subsystem also initializes `PSA_CRYPTO_SUBSYSTEM_COMMUNICATION`.
227
+
228
+
Calling `psa_crypto_init_subsystem()` with for a subsystem that is not used by the implementation must have no effect, and return :code:`PSA_SUCCESS`.
229
+
In effect, this is indicating that there is no further initialization required for this subsystem.
230
+
231
+
Calling `psa_crypto_init()` is equivalent to calling :code:`psa_crypto_init_subsystem(PSA_CRYPTO_ALL_SUBSYSTEMS)`.
232
+
233
+
See also :secref:`library-init`.
234
+
235
+
.. note::
73
236
74
-
.. warning::
75
-
The set of functions that depend on successful initialization of the library is :scterm:`IMPLEMENTATION DEFINED`. Applications that rely on calling functions before initializing the library might not be portable to other implementations.
237
+
Multiple subsystems can be initialized in the same call by passing a bitwise-or of ``PSA_CRYPTO_SUBSYSTEM_xxx`` values.
238
+
If the initialization of one subsystem fails, it is unspecified whether other requested subsystems are initialized or not.
0 commit comments