AEAD architecture: FAuthObj + multi-call GCM (split from PR #90 concern A) - #5
AEAD architecture: FAuthObj + multi-call GCM (split from PR #90 concern A)#5omonien wants to merge 2 commits into
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 47c7463. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
🤖 Augment PR SummarySummary: Refactors AEAD handling to use a single authenticated-mode object and adds correct multi-call (streaming) GCM finalization semantics. Changes:
Technical Notes: Callers must call 🤖 Was this summary useful? React with 👍 or 👎 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…m#99) Extract Concern A from the ChaCha PR MHumm#90 donor without ChaCha/Poly1305. - Polymorphic FAuthObj replaces dual FGCM/FCCM fields; public IDECAuthenticatedCipher unchanged - Keep EncodeGCM/DecodeGCM/EncodeCCM/DecodeCCM as protected wrappers (no rename break) - GCM multi-call: absorb PR MHumm#99 streaming (GHASH partial + CTR keystream remainder + Done/FFinalized) - Reject PR MHumm#90 fIsLastBlock CTR model (incorrect for unaligned multi-chunk) - Base Done virtual (no-op for CCM one-shot); TDECCipherModes.Done finalizes then verifies ExpectedTag - InitMode always FreeAndNil(FAuthObj) before recreate (leak fix) - Multi-chunk and Done-lifecycle unit tests; corrected large GCM rsp tag See Docs/plans/2026-07-25-aead-architecture.md.
47c7463 to
58b54d1CompareReject DataToAuthenticate after GHASH has absorbed AAD or after Done; cap AuthenticationTagBitLength at 128 bits with a defensive tag copy; keep EncodeCCM/DecodeCCM as independent protected entry points that call FAuthObj directly so EncodeGCM overrides no longer affect CCM.
omonien
commented
Jul 27, 2026
Addressed 2026-07-27 (fork cleanup pass)Linear stack restored (
Tests (D13 Win32 Console): GCM 21/21, ChaCha20Poly1305 12/12, AESNI 7/7. Pre-existing Keccak reds only. |

AEAD architecture (PR MHumm#90 Concern A only)
Package A from the cleanup roadmap: architecture for authenticated modes, without ChaCha/Poly1305.
Donor: PR #90. GCM multi-call correctness matches PR MHumm#99 semantics (absorbed).
What changed
FAuthObj: TAuthenticatedCipherModesBaseinstead of dualFGCM/FCCMIDECAuthenticatedCipherunchangedEncodeGCM/DecodeGCM/EncodeCCM/DecodeCCMkept as wrappersDoneInit → Encode/Decode* → Done → read tag; Done idempotent; post-Done Encode/Decode raiseTDECCipherModes.DoneNot in this PR
cmPoly1305/ SIMD / AES-NIfIsLastBlockCTR model (rejected)Behaviour note
Call
Donebefore readingCalculatedAuthenticationResultfor multi-call GCM.Tests (Delphi 13 Win32 Console DUnit)
Design notes:
Docs/plans/2026-07-25-aead-architecture.mdThis branch lives on the fork so it can be opened against upstream
MHumm/developmentwhen ready.Note
High Risk
Changes core GCM/AEAD lifecycle (tag only valid after Done) and streaming crypto state; callers that read the tag or stream chunks without Done may break despite preserved public API names.
Overview
This PR refactors authenticated cipher modes around a single
FAuthObj(TAuthenticatedCipherModesBase) instead of separateFGCM/FCCM, while keepingIDECAuthenticatedCipherand the protectedEncodeGCM/DecodeGCM/EncodeCCM/DecodeCCMentry points as dispatch wrappers.GCM no longer computes the tag inside each
Encode/Decode. It now maintains streaming GHASH state (partial blocks, ciphertext length) and CTR keystream remainder across calls, materializesCalculatedAuthenticationTaginDone, blocks furtherEncode/Decodeafter finalize, and rejects late AAD or tag bit lengths above 128.TDECCipherModes.DonecallsFAuthObj.Donebefore the expected-tag check;InitModealways frees the previous auth object on mode change.The AEAD base gains a virtual
Done,SetDataToAuthenticate, and documented multi-call lifecycle. Tests add multi-chunk GCM vectors,Donelifecycle cases, and fix the large 256-bit-key GCM vector tag in test data.Reviewed by Cursor Bugbot for commit 713a102. Bugbot is set up for automated code reviews on this repo. Configure here.