Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a2003d9
Key encapsulation functions
MarcusJGStreets Mar 7, 2024
f3ef0bc
Added Key encapsulation usage
athoelke Apr 16, 2024
f5fddee
Fixing two typos
MarcusJGStreets Jul 22, 2024
660d215
Changing encapsulation to use ephemeral key
MarcusJGStreets Jul 22, 2024
be8e319
Minor changes to Encap policy
MarcusJGStreets Jul 22, 2024
b9229dd
Reverting inadvertent changes due to having a stale copy of the file …
MarcusJGStreets Jul 24, 2024
41551ad
And again with the correct year
MarcusJGStreets Jul 24, 2024
aefbe8f
third times the charm
MarcusJGStreets Jul 24, 2024
72a5c24
Split encapsulate and decapsulate permissions
MarcusJGStreets Jul 29, 2024
a37f4cd
Change ephemeral keys to read / write from buffers
MarcusJGStreets Jul 29, 2024
64b246e
Adding ML key types
MarcusJGStreets Sep 2, 2024
ceac028
Adding ML signature and encapsulations algorithms
MarcusJGStreets Sep 2, 2024
f511731
Forgot the citations
MarcusJGStreets Sep 2, 2024
879c587
Correcting the tables
MarcusJGStreets Sep 2, 2024
5ceff79
Attempting to resolve merge conflicts
MarcusJGStreets Sep 2, 2024
c043771
Conflicts
MarcusJGStreets Sep 2, 2024
d0d0286
Conflicts 2
MarcusJGStreets Sep 2, 2024
07ee657
Conflicts
MarcusJGStreets Sep 2, 2024
66b07f7
conflicts
MarcusJGStreets Sep 2, 2024
e6c24fe
Add files via upload
MarcusJGStreets Sep 2, 2024
6ac9020
Conflict resolution
MarcusJGStreets Sep 2, 2024
10f7196
Add files via upload
MarcusJGStreets Sep 2, 2024
55ed4da
conflicts
MarcusJGStreets Sep 2, 2024
eca28a0
Conflict
MarcusJGStreets Sep 2, 2024
4293e53
Add files via upload
MarcusJGStreets Sep 2, 2024
a8445f0
Conflcts - white space
MarcusJGStreets Sep 2, 2024
a7ee3a8
lost some important white space
MarcusJGStreets Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion doc/crypto/api/keys/policy.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. SPDX-FileCopyrightText: Copyright 2018-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
.. SPDX-FileCopyrightText: Copyright 2018-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
.. SPDX-License-Identifier: CC-BY-SA-4.0 AND LicenseRef-Patent-license

.. header:: psa/crypto
Expand Down Expand Up @@ -250,6 +250,31 @@ The usage flags are encoded in a bitmask, which has the type `psa_key_usage_t`.

If this flag is present on all keys used in calls to `psa_key_derivation_input_key()` for a key derivation operation, then it permits calling `psa_key_derivation_verify_bytes()` or `psa_key_derivation_verify_key()` at the end of the operation.

.. macro:: PSA_KEY_USAGE_ENCAPSULATE
:definition: ((psa_key_usage_t)0x00010000)

.. summary::
Permission to encapsulate new keys.

This flag is required to encapsulate new keys to send to a counter party.

This flag must be present on public keys used with the following APIs:

* `psa_encapsulate()`

.. macro:: PSA_KEY_USAGE_DECAPSULATE
:definition: ((psa_key_usage_t)0x00020000)

.. summary::
Permission to decapsulate an encapsulated key.

This flag is required to decapsulate a key buffer obtained from a counter party.

This flag must be present on private keys used with the following APIs:

* `psa_decapsulate()`


.. function:: psa_set_key_usage_flags

.. summary::
Expand Down
143 changes: 140 additions & 3 deletions doc/crypto/api/keys/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Symmetric keys
It is :scterm:`implementation defined` whether an HMAC key that is longer than the hash block size is supported.

If the application does not control the length of the data used to construct the HMAC key, it is recommended that the application hashes the key data, when it exceeds the hash block length, before constructing the HMAC key.

.. note::

:code:`PSA_HASH_LENGTH(alg)` provides the output size of hash algorithm ``alg``, in bytes.
Expand Down Expand Up @@ -408,6 +408,7 @@ Symmetric keys
| `PSA_ALG_STREAM_CIPHER`
| `PSA_ALG_CHACHA20_POLY1305`


.. macro:: PSA_KEY_TYPE_XCHACHA20
:definition: ((psa_key_type_t)0x2007)

Expand All @@ -425,7 +426,6 @@ Symmetric keys
| `PSA_ALG_STREAM_CIPHER`
| `PSA_ALG_XCHACHA20_POLY1305`


.. _asymmetric-keys:

RSA keys
Expand Down Expand Up @@ -502,7 +502,7 @@ Elliptic Curve keys
.. summary::
Elliptic curve key pair: both the private and public key.

The size of an elliptic curve key is the bit size associated with the curve, that is, the bit size of :math:`q`` for a curve over a field :math:`\mathbb{F}_q`. See the documentation of each Elliptic curve family for details.
The size of an elliptic curve key is the bit size associated with the curve, that is, the bit size of :math:``q`` for a curve over a field :math:`\mathbb{F}_q`. See the documentation of each Elliptic curve family for details.

.. param:: curve
A value of type `psa_ecc_family_t` that identifies the ECC curve family to be used.
Expand Down Expand Up @@ -920,6 +920,143 @@ Diffie Hellman keys
.. return:: psa_dh_family_t
The Diffie-Hellman group family id, if ``type`` is a supported Diffie-Hellman key. Unspecified if ``type`` is not a supported Diffie-Hellman key.

Module Lattice keys
-------------------

PSA supports Module Lattice Cryptography as defined in :cite:`FIPS203` and :cite:`FIPS204`.

There are two related, but separate algorithms a key encapsulation method, ML-KEM and a signature method ML-DSA.

.. macro:: PSA_KEY_TYPE_MLKEM_KEY_PAIR
:definition: ((psa_key_type_t)0xy001)

.. summary::
MLKEM key pair: contains both the decapsulation and encapsulation keys.
PSA Crypto treats decapsulation keys as private keys and encapsulation keys as public keys.

The size of an ML-KEM key is specified by the numeric part of the parameter set identifier defined in FIPS 203.

The parameter sets refer to the key strength, the actual size of the key

.. list-table:: Sizes (in bytes) of keys and cipher texts for ML-KEM
:header-rows: 1

* - Size
- Parameter Set
- Encapsulation key
- Decapsulation key
- Ciphertext

* - 512
- ML-KEM-512
- 800
- 1632
- 768

* - 768
- ML-KEM-768
- 1184
- 2400
- 1088

* - 1024
- ML-KEM-1024
- 1568
- 3168
- 1568

In all cases the shared secret produced is 32-bytes, 256-bits long.
The shared secret can be used directly or passed to a PRF to derive further keys.

.. subsection:: Compatible algorithms

| `PSA_ALG_MLKEM`

.. macro:: PSA_KEY_TYPE_ML_KEM _PUBLIC_KEY
:definition: ((psa_key_type_t)0x4001)

.. summary::
ML-KEM public key.

The size of an ML-KEM key is the numeric part of the parameter set identifier.

.. subsection:: Compatible algorithms

| `PSA_ALG_MLKEM` (encapsulation only)
|
.. macro:: PSA_KEY_TYPE_IS_MLKEM
:definition: /* specification-defined value */

.. summary::
Whether a key type is an ML-KEM key. This includes both key pairs and public keys.

.. param:: type
A key type: a value of type `psa_key_type_t`.

.. macro:: PSA_KEY_TYPE_MLDSA_KEY_PAIR
:definition: ((psa_key_type_t)0xy001)

.. summary::
An ML_DSA key pair: contains both the public and private keys.

The size of an ML-DSA key is specified by the numeric part of the parameter set identifier defined in FIPS 203.

The parameter sets refer to the dimensions of the matrix A, and do not directly define key size.

.. list-table:: Sizes (in bytes) of keys and cipher texts for ML-KEM
:header-rows: 1

* - Size
- Parameter Set
- Private key
- Public key
- Signature

* - 44
- ML-DSA-44
- 2560
- 1312
- 2420

* - 65
- ML-DSA-65
- 4032
- 1952
- 3309

* - 87
- ML-DSA-87
- 4896
- 2592
- 4627

.. subsection:: Compatible algorithms

| `PSA_ALG_MLDSA_SIGN`

.. macro:: PSA_KEY_TYPE_MLDSA_PUBLIC_KEY
:definition: ((psa_key_type_t)0xy001)

.. summary::
A ML-DSA public key.

The size of an ML-DSA key is specified by the numeric part of the parameter set identifier defined in FIPS 203.

The parameter sets refer to the key strength, the actual size of the key

.. subsection:: Compatible algorithms

| `PSA_ALG_MLDSA_SIGN` (verification only)

.. macro:: PSA_KEY_TYPE_IS_MLDSA
:definition: /* specification-defined value */

.. summary::
Whether a key type is an ML-SIG key. This includes both key pairs and public keys.

.. param:: type
A key type: a value of type `psa_key_type_t`.

Attribute accessors
-------------------

Expand Down
2 changes: 2 additions & 0 deletions doc/crypto/api/ops/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The specific algorithm identifiers are described alongside the cryptographic ope
* :secref:`sign-algorithms`
* :secref:`asymmetric-encryption-algorithms`
* :secref:`key-agreement-algorithms`
* :secref:`encapsulation-algorithms`


Algorithm encoding
Expand Down Expand Up @@ -227,3 +228,4 @@ Algorithm categories
* `PSA_ALG_TLS12_PRF()`
* `PSA_ALG_TLS12_PSK_TO_MS()`
* `PSA_ALG_PBKDF2_HMAC()`
* `PSA_ALG_MLDSA_SIGN`
Loading