[Cryptographic_Clang] Fix lost borrow in bignum_subtract when a limb is 0xFFFFFFFF

オープン 初心者向け
#417 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
79/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp
領域
cryptography

調査の方向性

Security_Algorithms/Cryptographic_Clang/bignum.cを読み、bignum_subtractと、各limbの差および借りをどのように計算するかに注目してください。limbに0xFFFFFFFFを含むオペランドで不具合を再現し、その後、issueに記載されたランダムな恒等性チェックとPythonによる差分チェックを実行してください。両方のチェックが誤った減算なしで成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area: security-algorithms priority: P1 size: XS type: bug

Summary

bignum_subtract computes the borrow from temp = carry + b2->data[i] in 32 bits. When the incoming borrow is 1 and the limb of b2 is 0xFFFFFFFF, temp wraps to 0, the limb difference is computed against 0 and the borrow is lost. RSA key generation uses subtraction (p - 1, q - 1), so wrong results can propagate into phi.

Location

  • Security_Algorithms/Cryptographic_Clang/bignum.c (bignum_subtract)

Evidence

Differential test against Python integers, 3,000 random operands biased towards 0xFFFFFFFF limbs: 379 subtractions wrong. Found while fixing #136 and #137.

Expected

(a + b) - b == a for all operands with a >= b.

Proposed fix

Accumulate the subtrahend limb plus borrow in 64 bits and derive the borrow from that comparison.

Acceptance criteria

  • Random identity test (a + b) - b == a passes for 20,000 operands
  • Differential test against Python reports no wrong subtraction

Found while fixing the bignum issues · Phase 3 · Build & correctness


Generated by Claude Code

主要言語
C++
スター
2
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

ibra-kdbra/Math-Problems のほかの issue

ibra-kdbra/Math-Problems の issue をすべて見る

似ている issue

C++ の issue をもっと見る

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

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