[php-src] PR #19103: fix: check priv_key_bits only for relevant private key types

From: Date: Sat, 12 Jul 2025 12:59:50 +0000
Subject: [php-src] PR #19103: fix: check priv_key_bits only for relevant private key types
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-32407@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/19103 Author: joostdebruijn # Description php_openssl_generate_private_key currently applies the MIN_KEY_LENGTH (384 bits) check across all key types, including EC (Elliptic Curve) keys. However, for EC key generation, the private_key_bits parameter is not relevant—the security of EC keys is determined by the selected curve, not the bit length. As a result, applying this check to EC keys can cause developer confusion. For reference, see related discussions: - [Laravel Notification Channels Issue #213](https://github.com/laravel-notification-channels/webpush/issues/213) - [Stack Overflow: Why can't I use key lengths <384bit for EC in PHP OpenSSL?](https://stackoverflow.com/questions/62430373/why-cant-i-use-key-lengths-384bit-for-ec-in-php-openssl) # Solution This PR updates php_openssl_generate_private_key to enforce the MIN_KEY_LENGTH check only for key types where the priv_key_bits parameter is meaningful—specifically RSA, DSA, and DH keys. # Additional Notes - As a side note, the current MIN_KEY_LENGTH of 384 bits for RSA, DSA, and DH keys is not considered secure by modern standards. Ideally, this minimum should be raised (e.g., to 2048 bits for RSA), or the check reconsidered entirely. - Regarding branch targets: The contribution guide suggests targeting the PHP-8.3 branch for bug fixes (as this is the lowest actively supported version). However, for extension changes, this branch lacks the involved source files. Please advise if a different branch is preferred for this PR.

« previous php.git-pulls (#32407) next »