Skip to content

Commit 66fc5b6

Browse files
authored
Merge pull request #76 from athoelke/athoelke-crypto-enum-types
Reserve value 0 for most enum-like types
2 parents 783fdc3 + e5b96c0 commit 66fc5b6

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

doc/crypto/api/keys/types.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,9 @@ Elliptic Curve keys
457457

458458
The range of Elliptic curve family identifier values is divided as follows:
459459

460-
:code:`0x00 – 0x7f`
460+
:code:`0x00`
461+
Reserved. Not allocated to an ECC family.
462+
:code:`0x01 – 0x7f`
461463
ECC family identifiers defined by this standard.
462464
Unallocated values in this range are reserved for future use.
463465
:code:`0x80 – 0xff`
@@ -773,7 +775,9 @@ Diffie Hellman keys
773775

774776
The range of Diffie-Hellman group family identifier values is divided as follows:
775777

776-
:code:`0x00 – 0x7f`
778+
:code:`0x00`
779+
Reserved. Not allocated to a DH group family.
780+
:code:`0x01 – 0x7f`
777781
DH group family identifiers defined by this standard.
778782
Unallocated values in this range are reserved for future use.
779783
:code:`0x80 – 0xff`

doc/crypto/api/ops/kdf.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ Input step types
311311
.. summary::
312312
Encoding of the step of a key derivation.
313313

314+
.. admonition:: Implementation note
315+
316+
It is recommended that the value `0` is not allocated as a valid key derivation step.
317+
314318
.. macro:: PSA_KEY_DERIVATION_INPUT_SECRET
315319
:definition: /* implementation-defined value */
316320

doc/crypto/appendix/history.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Clarifications and fixes
2525
~~~~~~~~~~~~~~~~~~~~~~~~
2626

2727
* Clarified the behavior of a key derivation operation when there is insufficient capacity for a call to `psa_key_derivation_output_bytes()`, `psa_key_derivation_output_key()`, `psa_key_derivation_verify_bytes()`, or `psa_key_derivation_verify_key()`.
28+
* Reserved the value `0` for most enum-like integral types.
2829

2930
Other changes
3031
~~~~~~~~~~~~~

doc/crypto/overview/conventions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ Data types
5454

5555
Integral types are defined for specific API elements to provide clarity in the interface definition, and to improve code readability. For example, `psa_algorithm_t` and :code:`psa_status_t`.
5656

57+
For enum-like integral types, the value `0` is usually reserved by the API to indicate an unspecified or invalid value.
58+
5759
Structure types are declared using ``typedef`` instead of a ``struct`` tag, also to improve code readability.
5860

5961
Fully-defined types must be declared exactly as defined in this specification. Types that are not fully defined in this specification must be defined by an implementation. See :secref:`implementation-defined-type`.

0 commit comments

Comments
 (0)