Reject oversized DSA parameters in PKCS#8 private key parsing (#16039)
* Reject oversized DSA parameters in PKCS#8 private key parsing
The DSA branch of parse_private_key computed the public key with a
modular exponentiation over parameters taken directly from the
untrusted input. A crafted key with a 16384-bit (or larger) modulus
made load_der_private_key burn seconds to minutes of CPU before the
key could be rejected.
Validate the parameters before the exponentiation: reject a modulus
larger than 4096 bits (the largest DSA modulus supported elsewhere
in the library, see check_dsa_parameters), and reject g or private
key values that are not smaller than the modulus.
Fixes #16034
* Move oversized DSA modulus test to the Python suite
The Rust unit test for the oversized DSA modulus rejection is
replaced by a Python test with a test vector: Rust tests are only
for things impossible to cover from Python.
* remove unneeded changelog entry
---------
Co-authored-by: tony1233200 <yc25778@gmail.com>
Co-authored-by: Paul Kehrer <paul.l.kehrer@gmail.com>
4 files changed