1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 19:06:53 +01:00

Huami/Xiaomi: Log session keys

It's otherwise impossible to troubleshoot issues from the logs, since
the communication is encrypted.
This commit is contained in:
José Rebelo 2024-08-01 22:52:54 +01:00
parent b242ad1ec5
commit 29f57758fa
2 changed files with 5 additions and 9 deletions

View File

@ -159,9 +159,7 @@ public class InitOperation2021 extends InitOperation implements Huami2021Handler
finalSharedSessionAES[i] = (byte) (sharedEC[i + 8] ^ secretKey[i]); 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); huami2021ChunkedEncoder.setEncryptionParameters(encryptedSequenceNumber, finalSharedSessionAES);
huami2021ChunkedDecoder.setEncryptionParameters(finalSharedSessionAES); huami2021ChunkedDecoder.setEncryptionParameters(finalSharedSessionAES);

View File

@ -195,12 +195,10 @@ public class XiaomiAuthService extends AbstractXiaomiService {
System.arraycopy(step2hmac, 32, decryptionNonce, 0, 4); System.arraycopy(step2hmac, 32, decryptionNonce, 0, 4);
System.arraycopy(step2hmac, 36, encryptionNonce, 0, 4); System.arraycopy(step2hmac, 36, encryptionNonce, 0, 4);
if (BuildConfig.DEBUG) {
LOG.debug("decryptionKey: {}", GB.hexdump(decryptionKey)); LOG.debug("decryptionKey: {}", GB.hexdump(decryptionKey));
LOG.debug("encryptionKey: {}", GB.hexdump(encryptionKey)); LOG.debug("encryptionKey: {}", GB.hexdump(encryptionKey));
LOG.debug("decryptionNonce: {}", GB.hexdump(decryptionNonce)); LOG.debug("decryptionNonce: {}", GB.hexdump(decryptionNonce));
LOG.debug("encryptionNonce: {}", GB.hexdump(encryptionNonce)); LOG.debug("encryptionNonce: {}", GB.hexdump(encryptionNonce));
}
final byte[] decryptionConfirmation = hmacSHA256(decryptionKey, ArrayUtils.addAll(watchNonce.getNonce().toByteArray(), nonce)); final byte[] decryptionConfirmation = hmacSHA256(decryptionKey, ArrayUtils.addAll(watchNonce.getNonce().toByteArray(), nonce));
if (!Arrays.equals(decryptionConfirmation, watchNonce.getHmac().toByteArray())) { if (!Arrays.equals(decryptionConfirmation, watchNonce.getHmac().toByteArray())) {