Repository navigation
fix(planet): pad ephemeral P-256 private key to 32 bytes - #260
Merged
Merged
Conversation
OpenSSL serialises an EC private scalar without leading zero bytes, so generateEphemeralKeypair() could return a 31-byte key. derivePlanetMediaKeys() rejects anything but 32 bytes, which made the PLANET transport test fail intermittently (and would break real media setup on those keys). Left-pad the scalar to its fixed width and add a regression test that samples enough keypairs to hit the short-key case reliably.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
frankekn
pushed a commit
to frankekn/linejs
that referenced
this pull request
Nov 9, 2026
OpenSSL serialises an EC private scalar without leading zero bytes, so generateEphemeralKeypair() could return a 31-byte key. derivePlanetMediaKeys() rejects anything but 32 bytes, which made the PLANET transport test fail intermittently (and would break real media setup on those keys). Left-pad the scalar to its fixed width and add a regression test that samples enough keypairs to hit the short-key case reliably. Co-authored-by: nakasyou <nakasyou@users.noreply.github.com> (cherry picked from commit 7815b7a)
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.
概要
generateEphemeralKeypair()が OpenSSL の P-256 秘密鍵をそのまま返していたため、先頭ゼロバイトが落ちて約 0.4% の確率で 31 バイトの秘密鍵が生成されていました。derivePlanetMediaKeys()は 32 バイトを必須としているため、その場合のみlocal private key must be 32 bytesで失敗し、PlanetTransport learns RTP source and sends decryptable SRTP mediaが不定期に落ちていました (main の CI 失敗: https://github.com/evex-dev/linejs/actions/runs/41862442685)。変更
crypto.test.tsに、4,096 個の鍵で秘密鍵が常に 32 バイト・公開鍵が 33 バイトであることを確認する回帰テストを追加確認