Repository navigation
[zend-openid] fix TypeError when openssl rejects DH parameters - #247
Open
falkenhawk wants to merge 1 commit into
Open
falkenhawk wants to merge 1 commit into
falkenhawk wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenID uses Diffie-Hellman (DH) keys to agree on a shared secret.
Zend_OpenId::createDhKey()creates them withopenssl_pkey_new(), which returnsfalsewhen OpenSSL rejects the DH parameters.The next call,
getDhKeyDetails(), then throws aTypeErroron php 8.1) The provider crashes on rejected DH parameters
Zend_OpenId_Providertakes the DH parameters from the association request.OpenSSL 3+ rejects a modulus it considers too small ("modulus too small"), so a request with such a modulus ends with a 500 error.
The provider now answers with an association error, as for other invalid association parameters.
Zend_OpenId_Consumeralways uses the default 1024-bit modulus of the OpenID spec, which all OpenSSL versions accept.Should OpenSSL ever reject it, the association now fails like on any other error, instead of throwing.
computeDhSecret()no longer reads$ret[0]whenopenssl_dh_compute_key()fails, it returnsfalse, which the provider already handles.2) Tests on OpenSSL 3+
testCreateDhKeyandtestComputeDhSecretused a tiny test modulus (0x0233). OpenSSL 3+ rejects it, so the test run ended with a fatal error.They now use the default modulus
Zend_OpenId::DH_Pwith fixed private keys, and check the exact public keys and shared secret.The expected values were computed with gmp and match OpenSSL 1.1, 3.5 and 4.0.
diablomedia skips these tests on OpenSSL 3 instead (diablomedia/zf1-openid#238).
A new provider test checks the error response for a modulus of
1, which every OpenSSL version rejects.