Repository navigation
wincng: fix ECC private key blob allocation size - #2631
Closed
abdul-khaliq-khalid wants to merge 1 commit into
Closed
abdul-khaliq-khalid wants to merge 1 commit into
abdul-khaliq-khalid wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is focused and resolves the incorrect allocation-size calculation.
Review effort: Lite
Findings: None
What changed in this PR
Fixes WinCNG ECC private-key blob sizing to use the correct header size.
Changes:
- Uses
sizeof(BCRYPT_ECCKEY_BLOB)for private-key allocation.
| File | Description |
|---|---|
src/wincng.c |
Corrects ECC private-key blob allocation sizing. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vszakats
approved these changes
Oct 1, 2026
Member
|
Thanks! |
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.
wcng_privatekey_from_point()sizes the ECC private-key blob withsizeof(BCRYPT_ECCPRIVATE_BLOB), but that name is the wide blob-type stringL"ECCPRIVATEBLOB", not a struct, so thesizeofmeasures the string (30 bytes on Windows) rather than the 8-byteBCRYPT_ECCKEY_BLOBheader. The threememcpyoffsets right below it, and the public-key siblingwcng_publickey_from_point(), already usesizeof(BCRYPT_ECCKEY_BLOB), so the buffer ends up oversized and its uninitialized tail is handed toBCryptImportKeyPair()with an inflatedcbInput. This is on the path that loads an OpenSSH-format ECDSA private key throughlibssh2_userauth_publickey_frommemory()/fromfile()on the CNG backend.Using
sizeof(BCRYPT_ECCKEY_BLOB)lines the allocation up with the header the copies actually write from and with the length passed toBCryptImportKeyPair(). Keeping it in step with the public-key path means the private blob is described to CNG with exactly the bytes it holds.Follow-up to 3e72343 #1315