Skip to content

Make OS/400 implementation work again - #953

Merged
vszakats merged 8 commits into
libssh2:masterfrom
monnerat:os400
Apr 13, 2023
Merged

vszakats merged 8 commits into
libssh2:masterfrom
monnerat:os400

Conversation

@monnerat

Copy link
Copy Markdown
Contributor

After more than 6 years without an IBM i, I have been able to do some work on libssh2 for it thanks to pub400.com.
During this time, some "injuries" were done to this implementation. The commits in this PR contribute all together to fix them:

  • Min target version is now V7R3M0. The build script now features ASCII C runtime development files in a non-standard path.
  • A code style cleanup introduced a bug in big numbers: fixed.
  • A pointer target type function parameter was incompatible: fixed.
  • Block length in os400qc3 cipher definitions were wrong: fixed.
  • Increase of Diffie-Hellman requested modulus size caused an error (QC3 is limited to 2048 bits). Fixed by reducing these for os400qc3.
  • Failing Diffie-Hellman key pair generation now effectively returns an error.
  • Implement an ASCII-compatible assert.h header file.
  • Implement RSA2 in os400qc3 backend.

Thanks for considering this.

This enables the possibility to compile libssh2 even if the ascii
runtime development files are not installed system-wide.
A temporary variable matching the parameter type is used before copying
to the real target and checking for overflow (that should not occur!).
A bug added by a previous code style cleaning is fixed.
_libssh2_random() now checks and return the success status.
They were wrongly set to the key size.
In particular, os400qc3 limits the maximum group size to 2048-bits.
Move definitions of these parameters to crypto backend header files.
@vszakats
vszakats merged commit 6dc42e9 into libssh2:master Apr 13, 2023
@vszakats

Copy link
Copy Markdown
Member

Thanks @monnerat!

@monnerat

Copy link
Copy Markdown
Contributor Author

Thanks to you for merging, @vszakats :-)

@monnerat
monnerat deleted the os400 branch April 13, 2023 16:21
agreppin pushed a commit to agreppin/libssh2 that referenced this pull request Jul 14, 2024
* os400: support QADRT development files in a non-standard directory

This enables the possibility to compile libssh2 even if the ascii
runtime development files are not installed system-wide.

* userauth_kbd_packet: fix a pointer target type mismatch.

A temporary variable matching the parameter type is used before copying
to the real target and checking for overflow (that should not occur!).

* os400qc3: move and fix big number procedures

A bug added by a previous code style cleaning is fixed.
_libssh2_random() now checks and return the success status.

* os400qc3: fix cipher definition block lengths

They were wrongly set to the key size.

* Diffie-Hellman min/max modulus sizes are dependent of crypto-backend

In particular, os400qc3 limits the maximum group size to 2048-bits.
Move definitions of these parameters to crypto backend header files.

* kex: return an error if Diffie-Hellman key pair generation fails

* os400: add an ascii assert.h header file

* os400qc3: implement RSA SHA2 256/512
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 10, 2026
[16/136] Building C object src/CMakeFiles/libssh2_static.dir/userauth_kbd_packet.c.o
src/userauth_kbd_packet.c:102:44: warning: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
  102 |        (session->userauth_kybd_num_prompts = tmp_u32) != tmp_u32) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
src/userauth_kbd_packet.c:102:44: note: if it should be an assignment, move it out of the 'if' condition
src/userauth_kbd_packet.c:102:44: note: if it is meant to be an equality check, change '=' to '=='

Follow-up to 6dc42e9 libssh2#953
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 10, 2026
[16/136] Building C object src/CMakeFiles/libssh2_static.dir/userauth_kbd_packet.c.o
src/userauth_kbd_packet.c:102:44: warning: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
  102 |        (session->userauth_kybd_num_prompts = tmp_u32) != tmp_u32) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
src/userauth_kbd_packet.c:102:44: note: if it should be an assignment, move it out of the 'if' condition
src/userauth_kbd_packet.c:102:44: note: if it is meant to be an equality check, change '=' to '=='

Follow-up to 6dc42e9 libssh2#953
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 10, 2026
[16/136] Building C object src/CMakeFiles/libssh2_static.dir/userauth_kbd_packet.c.o
src/userauth_kbd_packet.c:102:44: warning: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
  102 |        (session->userauth_kybd_num_prompts = tmp_u32) != tmp_u32) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
src/userauth_kbd_packet.c:102:44: note: if it should be an assignment, move it out of the 'if' condition
src/userauth_kbd_packet.c:102:44: note: if it is meant to be an equality check, change '=' to '=='

Follow-up to 6dc42e9 libssh2#953
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 10, 2026
[16/136] Building C object src/CMakeFiles/libssh2_static.dir/userauth_kbd_packet.c.o
src/userauth_kbd_packet.c:102:44: warning: an assignment within an 'if' condition is bug-prone [bugprone-assignment-in-if-condition]
  102 |        (session->userauth_kybd_num_prompts = tmp_u32) != tmp_u32) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
src/userauth_kbd_packet.c:102:44: note: if it should be an assignment, move it out of the 'if' condition
src/userauth_kbd_packet.c:102:44: note: if it is meant to be an equality check, change '=' to '=='

Follow-up to 6dc42e9 libssh2#953
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants