Skip to content

Commit 2de2c0d

Browse files
Clarify deterministic generation by re-drawing
For DH, ECC (Weierstrass curves) and DSA, specify that the re-drawing method is the one defined by NIST as "key-pair generation by testing candidates", and describe it unambiguously. Also specify DES explicitly.
1 parent fa4486d commit 2de2c0d

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

include/psa/crypto.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,12 +2924,31 @@ psa_status_t psa_generator_read(psa_crypto_generator_t *generator,
29242924
* for the output produced by psa_export_key().
29252925
* The following key types defined in this specification follow this scheme:
29262926
*
2927-
* - #PSA_KEY_TYPE_DES;
2928-
* - #PSA_KEY_TYPE_DH_KEYPAIR;
2929-
* - #PSA_KEY_TYPE_DSA_KEYPAIR;
2930-
* - ECC keys on a Weierstrass elliptic curve, i.e.
2931-
* #PSA_KEY_TYPE_ECC_KEYPAIR(\c curve) where \c curve designates a
2932-
* Weierstrass curve.
2927+
* - #PSA_KEY_TYPE_DES.
2928+
* Force-set the parity bits, but discard forbidden weak keys.
2929+
* For 2-key and 3-key triple-DES, the three keys are generated
2930+
* successively (for example, for 3-key triple-DES,
2931+
* if the first 8 bytes specify a weak key and the next 8 bytes do not,
2932+
* discard the first 8 bytes, use the next 8 bytes as the first key,
2933+
* and continue reading output from the generator to derive the other
2934+
* two keys).
2935+
* - Finite-field Diffie-Hellman keys (#PSA_KEY_TYPE_DH_KEYPAIR),
2936+
* DSA keys (#PSA_KEY_TYPE_DSA_KEYPAIR), and
2937+
* ECC keys on a Weierstrass elliptic curve
2938+
* (#PSA_KEY_TYPE_ECC_KEYPAIR(\c curve) where \c curve designates a
2939+
* Weierstrass curve).
2940+
* For these key types, interpret the byte string as integer
2941+
* in big-endian order. Discard it if it is not in the range
2942+
* [0, *N* - 2] where *N* is the boundary of the private key domain
2943+
* (the prime *p* for Diffie-Hellman, the subprime *q* for DSA,
2944+
* or the order of the curve's coordinate field for ECC).
2945+
* Add 1 to the resulting integer and use this as the private key *x*.
2946+
* This is the method described as
2947+
* "key-pair generation by testing candidates"
2948+
* in NIST SP 800-56A §5.6.1.1.4 for Diffie-Hellman,
2949+
* in FIPS 186-4 §B.1.2 for DSA, and
2950+
* in NIST SP 800-56A §5.6.1.2.2 or
2951+
* FIPS 186-4 §B.4.2 for elliptic curve keys.
29332952
*
29342953
* - For other key types, including #PSA_KEY_TYPE_RSA_KEYPAIR,
29352954
* the way in which the generator output is consumed is

0 commit comments

Comments
 (0)