You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/crypto/api/keys/types.rst
+55-49Lines changed: 55 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,11 +117,11 @@ Symmetric keys
117
117
118
118
.. subsection:: Key format
119
119
120
-
The key data is the raw bytes of the key.
120
+
The data format for import and export of the key is the raw bytes of the key.
121
121
122
122
.. subsection:: Key derivation
123
123
124
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
124
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
125
125
126
126
.. macro:: PSA_KEY_TYPE_HMAC
127
127
:definition: ((psa_key_type_t)0x1100)
@@ -157,11 +157,11 @@ Symmetric keys
157
157
158
158
.. subsection:: Key format
159
159
160
-
The key data is the raw bytes of the key.
160
+
The data format for import and export of the key is the raw bytes of the key.
161
161
162
162
.. subsection:: Key derivation
163
163
164
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
164
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
165
165
166
166
.. macro:: PSA_KEY_TYPE_DERIVE
167
167
:definition: ((psa_key_type_t)0x1200)
@@ -191,11 +191,11 @@ Symmetric keys
191
191
192
192
.. subsection:: Key format
193
193
194
-
The key data is the raw bytes of the key.
194
+
The data format for import and export of the key is the raw bytes of the key.
195
195
196
196
.. subsection:: Key derivation
197
197
198
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
198
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
199
199
200
200
.. macro:: PSA_KEY_TYPE_PASSWORD
201
201
:definition: ((psa_key_type_t)0x1203)
@@ -225,11 +225,11 @@ Symmetric keys
225
225
226
226
.. subsection:: Key format
227
227
228
-
The key data is the raw bytes of the key.
228
+
The data format for import and export of the key is the raw bytes of the key.
229
229
230
230
.. subsection:: Key derivation
231
231
232
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
232
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
233
233
234
234
.. macro:: PSA_KEY_TYPE_PASSWORD_HASH
235
235
:definition: ((psa_key_type_t)0x1205)
@@ -250,11 +250,11 @@ Symmetric keys
250
250
251
251
.. subsection:: Key format
252
252
253
-
The key data is the raw bytes of the key.
253
+
The data format for import and export of the key is the raw bytes of the key.
254
254
255
255
.. subsection:: Key derivation
256
256
257
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
257
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
258
258
259
259
.. macro:: PSA_KEY_TYPE_PEPPER
260
260
:definition: ((psa_key_type_t)0x1206)
@@ -275,11 +275,11 @@ Symmetric keys
275
275
276
276
.. subsection:: Key format
277
277
278
-
The key data is the raw bytes of the key.
278
+
The data format for import and export of the key is the raw bytes of the key.
279
279
280
280
.. subsection:: Key derivation
281
281
282
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
282
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
283
283
284
284
.. macro:: PSA_KEY_TYPE_AES
285
285
:definition: ((psa_key_type_t)0x2400)
@@ -320,11 +320,11 @@ Symmetric keys
320
320
321
321
.. subsection:: Key format
322
322
323
-
The key data is the raw bytes of the key.
323
+
The data format for import and export of the key is the raw bytes of the key.
324
324
325
325
.. subsection:: Key derivation
326
326
327
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
327
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
328
328
329
329
.. macro:: PSA_KEY_TYPE_ARIA
330
330
:definition: ((psa_key_type_t)0x2406)
@@ -365,11 +365,11 @@ Symmetric keys
365
365
366
366
.. subsection:: Key format
367
367
368
-
The key data is the raw bytes of the key.
368
+
The data format for import and export of the key is the raw bytes of the key.
369
369
370
370
.. subsection:: Key derivation
371
371
372
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
372
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
373
373
374
374
.. macro:: PSA_KEY_TYPE_DES
375
375
:definition: ((psa_key_type_t)0x2301)
@@ -406,19 +406,19 @@ Symmetric keys
406
406
407
407
.. subsection:: Key format
408
408
409
-
The key data is the raw bytes of the key.
409
+
The data format for import and export of the key is the raw bytes of the key.
410
410
The parity bits in each 64-bit DES key element must be correct.
411
411
412
412
.. subsection:: Key derivation
413
413
414
-
To derive a single 64-bit DES key, use the following process:
414
+
A call to `psa_key_derivation_output_key()` will construct a single 64-bit DES key using the following process:
415
415
416
416
1. Draw an 8-byte string.
417
417
#. Set/clear the parity bits in each byte.
418
418
#. If the result is a forbidden weak key, discard the result and return to step 1.
419
419
#. Output the string.
420
420
421
-
For 2-key 3DES and 3-key 3DES, repeat this process to derive the 2nd and 3rd keys, as required.
421
+
For 2-key 3DES and 3-key 3DES, this process is repeated to derive the 2nd and 3rd keys, as required.
422
422
423
423
.. macro:: PSA_KEY_TYPE_CAMELLIA
424
424
:definition: ((psa_key_type_t)0x2403)
@@ -459,11 +459,11 @@ Symmetric keys
459
459
460
460
.. subsection:: Key format
461
461
462
-
The key data is the raw bytes of the key.
462
+
The data format for import and export of the key is the raw bytes of the key.
463
463
464
464
.. subsection:: Key derivation
465
465
466
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
466
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
467
467
468
468
.. macro:: PSA_KEY_TYPE_SM4
469
469
:definition: ((psa_key_type_t)0x2405)
@@ -496,11 +496,11 @@ Symmetric keys
496
496
497
497
.. subsection:: Key format
498
498
499
-
The key data is the raw bytes of the key.
499
+
The data format for import and export of the key is the raw bytes of the key.
500
500
501
501
.. subsection:: Key derivation
502
502
503
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
503
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
504
504
505
505
.. macro:: PSA_KEY_TYPE_ARC4
506
506
:definition: ((psa_key_type_t)0x2002)
@@ -523,11 +523,11 @@ Symmetric keys
523
523
524
524
.. subsection:: Key format
525
525
526
-
The key data is the raw bytes of the key.
526
+
The data format for import and export of the key is the raw bytes of the key.
527
527
528
528
.. subsection:: Key derivation
529
529
530
-
Draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
530
+
A call to `psa_key_derivation_output_key()` will draw:math:`m/8` bytes of output and use these as the key data, where :math:`m` is the bit-size of the key.
531
531
532
532
.. macro:: PSA_KEY_TYPE_CHACHA20
533
533
:definition: ((psa_key_type_t)0x2004)
@@ -550,11 +550,11 @@ Symmetric keys
550
550
551
551
.. subsection:: Key format
552
552
553
-
The key data is the raw bytes of the key.
553
+
The data format for import and export of the key is the raw bytes of the key.
554
554
555
555
.. subsection:: Key derivation
556
556
557
-
Draw 32 bytes of output and use these as the key data.
557
+
A call to `psa_key_derivation_output_key()` will draw 32 bytes of output and use these as the key data.
558
558
559
559
.. macro:: PSA_KEY_TYPE_XCHACHA20
560
560
:definition: ((psa_key_type_t)0x2007)
@@ -577,11 +577,11 @@ Symmetric keys
577
577
578
578
.. subsection:: Key format
579
579
580
-
The key data is the raw bytes of the key.
580
+
The data format for import and export of the key is the raw bytes of the key.
581
581
582
582
.. subsection:: Key derivation
583
583
584
-
Draw 32 bytes of output and use these as the key data.
584
+
A call to `psa_key_derivation_output_key()` will draw 32 bytes of output and use these as the key data.
585
585
586
586
.. _asymmetric-keys:
587
587
@@ -621,7 +621,7 @@ RSA keys
621
621
622
622
.. subsection:: Key format
623
623
624
-
The key data is the non-encrypted DER encoding of the representation defined by in :RFC-title:`8017` as ``RSAPrivateKey``, version ``0``.
624
+
The data format for import and export of a key-pair is the non-encrypted DER encoding of the representation defined by in :RFC-title:`8017` as ``RSAPrivateKey``, version ``0``.
625
625
626
626
.. code-block:: none
627
627
@@ -641,9 +641,11 @@ RSA keys
641
641
642
642
Although it is possible to define an RSA key pair or private key using a subset of these elements, the output from `psa_export_key()` for an RSA key pair must include all of these elements.
643
643
644
+
See `PSA_KEY_TYPE_RSA_PUBLIC_KEY` for the data format used when exporting the public key with `psa_export_public_key()`.
645
+
644
646
.. subsection:: Key derivation
645
647
646
-
The key derivation method for RSA keys is :term:`implementation defined`.
648
+
The method used by `psa_key_derivation_output_key()` to derive an RSA key-pair is :term:`implementation defined`.
647
649
648
650
.. macro:: PSA_KEY_TYPE_RSA_PUBLIC_KEY
649
651
:definition: ((psa_key_type_t)0x4001)
@@ -667,7 +669,7 @@ RSA keys
667
669
668
670
.. subsection:: Key format
669
671
670
-
The key data is the DER encoding of the representation defined by :RFC-title:`3279#2.3.1` as ``RSAPublicKey``.
672
+
The data format for import and export of a public key is the DER encoding of the representation defined by :RFC-title:`3279#2.3.1` as ``RSAPublicKey``.
671
673
672
674
.. code-block:: none
673
675
@@ -793,9 +795,10 @@ The curve type affects the key format, the key derivation procedure, and the alg
793
795
794
796
.. subsection:: Key format
795
797
798
+
The data format for import and export of the key-pair depends on the type of elliptic curve.
796
799
:numref:`tab-ecc-key-pair-format` shows the format for each type of elliptic curve key-pair.
797
-
This is the format used for `psa_import_key()` and `psa_export_key()`.
798
-
See `PSA_KEY_TYPE_ECC_PUBLIC_KEY()` for the format used for `psa_export_public_key()`.
800
+
801
+
See `PSA_KEY_TYPE_ECC_PUBLIC_KEY` for the data format used when exporting the public key with `psa_export_public_key()`.
799
802
800
803
.. list-table:: Key-pair formats for elliptic curve keys
801
804
:name: tab-ecc-key-pair-format
@@ -824,6 +827,7 @@ The curve type affects the key format, the key derivation procedure, and the alg
824
827
825
828
.. subsection:: Key derivation
826
829
830
+
The key derivation method used when calling `psa_key_derivation_output_key()` depends on the type of elliptic curve.
827
831
:numref:`tab-ecc-key-derivation` shows the derivation method for each type of elliptic curve key.
828
832
829
833
.. list-table:: Key derivation for elliptic curve keys
@@ -909,6 +913,7 @@ The curve type affects the key format, the key derivation procedure, and the alg
909
913
910
914
.. subsection:: Key format
911
915
916
+
The data format for import and export of the public key depends on the type of elliptic curve.
912
917
:numref:`tab-ecc-public-key-format` shows the format for each type of elliptic curve public key.
913
918
914
919
.. list-table:: Public key formats for elliptic curve keys
@@ -1175,14 +1180,18 @@ Diffie Hellman keys
1175
1180
1176
1181
.. subsection:: Key format
1177
1182
1178
-
The key data is the representation of the private key :math:`x` as a big-endian byte string.
1183
+
The data format for import and export of the key-pair is the representation of the private key :math:`x` as a big-endian byte string.
1179
1184
The length of the byte string is the private key size in bytes, and leading zeroes are not stripped.
1180
1185
1186
+
See `PSA_KEY_TYPE_DH_PUBLIC_KEY` for the data format used when exporting the public key with `psa_export_public_key()`.
1187
+
1181
1188
.. subsection:: Key derivation
1182
1189
1183
-
A Diffie-Hellman private key is :math:`x \in [1, p - 1]`, where :math:`p` is the group's prime modulus.
1190
+
A call to `psa_key_derivation_output_key()` will use the following process, defined in *Key-Pair Generation by Testing Candidates* in :cite-title:`SP800-56A` §5.6.1.1.4.
1184
1191
1192
+
A Diffie-Hellman private key is :math:`x \in [1, p - 1]`, where :math:`p` is the group's prime modulus.
1185
1193
Let :math:`m` be the bit size of :math:`p`, such that :math:`2^{m-1} \leq p < 2^m`.
1194
+
1186
1195
This function generates the private key using the following process:
1187
1196
1188
1197
1. Draw a byte string of length :math:`\lceil{m/8}\rceil` bytes.
@@ -1191,8 +1200,6 @@ Diffie Hellman keys
1191
1200
#. If :math:`k > p-2`, discard the result and return to step 1.
1192
1201
#. Output :math:`x = k + 1` as the private key.
1193
1202
1194
-
This method allows compliance to NIST standards, specifically the methods titled *Key-Pair Generation by Testing Candidates* in :cite-title:`SP800-56A` §5.6.1.1.4.
1195
-
1196
1203
.. macro:: PSA_KEY_TYPE_DH_PUBLIC_KEY
1197
1204
:definition: /* specification-defined value */
1198
1205
@@ -1204,11 +1211,12 @@ Diffie Hellman keys
1204
1211
1205
1212
.. subsection:: Compatible algorithms
1206
1213
1207
-
None. Finite-field Diffie-Hellman public keys are exported to use in a key agreement algorithm, and the peer key is provided to the `PSA_ALG_FFDH` key agreement algorithm as a buffer of key data.
1214
+
None: Finite-field Diffie-Hellman public keys are exported to use in a key agreement algorithm, and the peer key is provided to the `PSA_ALG_FFDH` key agreement algorithm as a buffer of key data.
1208
1215
1209
1216
.. subsection:: Key format
1210
1217
1211
-
The key data is the representation of the public key :math:`y = g^x\!\mod p` as a big-endian byte string. The length of the byte string is the length of the base prime :math:`p` in bytes.
1218
+
The data format for export of the public key is the representation of the public key :math:`y = g^x\!\mod p` as a big-endian byte string.
1219
+
The length of the byte string is the length of the base prime :math:`p` in bytes.
1212
1220
1213
1221
.. macro:: PSA_DH_FAMILY_RFC7919
1214
1222
:definition: ((psa_dh_family_t) 0x03)
@@ -1326,22 +1334,22 @@ SPAKE2+ keys
1326
1334
1327
1335
.. subsection:: Key format
1328
1336
1329
-
A SPAKE2+ key pair can be exported and imported.
1330
-
1331
-
The key consists of the two values :math:`w0` and :math:`w1`, which result from the SPAKE2+ registration phase, see :secref:`spake2p-registration`.
1337
+
A SPAKE2+ key-pair consists of the two values :math:`w0` and :math:`w1`, which result from the SPAKE2+ registration phase, see :secref:`spake2p-registration`.
1332
1338
:math:`w0` and :math:`w1` are scalars in the same range as an elliptic curve private key from the group used as the SPAKE2+ primitive group.
1333
1339
1334
-
For the |API|, the default format for a SPAKE2+ keypair is the concatenation of the formatted values for :math:`w0` and :math:`w1`, using the standard formats for elliptic curve keys used by the |API|.
1340
+
The data format for import and export of the key-pair is the concatenation of the formatted values for :math:`w0` and :math:`w1`, using the standard formats for elliptic curve keys used by the |API|.
1335
1341
For example, for SPAKE2+ over P-256 (secp256r1), the output from :code:`psa_export_key()` would be the concatenation of:
1336
1342
1337
1343
* The P-256 private key :math:`w0`.
1338
1344
This is a 32-byte big-endian encoding of the integer :math:`w0`.
1339
1345
* The P-256 private key :math:`w1`.
1340
1346
This is a 32-byte big-endian encoding of the integer :math:`w1`.
1341
1347
1348
+
See `PSA_KEY_TYPE_SPAKE2P_PUBLIC_KEY` for the data format used when exporting the public key with `psa_export_public_key()`.
1349
+
1342
1350
.. subsection:: Key derivation
1343
1351
1344
-
The SPAKE2+ key derivation process follows the recommendations for the registration process in :rfc-title:`9383`, and matches the specification of this process in :cite-title:`MATTER`.
1352
+
A call to `psa_key_derivation_output_key()` will use the following process, which follows the recommendations for the registration process in :rfc-title:`9383`, and matches the specification of this process in :cite-title:`MATTER`.
1345
1353
1346
1354
The derivation of SPAKE2+ keys extracts :math:`\lceil{log_2(p)/8}\rceil+8` bytes from the PBKDF for each of :math:`w0s` and :math:`w1s`, where :math:`p` is the prime factor of the order of the elliptic curve group.
1347
1355
The following sizes are used for extracting :math:`w0s` and :math:`w1s`, depending on the elliptic curve:
@@ -1384,13 +1392,11 @@ SPAKE2+ keys
1384
1392
1385
1393
.. subsection:: Key format
1386
1394
1387
-
A SPAKE2+ public key can be exported and imported, to enable use cases that require offline registration.
1388
-
1389
-
The public key consists of the two values :math:`w0` and :math:`L`, which result from the SPAKE2+ registration phase, see :secref:`spake2p-registration`.
1395
+
A SPAKE2+ public key consists of the two values :math:`w0` and :math:`L`, which result from the SPAKE2+ registration phase, see :secref:`spake2p-registration`.
1390
1396
:math:`w0` is a scalar in the same range as a elliptic curve private key from the group used as the SPAKE2+ primitive group.
1391
1397
:math:`L` is a point on the curve, similar to a public key from the same group, corresponding to the :math:`w1` value in the key pair.
1392
1398
1393
-
For the |API|, the default format for a SPAKE2+ public key is the concatenation of the formatted values for :math:`w0` and :math:`L`, using the standard formats for elliptic curve keys used by the |API|.
1399
+
The data format for import and export of the public key is the concatenation of the formatted values for :math:`w0` and :math:`L`, using the standard formats for elliptic curve keys used by the |API|.
1394
1400
For example, for SPAKE2+ over P-256 (secp256r1), the output from :code:`psa_export_public_key()` would be the concatenation of:
0 commit comments