Repository navigation
Conversation
Follow-up to b101ce0 libssh2#1878 Follow-up to 5528f3d libssh2#385 Follow-up to a19d853 libssh2#359
There was a problem hiding this comment.
Pull request overview
This PR updates the mbedTLS backend’s ECDSA private-key loader to ensure the file buffer is NUL-terminated (and the passed length includes that terminator) so it satisfies mbedtls_pk_parse_key()’s input requirements.
Changes:
- Allocate
data_len + 1bytes when reading an ECDSA private key file. - Append a NUL terminator at
data[data_len]. - Call
mbed_parse_eckey()withdata_len + 1.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| if(mbed_parse_eckey(ec_ctx, &pkey, data, data_len, passphrase) == 0) | ||
| data[data_len] = 0; /* for mbedtls_pk_parse_key() */ | ||
| if(mbed_parse_eckey(ec_ctx, &pkey, data, data_len + 1, passphrase) == 0) |
Member
Author
There was a problem hiding this comment.
Yes, lots of key formats are not tested. I'd be surprised if all combinations would be supported universally (and work as expected). Also the way they are tested ATM do not scale (separate test app binary for each format!).
ssh2_ecdsa_new_private()ssh2_ecdsa_new_private() for PEM-formatted keys
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.
When loading ECDSA key from an EC/PEM-formatted private key file, as
required by
mbedtls_pk_parse_key().Follow-up to b101ce0 #1878