DecodeBytes decodes in place and overwrites the caller's ciphertext (non-GCM modes)
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- cryptography, testing
調査の方向性
TDECFormattedCipher.DecodeBytes から始めてください。ここでは Result := Source により両方の配列がメモリを共有しています。SetLength を呼んでいるのは cmGCM の分岐だけなので、すべてのモードで Decode の前に入力を Result にコピーしてください。副次的な修正は TestTFormat_UU.TestIsValidTypeless にあり、@SrcBuf を @SrcBuf[0] に変更する必要があります。すべてのモードでデコード後も呼び出し元の入力配列が変わらず、テストが Win64 で成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
TDECFormattedCipher.DecodeBytes overwrites the caller's input array for every mode except GCM.
Cause
DecodeBytes starts with Result := Source. For dynamic arrays this only copies the reference, so Result and Source point to the same memory. Only for cmGCM is SetLength(Result, Length(Source)) called, which creates a separate copy. For all other modes Decode(Source[0], Result[0], ...) writes the plaintext straight into the caller's array.
Effect
After Plain := Cipher.DecodeBytes(CipherText), CipherText contains the plaintext too. Code that decodes the same buffer twice, or keeps the ciphertext for later use (logging, retry, comparing), silently works on wrong data.
Repro
Cipher := TCipher_Twofish.Create;
Cipher.Mode := cmCBCx;
Cipher.Init(Key, IV, $FF);
Original := Copy(Source);
Plain := Cipher.DecodeBytes(Source);
// Source is now equal to Plain instead of Original
I came across this in the ChaCha20 speed tests on development_chacha20poly1305, which decode the same buffer once per CPU mode. Every decode after the first one failed.
Side note
TestTFormat_UU.TestIsValidTypeless fails now and then on Win64. It uses p := @SrcBuf, which points at the array variable instead of the data, so IsValid checks the bytes of a heap pointer. It should be @SrcBuf[0]. I fix that in the same PR.
- 主要言語
- HTML
- スター
- 286
- フォーク
- 78
- 平均マージ
- 1日 23分
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MHumm/DelphiEncryptionCompendium のほかの issue
-
CRC64 - PKI Addition再び着手できるかも @MHumm が 152 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement help wanted
MHumm/DelphiEncryptionCompendium#93 · コメント 1 件 · 担当者 1 名 ·
-
Missing PUInt8Array type in the GetIt version.再び着手できるかも @MHumm が 163 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug delphi
MHumm/DelphiEncryptionCompendium#92 · コメント 2 件 · 担当者 1 名 ·
-
Confused by NEXTGEN directive再び着手できるかも @MHumm が 534 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
MHumm/DelphiEncryptionCompendium#88 · コメント 8 件 · 担当者 1 名 ·
-
Authenticated tag is wrong on streams再び着手できるかも @MHumm が 544 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンbug
MHumm/DelphiEncryptionCompendium#87 · コメント 20 件 · 担当者 1 名 ·
-
Support for AEGIS 256再び着手できるかも @MHumm が 855 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement help wanted
MHumm/DelphiEncryptionCompendium#77 · コメント 3 件 · リアクション 1 件 · 担当者 1 名 ·
MHumm/DelphiEncryptionCompendium の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
btclib-org/btclib#2717 ·
メンテナーはふだん 1 日以内に返信
-
founders_reward panics on a configured Testnet when the slow-start subsidy is not a multiple of 5対応中かも @Steeve-Crypto が今日担当しました。 オープンexternal-contribution
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ZcashFoundation/zebra#11792 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spesmilo/electrum#11054 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
RustCrypto/formats#2482 ·
メンテナーはふだん 1 日以内に返信