Skip to content

fix(planet): pad ephemeral P-256 private key to 32 bytes - #260

Merged
nakasyou merged 1 commit into
mainfrom
fix/ci-planet-transport-test
Nov 4, 2026
Merged

nakasyou merged 1 commit into
mainfrom
fix/ci-planet-transport-test

Conversation

@nakasyou

@nakasyou nakasyou commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

概要

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)。

変更

  • 生成した秘密鍵を 32 バイトへ左ゼロパディング
  • crypto.test.ts に、4,096 個の鍵で秘密鍵が常に 32 バイト・公開鍵が 33 バイトであることを確認する回帰テストを追加

確認

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.
Copilot AI balanced review requested due to automatic review settings November 4, 2026 23:41

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.

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.

@nakasyou
nakasyou merged commit 7815b7a into main Nov 4, 2026
2 checks passed
@nakasyou
nakasyou deleted the fix/ci-planet-transport-test branch November 4, 2026 23:43
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)
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.

2 participants