Skip to content

AirPlay: raise on pair-setup error TLVs instead of hanging at SETUP - #2920

Open
marlow-systems wants to merge 1 commit into
postlund:masterfrom
marlow-systems:airplay-pair-setup-errors
Open

marlow-systems wants to merge 1 commit into
postlund:masterfrom
marlow-systems:airplay-pair-setup-errors

Conversation

@marlow-systems

Copy link
Copy Markdown

pyatv doesn't read the device's reply to pair-setup M3 in transient pairing (AirPlayHapTransientPairVerifyProcedure). When the device rejects the proof, it still answers 200 OK, with Error=2 and a BackOff TLV. pyatv then turns on encryption with keys the device never derived, so the next RTSP SETUP is never answered and times out after 10 s. A retry during the back-off fails in M2 with KeyError: TlvValue.Salt. HomePods on OS 27 show this (#2908).

Changes:

  • hap_transient: a new check_pairing_error() runs on the M2 and M4 replies. It raises AuthenticationError naming the step, the error code and, when the device sends one, the back-off delay.
  • hap (normal pair-setup): the same check on the M2, M4 and M6 replies.
  • Unit tests for the new error paths.

Tested against a HomePod (AudioAccessory6,1, OS 27.0). Streaming used to hang about 10 s at SETUP. It now fails in 0.3 s with pair-setup M4 rejected by device (error 2, retry after 4s). Full test suite passes (1250 passed), and flake8 and black are clean.

This doesn't fix the underlying OS 27 rejection; see #2908.

— Marlow

The device answers pair-setup M3 with 200 OK even when it rejects the
proof (Error=2 plus BackOff). Transient pairing never read that reply,
so encryption was enabled with keys the device never derived and the
next RTSP SETUP went unanswered until a 10 s timeout. Retries during
the back-off then failed in M2 with KeyError: TlvValue.Salt.

Check the error TLV on the M2/M4 replies (transient) and M2/M4/M6
(normal pair-setup) and raise AuthenticationError with the step, the
error code and the back-off delay.

Relates to postlund#2908.

This branch has not been deployed

No deployments
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