Skip to content

Commit 836b05a

Browse files
MarcusJGStreetsathoelke
authored andcommitted
Add files via upload
Responses to Andrew's comments that were uncommitted. Signed-off-by: Marcus Streets <[email protected]>
1 parent a3ab679 commit 836b05a

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

doc/crypto/api/keys/policy.rst

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ The usage flags are encoded in a bitmask, which has the type `psa_key_usage_t`.
9797
- `PSA_KEY_USAGE_DERIVE`
9898
- `PSA_KEY_USAGE_VERIFY_DERIVATION`
9999

100-
* The flag `PSA_KEY_USAGE_DERIVE_PUBLIC` it is not checked when calling any of the APIs to carry out a cryptographic operation. However, it is used in the function `psa_check_key_usage` to query if a key is of the correct type for the public role in the specified algorithm, which is may be provided in a buffer and not as a key object. For example PSA_KEY_USAGE_DERIVE_PUBLIC with:
100+
* The flag `PSA_KEY_USAGE_DERIVE_PUBLIC` it is not checked when calling any of the APIs to carry out a cryptographic operation. However, it is used in the function `psa_check_key_usage()` to query if a key can be used for the public role in the specified algorithm. Note, in some usages the key in the public role is provided in a buffer and not as a key object. For example `PSA_KEY_USAGE_DERIVE_PUBLIC` with:
101101

102-
- ``PSA_ALG_ECDH`` checks that the key can be used as the public share in the ECDH key agreement. There are no checks on permssions as this is provided in a buffer.
103-
- ``PSA_ALG_SPAKE2P_HMAC`` will check that the key can be used in the Verifier role in the SPAKE2+ algorithm. The key must have the `PSA_KEY_USAGE_DERIVE` permission.
104-
- ``PSA_ALG_HKDF`` is invalid, as there is no such role in single-key derivation algorithms.
102+
- `PSA_ALG_ECDH` checks that the key can be used as the public share in the ECDH key agreement. There are no checks on permissions as this is provided in a buffer.
103+
- `PSA_ALG_SPAKE2P_HMAC` will check that the key can be used in the Verifier role in the SPAKE2+ algorithm. The key must have the `PSA_KEY_USAGE_DERIVE` permission.
104+
- `PSA_ALG_HKDF` is invalid, as there is no such role in single-key derivation algorithms.
105105

106106
.. typedef:: uint32_t psa_key_usage_t
107107

@@ -277,13 +277,13 @@ The usage flags are encoded in a bitmask, which has the type `psa_key_usage_t`.
277277
:definition: ((psa_key_usage_t)0x00010000)
278278

279279
.. summary::
280-
Used in the `psa_check_key_usage` function to determine if the key can be used in the second key role in PAKE operations.
280+
Used in the `psa_check_key_usage()` function to determine if the key can be used in the second key role in PAKE operations.
281281

282282
.. versionadded:: 1.4
283283

284284
This flag is only used with the `psa_check_key_usage` function.
285285

286-
As the key in this role is provided in a buffer, this flag is never checked.
286+
This flag is never checked when performing cryptographic operations.
287287

288288
.. function:: psa_set_key_usage_flags
289289

@@ -324,43 +324,44 @@ The usage flags are encoded in a bitmask, which has the type `psa_key_usage_t`.
324324
.. function:: psa_check_key_usage
325325

326326
.. summary::
327-
Queries the capabilities of a key.
328-
329-
Returns success only if this key object exists and is the correct type for the requested operation and this implementation supports the algorithm and the key has the required permission.
330-
331-
That is, if the application were to call the identified operation with this key and with all other parameters correct, the operation should succeed.
332-
333-
This function only checks permissions, it does not attempt to perform the operation, so does not use any resources in the cryptographic engine.
334-
327+
Query the capability of a key.
335328

336329
.. versionadded:: 1.4
337330

338331
.. param:: psa_key_id_t key
339-
a PSA key identifier.
332+
Identifier of the key to check.
340333

341334
.. param:: psa_algorithm_t alg
342-
a specific algorithm.
335+
An algorithm identifier: a value of type `psa_algorithm_t`.
343336

344337
.. param:: psa_key_usage_t usage
345-
a single PSA_KEY_USAGE_xxx flag.
338+
A single PSA_KEY_USAGE_xxx flag.
346339

347340
.. return:: psa_status_t
348341

349342
.. retval:: PSA_SUCCESS
350-
``key`` can be used for the requested operation on this implementation. That is the ``alg`` is supported, ``key`` is of the correct type and has the requied permissions for ``useage``.
343+
``key`` can be used for the requested operation on this implementation.
351344

352345
.. retval:: PSA_ERROR_INVALID_ARGUMENT
353-
Either ``algorithm`` is a wildcard,
354-
or ``usage`` is an operation that is not algorithm dependent, like COPY or EXPORT.
355-
or ``key`` is not of the correct type for the operation.
356-
357-
.. retval:: PSA_ERROR_NOT_SUPPORTED
358-
``alg`` and ``useage`` together refer to an operation on an algorithm that is not supported by this implementation.
346+
* ``alg`` is not a specific cryptographic algorithm. It cannot be a wildcard algorithm.
347+
* ``usage`` is not a valid role for algorithm ``alg``.
348+
* ``key`` is not compatible with ``alg`` and ``usage``.
359349

360350
.. retval: PSA_ERROR_INVALID_HANDLE:
361-
``key`` does not exist
351+
``key`` is not a valid key identifier.
362352
363353
.. retval: PSA_ERROR_NOT_PERMITTED
364-
``key`` does not have the correct permission for the ``useage``
354+
``key`` does not permit the requested usage.
355+
356+
.. retval:: PSA_ERROR_NOT_SUPPORTED
357+
The implementation does not support using ``key`` with the cryptographic operation associated with ``alg`` and ``usage``.
358+
359+
Returns success only if this key object exists, is the correct type for the the operation associated with the algorithm and usage, with the required permission, and this implementation supports this key type for this operation.
360+
361+
This function does not attempt to perform the operation, so does not use any resources in the cryptographic engine.
362+
363+
The ``alg`` must be a fully specified algorithm, and not a wildcard.
364+
365+
The ``useage`` must be a valid role within a cryptographic algorithm. It must not be a non-cryptographiic operation such as `PSA_KEY_USAGE_COPY` or `PSA_KEY_USAGE_EXPORT`.
365366

366-
When checking a public key with a usage flag for an operation where the public key is provided as a buffer, for example, the public key in a derive operation, or the counterparty key in a key establishment, then the function indicates that the operation supports this type of key in this role. It ignores permissions, as all public keys can be exported.
367+
When checking a public key with a usage flag for an operation where the public key is provided as a buffer, the function returns ``PSA_SUCCESS`` if the operation supports this type of key in this role. In these cases, the function does not check THE permissions, as all public keys can be exported. This applies to, for example, using the key as the public key in a key agreement.

0 commit comments

Comments
 (0)