RSA1_5: pass the expected CEK size as a parameter instead of the hardcoded CEK_LENGTHS table

オープン
#653 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Spomky がすでに取り組んでいます。

2026年8月28日 から。

評価

この issue はまだ評価されていません。

説明

enhancement

Context

The RSA1_5 implicit-rejection fix (GHSA-5739-39v2-5754) needs the expected CEK length to build a constant-time random fallback. It currently relies on a hardcoded lookup table in RSA15:

private const CEK_LENGTHS = [
    'A128GCM' => 16, 'A192GCM' => 24, 'A256GCM' => 32,
    'A128CBC-HS256' => 32, 'A192CBC-HS384' => 48, 'A256CBC-HS512' => 64,
];

Problem (SOLID)

This violates SRP/DRY/OCP: RSA15 (a key-encryption algorithm) should not know the CEK sizes of the content-encryption algorithms. The single source of truth is already ContentEncryptionAlgorithm::getCEKSize(). A custom/unknown enc is not in the table, so it falls back to the legacy throwing path (no implicit rejection for that case).

This table was kept deliberately on the maintenance branches (3.4.x / 4.x) to avoid a public BC break, since fixing it properly changes the KeyEncryption::decryptKey() / KeyWrapping::unwrapKey() signatures.

Action for the next major (5.0.0)

Inject the expected CEK size through the interface, exactly as already done for KeyAgreement / KeyAgreementWithKeyWrapping in JWEDecrypter::decryptCEK (which already passes $content_encryption_algorithm->getCEKSize()):

  • add an expected-size parameter to KeyEncryption::decryptKey() (and KeyWrapping::unwrapKey()),
  • have JWEDecrypter pass $content_encryption_algorithm->getCEKSize(),
  • forward it through RSA / RSA15 to RSACrypt::decrypt(),
  • delete the CEK_LENGTHS table.

This is a public BC break, hence scheduled for 5.0.0.

主要言語
PHP
スター
954
フォーク
119
平均マージ
48分
マージ済み PR(30日)
17

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

web-token/jwt-framework のほかの issue

web-token/jwt-framework の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。