Extend tests and fix payload parsing

This commit enhances the test coverage for `AirPodsProTest` by:
- Verifying the hex representation of the public payload data.
- Confirming that the private payload is null when no IRK/EncKey is set.
- Verifying the hex representation of the private payload data when IRK/EncKey are set.

Additionally, a fix is introduced in `AppleFactory.kt` to correctly parse the public payload by taking only the first 9 bytes instead of 16. This ensures that the private payload is only processed if the incoming message length matches the expected `PAIRING_MESSAGE_LENGTH`.
This commit is contained in:
darken
2025-06-06 06:03:41 +02:00
committed by Matthias Urhahn
parent e9b29a2a43
commit cda16ca06a
2 changed files with 9 additions and 1 deletions
@@ -65,10 +65,11 @@ class AppleFactory @Inject constructor(
val payload = ProximityPayload(
public = ProximityPayload.Public(
proximityMessage.data.take(16).toUByteArray()
proximityMessage.data.take(9).toUByteArray()
),
private = run {
if (!isIrkMatch) return@run null
if (proximityMessage.data.size != ProximityPairing.PAIRING_MESSAGE_LENGTH) return@run null
val encKey = generalSettings.mainDeviceEncryptionKey.value
if (encKey == null) return@run null