Repository navigation
Conversation
As already done in WinCNG. Follow-up to 5a96f49 libssh2#879
ssh2_dh_key_pair() reject negative group_order, where missingssh2_dh_key_pair() reject negative group_order, where missing
There was a problem hiding this comment.
Pull request overview
This PR aligns multiple crypto backends by adding an explicit guard in ssh2_dh_key_pair() to reject negative group_order values (matching the WinCNG behavior introduced previously), preventing negative sizes from flowing into DH private exponent generation.
Changes:
- Add
group_order < 0early-return guards in DH keypair generation across OS/400 QC3, OpenSSL, mbedTLS, and libgcrypt backends. - Minor expression parenthesization in OpenSSL/libgcrypt DH exponent bit-length calculation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/os400qc3.c | Adds negative group_order rejection in OS/400 QC3 DH keypair routine. |
| src/openssl.c | Adds negative group_order rejection and tweaks the DH exponent bit-length expression. |
| src/mbedtls.c | Adds negative group_order rejection in mbedTLS DH keypair routine. |
| src/libgcrypt.c | Adds negative group_order rejection and tweaks the DH exponent bit-length expression. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ssh2_dh_key_pair() reject negative group_order, where missingssh2_dh_key_pair() reject negative/zero group_order, where missing
ssh2_dh_key_pair() reject negative/zero group_order, where missingssh2_dh_key_pair() reject group_order <= 0, where missing
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.
As already done in WinCNG, but for negative only.
Follow-up to 5a96f49 #879