Skip to content

openssl: merge ossl_key_from_openssh_*() file/blob functions - #2394

Closed
vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:pemmerge3
Closed

vszakats wants to merge 1 commit into
libssh2:masterfrom
vszakats:pemmerge3

Conversation

@vszakats

Copy link
Copy Markdown
Member

Follow-up to 7bf902e #2388
Follow-up to b560cb4 #2379
Follow-up to 5b94157 #2354

Copilot AI review requested due to automatic review settings July 22, 2026 14:01

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.

Pull request overview

This PR continues the ongoing effort to unify “from file” vs “from blob” key-loading behavior in the OpenSSL backend by merging the OpenSSH key parsing helpers into a single shared function.

Changes:

  • Replace separate ossl_key_from_openssh_file() / ossl_key_from_openssh_blob() helpers with a unified ossl_key_from_openssh() that accepts either a filename or a memory blob.
  • Update RSA/DSA/ED25519/ECDSA private-key loaders to call the unified helper for OpenSSH-format fallbacks.
  • Simplify ssh2_pub_privkey() OpenSSH fallback to use the unified helper regardless of file vs blob input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/openssl.c Outdated
Comment on lines +1664 to +1666
rc = ossl_key_from_openssh(session, (void **)dsa, "ssh-dsa",
NULL, NULL, NULL,
NULL, blob, blob_len, passphrase);

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 #2395

vszakats added a commit that referenced this pull request Jul 22, 2026
@vszakats vszakats changed the title openssl: merge `ossl_key_from_openssh_*() file/blob functions openssl: merge ossl_key_from_openssh_*() file/blob functions Jul 22, 2026
Copilot AI review requested due to automatic review settings July 22, 2026 14:32

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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/openssl.c
Comment on lines +3068 to +3070
rc = ossl_key_from_openssh(session, (void **)ec_ctx, "ssh-ecdsa",
NULL, NULL, NULL,
NULL, blob, blob_len, passphrase);

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.

One more pre-existing SK issue.

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 don' know..... the whole SK-thing seems broken to me, possibly except maybe some happy path that works.
In this case it breaks non-SK workflows if I understand correctly. It's a mess.

@vszakats vszakats closed this in 3bb068e Jul 22, 2026
@vszakats
vszakats deleted the pemmerge3 branch July 22, 2026 14:50
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
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