Repository navigation
Conversation
pem.c
There was a problem hiding this comment.
Pull request overview
This pull request refactors WinCNG ECDSA private-key loading to reuse the shared OpenSSH PEM parsing/decryption logic from pem.c, reducing duplication and enabling passphrase-handling via the common parser.
Changes:
- Reworked WinCNG ECDSA key loading to use
ssh2_openssh_pem_parse()/_memory()instead of bespoke parsing paths. - Removed the WinCNG-local PEM loading helper and consolidated parsing responsibilities into the shared PEM module.
- Relocated OpenSSH private key marker macros from
crypto.hintopem.cwhere they’re used.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/wincng.c | Switch ECDSA key loading/parsing to shared OpenSSH PEM parse helpers; removes duplicate parsing code paths. |
| src/pem.c | Adds OpenSSH private key header/footer/auth-magic defines used by OpenSSH PEM parsing. |
| src/crypto.h | Removes OpenSSH private key marker defines that are now local to pem.c. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vszakats
force-pushed
the
wincng-reuse-pem
branch
2 times, most recently
from
July 14, 2026 11:53
473a1f0 to
0f75320
Compare
vszakats
force-pushed
the
wincng-reuse-pem
branch
2 times, most recently
from
July 14, 2026 12:15
4027ae5 to
5b6e9e0
Compare
vszakats
force-pushed
the
wincng-reuse-pem
branch
3 times, most recently
from
July 15, 2026 19:06
ee2fe88 to
f33f4b3
Compare
…te() Also to automagically support passphrased ECDSA keys. wincng.c optimize out wcng_load_pem also reuse pem.c/ssh2_openssh_pem_parse_memory() in ssh2_ecdsa_new_private_frommemory() And unlock passphrased key support. propagate low-level error codes align more with rsa/dsa align name more with rsa/dsa
vszakats
force-pushed
the
wincng-reuse-pem
branch
from
July 17, 2026 14:33
f33f4b3 to
ad333fd
Compare
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.
reuse
pem.c/ssh2_openssh_pem_parse()inssh2_ecdsa_new_private(),replacing the generic PEM parser used prior to this patch.
reuse
pem.c/ssh2_openssh_pem_parse_memory()inssh2_ecdsa_new_private_frommemory().optimize out local
wcng_load_pem().move ECDSA key macros to from
crypto.htopem.c.To avoid code duplication, and also to hopefully enable support for
passphrased OpenSSH-format ECDSA private keys with WinCNG.
Build tested only.
Fixes #1517
Follow-up to 3e72343 #1315
It surpised me why libssh2 has a parallel key-loading implementation
for keys from file and from memory buffers, down to line level. Was
the reason historical, first loading from file, then adding from-memory,
and instead of making the former reuse that code, it just stayed on its
own path? Also why not just load the whole key to memory, then parse
instead of going line-by-line? These files are typically small, and their
size is capped to sane sizes since (maybe not everywhere though and
could maybe be smaller)