Skip to content

Commit f57cb97

Browse files
committed
Rename key-wrap algorithms to be agnostic of the block cipher
1 parent 506cf6c commit f57cb97

File tree

6 files changed

+47
-26
lines changed

6 files changed

+47
-26
lines changed

doc/crypto/api.db/psa/crypto.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ typedef struct psa_custom_key_parameters_t {
5858
/* specification-defined value */
5959
#define PSA_ALG_AEAD_WITH_SHORTENED_TAG(aead_alg, tag_length) \
6060
/* specification-defined value */
61-
#define PSA_ALG_AES_KW ((psa_algorithm_t)0x0B400100)
62-
#define PSA_ALG_AES_KWP ((psa_algorithm_t)0x0BC00200)
6361
#define PSA_ALG_AES_MMO_ZIGBEE ((psa_algorithm_t)0x02000007)
6462
#define PSA_ALG_ANY_HASH ((psa_algorithm_t)0x020000ff)
6563
#define PSA_ALG_AT_LEAST_THIS_LENGTH_MAC(mac_alg, min_mac_length) \
@@ -144,6 +142,8 @@ typedef struct psa_custom_key_parameters_t {
144142
/* specification-defined value */
145143
#define PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) /* specification-defined value */
146144
#define PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) /* specification-defined value */
145+
#define PSA_ALG_KW ((psa_algorithm_t)0x0B400100)
146+
#define PSA_ALG_KWP ((psa_algorithm_t)0x0BC00200)
147147
#define PSA_ALG_MD2 ((psa_algorithm_t)0x02000001)
148148
#define PSA_ALG_MD4 ((psa_algorithm_t)0x02000002)
149149
#define PSA_ALG_MD5 ((psa_algorithm_t)0x02000003)

doc/crypto/api/keys/types.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ Symmetric keys
322322
* `PSA_ALG_ECB_NO_PADDING`
323323
* `PSA_ALG_CCM`
324324
* `PSA_ALG_GCM`
325+
* `PSA_ALG_KW`
326+
* `PSA_ALG_KWP`
325327
* `PSA_ALG_SP800_108_COUNTER_CMAC` (secret input)
326-
* `PSA_ALG_AES_KW`
327-
* `PSA_ALG_AES_KWP`
328328

329329
.. subsection:: Key format
330330

@@ -371,6 +371,8 @@ Symmetric keys
371371
* `PSA_ALG_ECB_NO_PADDING`
372372
* `PSA_ALG_CCM`
373373
* `PSA_ALG_GCM`
374+
* `PSA_ALG_KW`
375+
* `PSA_ALG_KWP`
374376
* `PSA_ALG_SP800_108_COUNTER_CMAC` (secret input)
375377

376378
.. subsection:: Key format
@@ -465,6 +467,8 @@ Symmetric keys
465467
* `PSA_ALG_ECB_NO_PADDING`
466468
* `PSA_ALG_CCM`
467469
* `PSA_ALG_GCM`
470+
* `PSA_ALG_KW`
471+
* `PSA_ALG_KWP`
468472
* `PSA_ALG_SP800_108_COUNTER_CMAC` (secret input)
469473

470474
.. subsection:: Key format
@@ -502,6 +506,8 @@ Symmetric keys
502506
* `PSA_ALG_ECB_NO_PADDING`
503507
* `PSA_ALG_CCM`
504508
* `PSA_ALG_GCM`
509+
* `PSA_ALG_KW`
510+
* `PSA_ALG_KWP`
505511
* `PSA_ALG_SP800_108_COUNTER_CMAC` (secret input)
506512

507513
.. subsection:: Key format

doc/crypto/api/ops/algorithms.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The specific algorithm identifiers are described alongside the cryptographic ope
2020
* :secref:`mac-algorithms`
2121
* :secref:`cipher-algorithms`
2222
* :secref:`aead-algorithms`
23+
* :secref:`key-wrapping-algorithms`
2324
* :secref:`key-derivation-algorithms`
2425
* :secref:`sign`
2526
* :secref:`asymmetric-encryption-algorithms`

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

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,48 +38,54 @@ When using one of these key-wrapping algorithms, the key attributes are managed
3838
Key-wrapping algorithms
3939
-----------------------
4040

41-
.. macro:: PSA_ALG_AES_KW
41+
.. macro:: PSA_ALG_KW
4242
:definition: ((psa_algorithm_t)0x0B400100)
4343

4444
.. summary::
45-
The AES-KW key-wrapping algorithm.
45+
A key-wrapping algorithm based on the NIST Key Wrap (KW) mode of a block cipher.
4646

47-
.. todo::
48-
Decide if we should support any 128-bit block-cipher, as described in SP800-38F.
49-
If so, the name of this algorithm would need to change.
50-
For example, to ``PSA_ALG_SP800_38_KEY_WRAP``?
47+
.. versionadded:: 1.4
5148

52-
This is the NIST Key Wrap algorithm, using an AES key-encryption key, as defined in :cite-title:`SP800-38F`.
53-
The algorithm is also defined in :rfc-title:`3394`.
49+
KW is defined for block ciphers that have a 128-bit block size.
50+
The underlying block cipher is determined by the key type.
5451

55-
Keys to be wrapped must have a length equal to a multiple of the 'semi-block' size for AES.
52+
Keys to be wrapped must have a length equal to a multiple of the 'semi-block' size for the block cipher.
5653
That is, a multiple of 8 bytes.
5754

58-
To wrap keys that are not a multiple of the AES semi-block size, `PSA_ALG_AES_KWP` can be used.
55+
To wrap keys that are not a multiple of the semi-block size, `PSA_ALG_KWP` can be used.
56+
57+
This is the NIST Key Wrap algorithm, using any block-cipher that operates on 128-bit blocks, as defined in :cite-title:`SP800-38F`.
58+
A definition of AES-KW is also found in :rfc-title:`3394`.
5959

6060
.. subsection:: Compatible key types
6161

6262
| `PSA_KEY_TYPE_AES`
63+
| `PSA_KEY_TYPE_ARIA`
64+
| `PSA_KEY_TYPE_CAMELLIA`
65+
| `PSA_KEY_TYPE_SM4`
6366
64-
.. macro:: PSA_ALG_AES_KWP
67+
.. macro:: PSA_ALG_KWP
6568
:definition: ((psa_algorithm_t)0x0BC00200)
6669

6770
.. summary::
68-
The AES-KWP key-wrapping algorithm with padding.
71+
A key-wrapping algorithm based on the NIST Key Wrap with Padding (KWP) mode of a block cipher.
6972

70-
.. todo::
71-
Decide if we should support any 128-bit block-cipher, as described in SP800-38F.
72-
If so, the name of this algorithm would need to change.
73-
For example, to ``PSA_ALG_SP800_38_KEY_WRAP_WITH_PADDING``?
73+
.. versionadded:: 1.4
7474

75-
This is the NIST Key Wrap with Padding algorithm, using an AES key-encryption key, as defined in :cite-title:`SP800-38F`.
76-
The algorithm is also defined in :rfc-title:`5649`.
75+
KWP is defined for block ciphers that have a 128-bit block size.
76+
The underlying block cipher is determined by the key type.
7777

7878
This algorithm can wrap a key of any length.
7979

80+
This is the NIST Key Wrap with Padding algorithm, using any block-cipher that operates on 128-bit blocks, as defined in :cite-title:`SP800-38F`.
81+
A definition of AES-KWP is also found in :rfc-title:`5649`.
82+
8083
.. subsection:: Compatible key types
8184

8285
| `PSA_KEY_TYPE_AES`
86+
| `PSA_KEY_TYPE_ARIA`
87+
| `PSA_KEY_TYPE_CAMELLIA`
88+
| `PSA_KEY_TYPE_SM4`
8389
8490
Key wrapping functions
8591
----------------------
@@ -89,6 +95,8 @@ Key wrapping functions
8995
.. summary::
9096
Unwrap and import a key using a specified wrapping key.
9197

98+
.. versionadded:: 1.4
99+
92100
.. param:: const psa_key_attributes_t * attributes
93101
The attributes for the new key.
94102

@@ -200,6 +208,8 @@ Key wrapping functions
200208
.. summary::
201209
Wrap and export a key using a specified wrapping key.
202210

211+
.. versionadded:: 1.4
212+
203213
.. param:: psa_key_id_t wrapping_key
204214
Identifier of the key to use for the wrapping operation.
205215
It must permit the usage `PSA_KEY_USAGE_WRAP`.
@@ -280,6 +290,8 @@ Support macros
280290
.. summary::
281291
Sufficient output buffer size for `psa_wrap_key()`.
282292

293+
.. versionadded:: 1.4
294+
283295
.. param:: wrap_key_type
284296
A supported key-wrapping key type.
285297
.. param:: alg
@@ -300,6 +312,8 @@ Support macros
300312
.. summary::
301313
Sufficient buffer size for wrapping any asymmetric key pair.
302314

315+
.. versionadded:: 1.4
316+
303317
This value must be a sufficient buffer size when calling `psa_wrap_key()` to export any asymmetric key pair that is supported by the implementation, regardless of the exact key type and key size.
304318

305319
See also `PSA_WRAP_KEY_OUTPUT_SIZE()`.

doc/crypto/appendix/encodings.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ The defined values for S, B, and WRAP-TYPE are shown in :numref:`table-key-wrap-
299299
:widths: auto
300300

301301
Key-wrapping algorithm, S, B, WRAP-TYPE, Algorithm identifier, Algorithm value
302-
AES-KW, 0, 1, ``0x01``, `PSA_ALG_AES_KW`, ``0x0B400100``
303-
AES-KWP, 1, 1, ``0x02``, `PSA_ALG_AES_KWP`, ``0x0BC00200``
302+
AES-KW, 0, 1, ``0x01``, `PSA_ALG_KW`, ``0x0B400100``
303+
AES-KWP, 1, 1, ``0x02``, `PSA_ALG_KWP`, ``0x0BC00200``
304304

305305
.. _kdf-encoding:
306306

doc/crypto/appendix/history.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Changes to the API
2121
* Added `psa_check_key_usage()` to query a key's capabilities.
2222
* Add support for extendable-output functions (XOF).
2323
See :secref:`xof`.
24+
* Added support for key wrapping using key-wrapping algorithms.
25+
See :secref:`key-wrapping`.
2426

2527
Clarifications and fixes
2628
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -71,8 +73,6 @@ Changes to the API
7173

7274
- Added `PSA_ALG_ECIES_SEC1` as a key-encapsulation algorithm that implements the key agreement steps of ECIES.
7375

74-
* Added support for key wrapping using key-wrapping algorithms. See :secref:`key-wrapping`.
75-
7676
Clarifications and fixes
7777
~~~~~~~~~~~~~~~~~~~~~~~~
7878

0 commit comments

Comments
 (0)