Skip to content

mbedtls: stop using mbedtls_pk_load_file() - #1878

Closed
vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:cq2
Closed

vszakats wants to merge 2 commits into
libssh2:masterfrom
vszakats:cq2

Conversation

@vszakats

@vszakats vszakats commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

This mbedTLS API is no longer exported by mbedTLS 3.6.0+. Replace with
local implementation.

Limit size of loaded keys to 1 MiB.

Follow-up to 1628f6c #1421
Follow-up to e973493 #1393
Follow-up to 2e4c5ec #1349

This mbedTLS API is no longer exported by mbedTLS 3.6.0+. Replace with
local implementation.

Follow-up to 1628f6c libssh2#1421
Follow-up to e973493 libssh2#1393
Follow-up to 2e4c5ec libssh2#1349
@vszakats
vszakats requested a review from Copilot April 23, 2026 18:55

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

Note

Copilot was unable to run its full agentic suite in this review.

Replaces usage of the now-unexported mbedtls_pk_load_file() (mbedTLS 3.6.0+) with a local file-loading implementation for ECDSA private keys.

Changes:

  • Removed the forward declaration used to force-expose the internal mbedtls_pk_load_file().
  • Implemented manual key file reading via fopen/fseek/ftell/fread.
  • Updated cleanup to explicitly zero and free the loaded key buffer.

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

Comment thread src/mbedtls.c Resolved
Comment thread src/mbedtls.c Resolved
@willco007

Copy link
Copy Markdown
Member

@vszakats A max file length check should also be added to _libssh2_pem_parse() if you have a moment, thanks!

vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 23, 2026
Limit size of loaded keys to 1 MiB.

Ref: libssh2#1878 (comment)
Suggested-by: Will Cosgrove

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 no new comments.


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

@vszakats vszakats closed this in b101ce0 Apr 24, 2026
@vszakats
vszakats deleted the cq2 branch April 24, 2026 07:29
vszakats added a commit to vszakats/libssh2 that referenced this pull request Apr 24, 2026
Limit size of loaded keys to 1 MiB.

Ref: libssh2#1878 (comment)
Suggested-by: Will Cosgrove
vszakats added a commit that referenced this pull request Apr 24, 2026
Limit size of loaded keys to 1 MiB.

Ref: #1878 (comment)
Suggested-by: Will Cosgrove

Closes #1880
vszakats added a commit that referenced this pull request Jul 12, 2026
…ormatted keys

When loading ECDSA key from an EC/PEM-formatted private key file, as
required by `mbedtls_pk_parse_key()`.

Follow-up to b101ce0 #1878

Closes #2275
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.

3 participants