Skip to content

CCM: harden DeclarePayloadLength (follow-up to #106) - #107

Merged
MHumm merged 1 commit into
MHumm:developmentfrom
omonien:cursor/ccm-declare-payload-length-201b
Sep 18, 2026
Merged

MHumm merged 1 commit into
MHumm:developmentfrom
omonien:cursor/ccm-declare-payload-length-201b

Conversation

@omonien

@omonien omonien commented Sep 18, 2026

Copy link
Copy Markdown

Follow-up to #106 — Markus’ consistency point on DeclarePayloadLength.

Change

TCCM.DeclarePayloadLength no longer silently ignores illegal calls:

  1. After Done → still raises via CheckNotFinalized
  2. Same length again → idempotent (allowed)
  3. Different length → EDECCipherException (sCCMPayloadLengthAlreadyDeclared)
  4. After Encode/Decode has started → EDECCipherException (sCCMPayloadLengthLocked)
  5. Otherwise set length as before

Also: EncodeStream only auto-declares length when none is set yet, so multi-chunk streams that already set AuthenticatedPayloadLength keep working with the stricter rules.

SupportsMultiChunk stays a Boolean (no capability set yet).

Tests

TestDECCipherModesCCM.pas: same length, different length, after Encode, after Decode, after Done.

No Delphi compiler in this agent environment — changes follow existing exception/CreateRes patterns in the unit.

Make TCCM.DeclarePayloadLength fail hard after start or when a different
length is declared, while still allowing an idempotent re-declare of the
same length. EncodeStream only auto-declares when no length is set yet so
multi-chunk streams keep working.

Follow-up to MHumm#106.

Co-authored-by: Olaf Monien <omonien@users.noreply.github.com>
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.

3 participants