Skip to content

Commit ca46ff2

Browse files
committed
Adopt the key attribute clarifications for key creation functions from ARM-software#205
1 parent 960595e commit ca46ff2

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

doc/crypto/api/keys/management.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -812,15 +812,21 @@ An interruptible key generation operation is used as follows:
812812
It must have been initialized as per the documentation for `psa_generate_key_iop_t`, and be inactive.
813813
.. param:: const psa_key_attributes_t * attributes
814814
The attributes for the new key.
815-
This function uses the attributes as follows:
816-
817-
* The key type is required.
818-
It cannot be an asymmetric public key.
819-
* The key size is required.
820-
It must be a valid size for the key type.
821-
* The key permitted-algorithm policy is required for keys that will be used for a cryptographic operation, see :secref:`permitted-algorithms`.
822-
* The key usage flags define what operations are permitted with the key, see :secref:`key-usage-flags`.
823-
* The key lifetime and identifier are required for a persistent key.
815+
816+
The following attributes are required for all keys:
817+
818+
* The key type. It must not be an asymmetric public key.
819+
* The key size. It must be a valid size for the key type.
820+
821+
The following attributes must be set for keys used in cryptographic operations:
822+
823+
* The key permitted-algorithm policy, see :secref:`permitted-algorithms`.
824+
* The key usage flags, see :secref:`key-usage-flags`.
825+
826+
The following attributes must be set for keys that do not use the default volatile lifetime:
827+
828+
* The key lifetime, see :secref:`key-lifetimes`.
829+
* The key identifier is required for a key with a persistent lifetime, see :secref:`key-identifiers`.
824830

825831
.. note::
826832
This is an input parameter: it is not updated with the final key attributes.

doc/crypto/api/ops/key-agreement.rst

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,24 +464,33 @@ An interruptible key agreement operation is used as follows:
464464
.. param:: psa_algorithm_t alg
465465
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.
466466
.. param:: const psa_key_attributes_t * attributes
467-
The attributes for the new key.
468-
This function uses the attributes as follows:
467+
The attributes for the key to be output on completion.
468+
469+
The following attributes are required for all keys:
469470

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`.
471472

472473
Implementations must support the `PSA_KEY_TYPE_DERIVE` and `PSA_KEY_TYPE_RAW_DATA` key types.
473474

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:
476476

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`.
478479

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``.
482490

483491
.. 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.
485494

486495
.. return:: psa_status_t
487496
.. retval:: PSA_SUCCESS
@@ -534,6 +543,8 @@ An interruptible key agreement operation is used as follows:
534543
This function sets up an interruptible operation to perform a key agreement.
535544
A key agreement algorithm takes two inputs: a private key ``private_key``, and a public key ``peer_key``.
536545

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+
537548
After a successful call to `psa_key_agreement_iop_setup()`, the operation is active.
538549
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`.
539550
Once active, the application must eventually terminate the operation.
@@ -583,6 +594,7 @@ An interruptible key agreement operation is used as follows:
583594
This is an interruptible function, and must be called repeatedly, until it returns a status code that is not :code:`PSA_OPERATION_INCOMPLETE`.
584595

585596
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.
586598
This key can be input to a key derivation operation using `psa_key_derivation_input_key()`.
587599

588600
.. warning::

0 commit comments

Comments
 (0)