fix: correct KEM output truncation and EVP_PKEY_paramgen double-free - #50
Merged
Merged
Conversation
tofay
force-pushed
the
kem-output-truncation
branch
2 times, most recently
from
September 27, 2026 21:31
41a87f0 to
24e83c7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
==========================================
- Coverage 81.49% 81.32% -0.17%
==========================================
Files 21 21
Lines 1967 1971 +4
==========================================
Hits 1603 1603
- Misses 364 368 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
tofay
force-pushed
the
kem-output-truncation
branch
from
September 27, 2026 21:34
24e83c7 to
a714bf6
Compare
Two bug fixes in the KEM implementation: 1. Truncation: encapsulate_to_vec and decapsulate_to_vec now truncate their output buffers to the actual written length. A short write would otherwise leave trailing zeros in the shared secret, which is a key agreement that silently disagrees with the peer. 2. Double-free: from_encoded_public_key no longer passes a pre-allocated EVP_PKEY to EVP_PKEY_paramgen. The function frees the passed pointer on failure, leaving a dangling pointer that is then freed again on the error path. Now passes NULL and lets paramgen allocate.
tofay
force-pushed
the
kem-output-truncation
branch
from
September 27, 2026 21:38
a714bf6 to
d4bc793
Compare
tofay
marked this pull request as ready for review
September 27, 2026 21:43
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.
Two bug fixes in the KEM implementation:
Truncation: encapsulate_to_vec and decapsulate_to_vec now truncate their output buffers to the actual written length. A short write would otherwise leave trailing zeros in the shared secret, which is a key agreement that silently disagrees with the peer.
Double-free: from_encoded_public_key no longer passes a pre-allocated EVP_PKEY to EVP_PKEY_paramgen. The function frees the passed pointer on failure, leaving a dangling pointer that is then freed again on the error path. Now passes NULL and lets paramgen allocate.