Repository navigation
Conversation
For some reason file vs blob code is vastly different.
vszakats
marked this pull request as draft
July 21, 2026 15:06
Comment on lines
+2216
to
+2225
| if(privatekey) | ||
| return os400_pub_privkey_file(session, method, method_len, | ||
| pubkeydata, pubkeydata_len, | ||
| privatekey, | ||
| passphrase); | ||
| else | ||
| return os400_pub_privkey_blob(session, method, method_len, | ||
| pubkeydata, pubkeydata_len, | ||
| privkeyblob, privkeyblob_len, | ||
| passphrase); |
Member
Author
There was a problem hiding this comment.
Hyperactive annoying LLM.
Member
Author
There was a problem hiding this comment.
This class of issues is all preexisting unless I'm missing something.
Won't be tackling it here.
Member
Author
|
Automatic review is somewhat annoying. |
vszakats
marked this pull request as ready for review
July 21, 2026 16:55
This reverts commit e1bd5c8.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
src/openssl.c:3927
- If
PEM_read_bio_PrivateKey()fails but the OpenSSH fallback (ossl_key_from_openssh_file/blob) succeeds, OpenSSL errors produced by the failed PEM read can remain on the thread-local error queue. This is the same class of issue as #1652 (stale errors after successfully loading an OpenSSH key). Consider clearing the remaining OpenSSL error queue on the!pkpath after capturingsslError(when applicable) so a successful return leaves no OpenSSL errors behind.
(void)BIO_reset(bp);
pk = PEM_read_bio_PrivateKey(bp, NULL, NULL, SSH2_UNCONST(passphrase));
#ifdef HAVE_SSLERROR_BAD_DECRYPT
sslError = ERR_get_error();
#endif
This was referenced Jul 21, 2026
vszakats
added a commit
that referenced
this pull request
Jul 22, 2026
To further merge file/blob codepaths/behavior, and to reduce branching at callers. Also: - pem: add internal API `ssh2_file_to_blob()` to load a (PEM) file into memory. Use it internally. Make sure to null-terminate the returned blob, primarily for mbedTLS. - mbedtls, os400qc3: use `ssh2_file_to_blob()`. - pem: fix to return `LIBSSH2_ERROR_ALGO_UNSUPPORTED` in `ssh2_pem_parse()` in no-MD5 builds (was: -1). - os400qc3: fix to scrub data before free in `try_pem_load()`. Note: - os400qc3: `try_pem_load()` has unique behavior of allowing multiple instances of private keys within a single file, but only when loading from a file. I could not positively confirm this to be valid/standard private file format, nor find a comment or commit message explaining the behavior. I've added (untested) support for this using the blob codepath, because the `FILE *` method is now gone from `pem.c`. It also seems one contributing factor why the file (vs blob) tracks are much different in this backend. After this patch, both could use `ssh2_pem_parse()` and possibly unify `os400_pub_privkey_file/blob()` and `os400_rsa_new_priv_from_file/blob()`. Follow-up to b560cb4 #2379 Follow-up to 6a95116 #2362 Follow-up to fe9442b #2359 Follow-up to 5b94157 #2354 Closes #2388
vszakats
added a commit
that referenced
this pull request
Jul 22, 2026
…_from_openssh()` Merging `ossl_*_openssh_priv_new()` functions and syncing the result up with `ossl_key_from_openssh()` ends up with an almost identical function (with the newly merged ones supporting filenames, not blobs). Therefore replace these calls with the latter, and drop the redundant code. This also syncs up recognized keys loaded from filenames with those loaded from memory buffers. Also: - sync `ssh2_ed25519_new_priv()` with sibling functions, also merging its file/blob codepaths. It means the filename codepath now uses OpenSSL's built-in loader first, and resorts to libssh2's own loader if OpenSSL's failed. Follow-up to b560cb4 #2379 Follow-up to 3bb068e #2394 Closes #2396
vszakats
added a commit
that referenced
this pull request
Aug 28, 2026
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.
Replace separate codepath for loading private keys from filenames vs.
memory buffers (blobs), with unified functions that handle both. Either
filename or blob pointer + size must be passed to these functions.
To reduce code duplication and small/large differences and bugs between
these codepaths. Also to improve readability and ease maintenance.
Also fix:
mbed_parse_openssh_key()on in ECDSA blob codepath. (benign)Reported-and-alternate-patch-by: Martin Nowak
Fixes ensure to clear openssl3 PEM reading errors #1652
ssh2_sk_pubkey().(not exposed via public API at this time.)
OSSL_INIT_IF_NEEDED()fromssh2_pub_privkey(). (for wolfSSL-debug enabled builds.)ssh2_sk_pubkey().(to be consistent with rest of code.)
ssh2_ed25519_new_priv()blobcodepaths.
(both file and blob) if BIO init failed.
os400_pub_privkey_*().Notes:
They are very different and difficult to read, also not possible to
build test.
is different (both rather short.)
Follow-up to 6a95116 #2362
Follow-up to fe9442b #2359
Follow-up to 5b94157 #2354
https://github.com/libssh2/libssh2/pull/2379/files?w=1