From 29f57758fae45e17cb8176278fa893d1372cf6a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 1 Aug 2024 22:52:54 +0100 Subject: [PATCH] Huami/Xiaomi: Log session keys It's otherwise impossible to troubleshoot issues from the logs, since the communication is encrypted. --- .../huami/operations/init/InitOperation2021.java | 4 +--- .../service/devices/xiaomi/XiaomiAuthService.java | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/init/InitOperation2021.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/init/InitOperation2021.java index c6fc41f55..771d0f998 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/init/InitOperation2021.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/init/InitOperation2021.java @@ -159,9 +159,7 @@ public class InitOperation2021 extends InitOperation implements Huami2021Handler finalSharedSessionAES[i] = (byte) (sharedEC[i + 8] ^ secretKey[i]); } - if (BuildConfig.DEBUG) { - LOG.debug("Shared Session Key: {}", GB.hexdump(finalSharedSessionAES)); - } + LOG.debug("Shared Session Key: {}", GB.hexdump(finalSharedSessionAES)); huami2021ChunkedEncoder.setEncryptionParameters(encryptedSequenceNumber, finalSharedSessionAES); huami2021ChunkedDecoder.setEncryptionParameters(finalSharedSessionAES); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiAuthService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiAuthService.java index c1e2971aa..f107cf713 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiAuthService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/xiaomi/XiaomiAuthService.java @@ -195,12 +195,10 @@ public class XiaomiAuthService extends AbstractXiaomiService { System.arraycopy(step2hmac, 32, decryptionNonce, 0, 4); System.arraycopy(step2hmac, 36, encryptionNonce, 0, 4); - if (BuildConfig.DEBUG) { - LOG.debug("decryptionKey: {}", GB.hexdump(decryptionKey)); - LOG.debug("encryptionKey: {}", GB.hexdump(encryptionKey)); - LOG.debug("decryptionNonce: {}", GB.hexdump(decryptionNonce)); - LOG.debug("encryptionNonce: {}", GB.hexdump(encryptionNonce)); - } + LOG.debug("decryptionKey: {}", GB.hexdump(decryptionKey)); + LOG.debug("encryptionKey: {}", GB.hexdump(encryptionKey)); + LOG.debug("decryptionNonce: {}", GB.hexdump(decryptionNonce)); + LOG.debug("encryptionNonce: {}", GB.hexdump(encryptionNonce)); final byte[] decryptionConfirmation = hmacSHA256(decryptionKey, ArrayUtils.addAll(watchNonce.getNonce().toByteArray(), nonce)); if (!Arrays.equals(decryptionConfirmation, watchNonce.getHmac().toByteArray())) {