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/ops/key-agreement.rst
+22-10Lines changed: 22 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -464,24 +464,33 @@ An interruptible key agreement operation is used as follows:
464
464
.. param:: psa_algorithm_t alg
465
465
The standalone key agreement algorithm to compute: a value of type `psa_algorithm_t` such that :code:`PSA_ALG_IS_STANDALONE_KEY_AGREEMENT(alg)` is true.
The attributes for the key to be output on completion.
468
+
469
+
The following attributes are required for all keys:
469
470
470
-
* The key type must be one of `PSA_KEY_TYPE_DERIVE`, `PSA_KEY_TYPE_RAW_DATA`, `PSA_KEY_TYPE_HMAC`, or `PSA_KEY_TYPE_PASSWORD`.
471
+
* The key type, which must be one of `PSA_KEY_TYPE_DERIVE`, `PSA_KEY_TYPE_RAW_DATA`, `PSA_KEY_TYPE_HMAC`, or `PSA_KEY_TYPE_PASSWORD`.
471
472
472
473
Implementations must support the `PSA_KEY_TYPE_DERIVE` and `PSA_KEY_TYPE_RAW_DATA` key types.
473
474
474
-
* The size of the returned key is always the bit-size of the shared secret, rounded up to a whole number of bytes.
475
-
The key size in ``attributes`` can be zero; if it is nonzero, it must be equal to the output size of the key agreement, in bits.
475
+
The following attributes must be set for keys used in cryptographic operations:
476
476
477
-
The output size, in bits, of the key agreement is :code:`8 * PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(type, bits)`, where ``type`` and ``bits`` are the type and bit-size of ``private_key``.
477
+
* The key permitted-algorithm policy, see :secref:`permitted-algorithms`.
478
+
* The key usage flags, see :secref:`key-usage-flags`.
478
479
479
-
* The key permitted-algorithm policy is required for keys that will be used for a cryptographic operation, see :secref:`permitted-algorithms`.
480
-
* The key usage flags define what operations are permitted with the key, see :secref:`key-usage-flags`.
481
-
* The key lifetime and identifier are required for a persistent key.
480
+
The following attributes must be set for keys that do not use the default volatile lifetime:
481
+
482
+
* The key lifetime, see :secref:`key-lifetimes`.
483
+
* The key identifier is required for a key with a persistent lifetime, see :secref:`key-identifiers`.
484
+
485
+
The following attributes are optional:
486
+
487
+
* If the key size is nonzero, it must be equal to the output size of the key agreement, in bits.
488
+
489
+
The output size, in bits, of the key agreement is :code:`8 * PSA_RAW_KEY_AGREEMENT_OUTPUT_SIZE(type, bits)`, where ``type`` and ``bits`` are the type and bit-size of ``private_key``.
482
490
483
491
.. note::
484
-
This is an input parameter: it is not updated with the final key attributes. The final attributes of the new key can be queried by calling `psa_get_key_attributes()` with the key's identifier.
492
+
This is an input parameter: it is not updated with the final key attributes.
493
+
The final attributes of the new key can be queried by calling `psa_get_key_attributes()` with the key's identifier.
485
494
486
495
.. return:: psa_status_t
487
496
.. retval:: PSA_SUCCESS
@@ -534,6 +543,8 @@ An interruptible key agreement operation is used as follows:
534
543
This function sets up an interruptible operation to perform a key agreement.
535
544
A key agreement algorithm takes two inputs: a private key ``private_key``, and a public key ``peer_key``.
536
545
546
+
When the interruptible operation completes, the shared secret is output in a key. The key's location, policy, and type are taken from ``attributes``. The size of the key is always the bit-size of the shared secret, rounded up to a whole number of bytes.
547
+
537
548
After a successful call to `psa_key_agreement_iop_setup()`, the operation is active.
538
549
The operation can be completed by calling `psa_key_agreement_iop_complete()` repeatedly, until it returns a status code that is not :code:`PSA_OPERATION_INCOMPLETE`.
539
550
Once active, the application must eventually terminate the operation.
@@ -583,6 +594,7 @@ An interruptible key agreement operation is used as follows:
583
594
This is an interruptible function, and must be called repeatedly, until it returns a status code that is not :code:`PSA_OPERATION_INCOMPLETE`.
584
595
585
596
When this function returns successfully, the shared secret is returned as a derivation key in ``key``, and the operation becomes inactive.
597
+
The attributes of the new key are specified in the call to `psa_key_agreement_iop_setup()` used to set up this operation.
586
598
This key can be input to a key derivation operation using `psa_key_derivation_input_key()`.
0 commit comments