Skip to content

test_simple: make test_ssh2_dh_validate() portable - #2595

Closed
vszakats wants to merge 9 commits into
libssh2:masterfrom
vszakats:bnt
Closed

vszakats wants to merge 9 commits into
libssh2:masterfrom
vszakats:bnt

Conversation

@vszakats

@vszakats vszakats commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Omit direct backend-specific API use. Drop one test using negative
input, that's impossible with the internal crypto API. Using
backend-specific code in tests is highly undesired. It's also
discouraged to special-case any, in this case WinCNG had to be because
it does not implement the DH validation function.

Also:

  • mbedtls: fix an internal API type difference with a cast.
  • unfold a line.

Follow-up to fcf8307 #2239

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The generic setup always reports failure with libgcrypt and can dereference failed big-number allocations.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Makes the DH validation test backend-portable by using internal big-number APIs.

Changes:

  • Replaces backend-specific test setup with generic big-number operations.
  • Adds the required mbedTLS integer cast.
  • Removes the unsupported negative-number case.
File summaries
File Description
tests/test_simple.c Makes DH validation test setup backend-independent.
src/mbedtls.h Aligns the word type with mbedTLS’s API.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/test_simple.c Outdated
Comment on lines +257 to +258
if(ssh2_bn_set_word(f, (uint32_t)atoi(t.f)) ||
ssh2_bn_set_word(p, (uint32_t)atoi(t.p)))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

→ PR #2596

Comment thread tests/test_simple.c Resolved
vszakats added a commit that referenced this pull request Sep 7, 2026
It was returning a non-NULL address on success, which translated to
permanent failure as mapped to this internal crypto API. Fix to match it
with the rest of crypto backends and the expectation of callers.

Reported by Copilot
Bug: #2595 (comment)
Follow-up to 95c824d #1354
Follow-up to c9d40af

Closes #2596

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test now fails on OS/400 because its validator does not return the expected detailed error codes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread tests/test_simple.c
Comment on lines +252 to +253
#ifdef LIBSSH2_WINCNG
got = t.expected;

@vszakats vszakats Sep 7, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I consider this an omission in the OS/400 implementation. If someone cares
to run this test on this platform, the internal API needs to be updated to pass
the test.

@vszakats vszakats closed this in a951e06 Sep 7, 2026
@vszakats
vszakats deleted the bnt branch September 7, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants