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/overview/functionality.rst
+73-63Lines changed: 73 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,15 +112,24 @@ Cryptographic operations
112
112
113
113
For each type of cryptographic operation, the API can include:
114
114
115
-
* One or more *single-part* functions, which perform a whole operation in a single function call. For example, compute, verify, encrypt or decrypt.
116
-
* A *multi-part operation* --- which is a series of functions that work with a stored operation state.
115
+
* One or more *single-part* functions, which perform a whole operation in a single function call. For example, compute, verify, encrypt or decrypt. See :secref:`single-part-functions`.
116
+
117
+
* A *multi-part operation* --- which is a set of functions that work with a stored operation state. This provides more control over operation configuration, piecewise processing of large input data, or handling for multi-step processes. See :secref:`multi-part-operations`.
118
+
119
+
* An *interruptible operation* --- which is also a set of functions that work with a stored operation state. However, these operations are for computationally expensive algorithms (for example, digital signatures), and enable the application to limit the computation performed in a single function call. See :secref:`interruptible-operations`.
120
+
121
+
.. _single-part-functions:
117
122
118
123
Single-part Functions
119
124
~~~~~~~~~~~~~~~~~~~~~
120
125
121
126
Single-part functions are APIs that implement the cryptographic operation in a single function call. This is the easiest API to use when all of the inputs and outputs fit into the application memory.
122
127
123
-
Some use cases involve messages that are too large to be assembled in memory, or require non-default configuration of the algorithm. These use cases require the use of a `multi-part operation <multi-part-operations>`.
128
+
Single-part functions do not meet the needs of all use cases:
129
+
130
+
* Some use cases involve messages that are too large to be assembled in memory, or require non-default configuration of the algorithm. These use cases require the use of a `multi-part operation <multi-part-operations>`.
131
+
132
+
* Some use cases require that the time spent in a single function call is bounded. For some algorithms, this result can be achieved using a multi-part operation. For algorithms that involve computationally expensive steps, the use case requires the use of an `interruptible operation <interruptible-operations>`.
124
133
125
134
.. _multi-part-operations:
126
135
@@ -209,66 +218,6 @@ It is safe to move a multi-part operation object to a different memory location,
209
218
210
219
Each type of multi-part operation can have multiple *active* states. Documentation for the specific operation describes the configuration and update functions, and any requirements about their usage and ordering.
211
220
212
-
Symmetric cryptography
213
-
~~~~~~~~~~~~~~~~~~~~~~
214
-
215
-
This specification defines interfaces for the following types of symmetric
216
-
cryptographic operation:
217
-
218
-
* Message digests, commonly known as hash functions. See :secref:`hashes`.
219
-
* Message authentication codes (MAC). See :secref:`macs`.
220
-
* Symmetric ciphers. See :secref:`ciphers`.
221
-
* Authenticated encryption with associated data (AEAD). See :secref:`aead`.
222
-
* Key derivation. See :secref:`kdf`.
223
-
224
-
Key derivation only provides multi-part operation, to support the flexibility required by these type of algorithms.
225
-
226
-
.. _symmetric-crypto-example:
227
-
228
-
Example of the symmetric cryptography API
229
-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230
-
231
-
Here is an example of a use case where a master key is used to generate both a message encryption key and an IV for the encryption, and the derived key and IV are then used to encrypt a message.
232
-
233
-
1. Derive the message encryption material from the master key.
234
-
235
-
a. Initialize a `psa_key_derivation_operation_t` object to zero or to `PSA_KEY_DERIVATION_OPERATION_INIT`.
236
-
#. Call `psa_key_derivation_setup()` with `PSA_ALG_HKDF` as the algorithm.
237
-
#. Call `psa_key_derivation_input_key()` with the step `PSA_KEY_DERIVATION_INPUT_SECRET` and the master key.
238
-
#. Call `psa_key_derivation_input_bytes()` with the step `PSA_KEY_DERIVATION_INPUT_INFO` and a public value that uniquely identifies the message.
239
-
#. Populate a `psa_key_attributes_t` object with the derived message encryption key’s attributes.
240
-
#. Call `psa_key_derivation_output_key()` to create the derived message key.
241
-
#. Call `psa_key_derivation_output_bytes()` to generate the derived IV.
242
-
#. Call `psa_key_derivation_abort()` to release the key derivation operation memory.
243
-
244
-
#. Encrypt the message with the derived material.
245
-
246
-
a. Initialize a `psa_cipher_operation_t` object to zero or to `PSA_CIPHER_OPERATION_INIT`.
247
-
#. Call `psa_cipher_encrypt_setup()` with the derived message encryption key.
248
-
#. Call `psa_cipher_set_iv()` using the derived IV retrieved above.
249
-
#. Call `psa_cipher_update()` one or more times to encrypt the message.
250
-
#. Call `psa_cipher_finish()` at the end of the message.
251
-
252
-
#. Call `psa_destroy_key()` to clear the generated key.
253
-
254
-
Asymmetric cryptography
255
-
~~~~~~~~~~~~~~~~~~~~~~~
256
-
257
-
This specification defines interfaces for the following types of asymmetric cryptographic operation:
258
-
259
-
* Asymmetric encryption (also known as public key encryption). See :secref:`pke`.
260
-
* Asymmetric signature. See :secref:`sign`.
261
-
* Two-way key agreement (also known as key establishment). See :secref:`key-agreement`.
262
-
* Password-authenticated key exchange (PAKE). See :secref:`pake`.
263
-
264
-
For asymmetric encryption, the API provides *single-part* functions.
265
-
266
-
For asymmetric signature, the API provides single-part functions and *interruptible operations* (see :secref:`interruptible-operations`).
267
-
268
-
For key agreement, the API provides single-part functions and an additional input method for a key derivation operation.
269
-
270
-
For PAKE, the API provides a *multi-part* operation.
271
-
272
221
.. _interruptible-operations:
273
222
274
223
Interruptible operations
@@ -356,6 +305,67 @@ Each type of interruptible operation can have multiple *setup*, *input*, and *co
356
305
357
306
See :secref:`interruptible_sign` for an example of using an interruptible operation.
358
307
308
+
Symmetric cryptography
309
+
~~~~~~~~~~~~~~~~~~~~~~
310
+
311
+
This specification defines interfaces for the following types of symmetric
312
+
cryptographic operation:
313
+
314
+
* Message digests, commonly known as hash functions. See :secref:`hashes`.
315
+
* Message authentication codes (MAC). See :secref:`macs`.
316
+
* Symmetric ciphers. See :secref:`ciphers`.
317
+
* Authenticated encryption with associated data (AEAD). See :secref:`aead`.
318
+
* Key derivation. See :secref:`kdf`.
319
+
320
+
Key derivation only provides multi-part operation, to support the flexibility required by these type of algorithms.
321
+
322
+
.. _symmetric-crypto-example:
323
+
324
+
Example of the symmetric cryptography API
325
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
326
+
327
+
Here is an example of a use case where a master key is used to generate both a message encryption key and an IV for the encryption, and the derived key and IV are then used to encrypt a message.
328
+
329
+
1. Derive the message encryption material from the master key.
330
+
331
+
a. Initialize a `psa_key_derivation_operation_t` object to zero or to `PSA_KEY_DERIVATION_OPERATION_INIT`.
332
+
#. Call `psa_key_derivation_setup()` with `PSA_ALG_HKDF` as the algorithm.
333
+
#. Call `psa_key_derivation_input_key()` with the step `PSA_KEY_DERIVATION_INPUT_SECRET` and the master key.
334
+
#. Call `psa_key_derivation_input_bytes()` with the step `PSA_KEY_DERIVATION_INPUT_INFO` and a public value that uniquely identifies the message.
335
+
#. Populate a `psa_key_attributes_t` object with the derived message encryption key’s attributes.
336
+
#. Call `psa_key_derivation_output_key()` to create the derived message key.
337
+
#. Call `psa_key_derivation_output_bytes()` to generate the derived IV.
338
+
#. Call `psa_key_derivation_abort()` to release the key derivation operation memory.
339
+
340
+
#. Encrypt the message with the derived material.
341
+
342
+
a. Initialize a `psa_cipher_operation_t` object to zero or to `PSA_CIPHER_OPERATION_INIT`.
343
+
#. Call `psa_cipher_encrypt_setup()` with the derived message encryption key.
344
+
#. Call `psa_cipher_set_iv()` using the derived IV retrieved above.
345
+
#. Call `psa_cipher_update()` one or more times to encrypt the message.
346
+
#. Call `psa_cipher_finish()` at the end of the message.
347
+
348
+
#. Call `psa_destroy_key()` to clear the generated key.
349
+
350
+
Asymmetric cryptography
351
+
~~~~~~~~~~~~~~~~~~~~~~~
352
+
353
+
This specification defines interfaces for the following types of asymmetric cryptographic operation:
354
+
355
+
* Asymmetric encryption (also known as public key encryption). See :secref:`pke`.
356
+
* Asymmetric signature. See :secref:`sign`.
357
+
* Two-way key agreement (also known as key establishment). See :secref:`key-agreement`.
358
+
* Password-authenticated key exchange (PAKE). See :secref:`pake`.
359
+
360
+
For asymmetric encryption, the API provides *single-part* functions.
361
+
362
+
For asymmetric signature, the API provides single-part functions and *interruptible operations* (see :secref:`interruptible-operations`).
363
+
364
+
For key agreement, the API provides single-part functions and an additional input method for a key derivation operation.
365
+
366
+
For PAKE, the API provides a *multi-part* operation.
0 commit comments