Skip to content

Stop logging pairing secrets; fix frame splitting in LengthPrefixedByteArrayProcessor - #204

Merged
yfre merged 2 commits into
masterfrom
claude/beautiful-ritchie-89e405
Oct 18, 2026
Merged

yfre merged 2 commits into
masterfrom
claude/beautiful-ritchie-89e405

Conversation

@yfre

@yfre yfre commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Two small fixes, one commit each. They don't change behavior for setups that already work.

1. Stop logging pairing secrets (ExchangeHandler)

Removes the four DEBUG log statements that printed the SRP shared secret K, the HKDF-derived encryption key and the raw M5 auth tag and message data. No logic changes.

2. Fix frame splitting (LengthPrefixedByteArrayProcessor)

The change is three lines:

  • The fast path read each frame's length from data[0]/data[1] instead of data[pos]/data[pos + 1]. When several frames of different lengths arrive in one read, every frame was split using the length of the first one.
  • The stored first length byte (firstLengthByteBuffer) was never cleared, and the fast path could run while it was pending. It is now cleared once used, and the fast path is skipped while it is set, so the stored byte always goes through step().

New tests in LengthPrefixedByteArrayProcessorTest:

Test Before After
single frame in one read pass pass
1024 + 1024 + 200 byte frames in one read pass pass
one frame split across two reads (offsets 1, 2, 3, 10, 18, 19, 20, 500, 1041) pass pass
split frame, with the next frame in the second read pass pass
5-byte frame then 100-byte frame in one read fail: [21,21,21,21,21,21] pass: [21,116]
first length byte alone, then the rest + a 40-byte frame fail: [21] pass: [21,56]

mvn -B package on JDK 11: 21 tests, 0 failures.

Not addressed here

  • A read that ends exactly after the 2-byte header leaves buffer empty. The next read can then take the fast path and read the first two payload bytes as a length. With encrypted data this is rare.
  • PairSetupRequest still DEBUG-logs the encrypted M5 data and auth tag.

Before release

Not yet tested with a real device. Smoke-test with a real iPhone or Home hub: pair, control an accessory, check that events arrive, and reconnect.

🤖 Generated with Claude Code

udaw and others added 2 commits October 18, 2026 22:31
Remove DEBUG log statements that printed the SRP shared secret K, the
HKDF-derived encryption key and the raw M5 auth tag / message data.
No logic changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Read the length of each frame at the current position instead of
  always at the start of the read, so several frames of different length
  in one read are split correctly.
- Clear the stored first length byte once it has been used, and do not
  take the fast path while such a byte is pending, so a read that ends
  after the first length byte is handled by step().

Adds tests that lock in the existing behaviour (single frame, several
frames in one read, a frame split across two reads) plus regression tests
for the two cases above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yfre
yfre merged commit 9c5bc6f into master Oct 18, 2026
1 check passed
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.

1 participant