mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
huawei: Handle version 4 digest for Honor Watch 4
* on huawei devices authVersion == 4 means using hichain, but honor still using simple challenge response and actually using V1 digest key
This commit is contained in:
committed by
José Rebelo
parent
1ce16380b8
commit
2538a6e9d3
+7
-2
@@ -77,6 +77,7 @@ public class HuaweiCrypto {
|
|||||||
|
|
||||||
public static final byte[] MESSAGE_RESPONSE = new byte[]{0x01, 0x10};
|
public static final byte[] MESSAGE_RESPONSE = new byte[]{0x01, 0x10};
|
||||||
public static final byte[] MESSAGE_CHALLENGE = new byte[]{0x01, 0x00};
|
public static final byte[] MESSAGE_CHALLENGE = new byte[]{0x01, 0x00};
|
||||||
|
public static final byte[] MESSAGE_CHALLENGE_V4 = new byte[]{0x04, 0x00};
|
||||||
|
|
||||||
public static final long ENCRYPTION_COUNTER_MAX = 0xFFFFFFFF;
|
public static final long ENCRYPTION_COUNTER_MAX = 0xFFFFFFFF;
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ public class HuaweiCrypto {
|
|||||||
|
|
||||||
private byte[] getDigestSecret() {
|
private byte[] getDigestSecret() {
|
||||||
byte[] digest;
|
byte[] digest;
|
||||||
if (authVersion == 1) {
|
if ((authVersion == 1) || (authVersion == 4)) { //version 4 digest used on honor health devices
|
||||||
digest = DIGEST_SECRET_v1.clone();
|
digest = DIGEST_SECRET_v1.clone();
|
||||||
} else if (authVersion == 2) {
|
} else if (authVersion == 2) {
|
||||||
digest = DIGEST_SECRET_v2.clone();
|
digest = DIGEST_SECRET_v2.clone();
|
||||||
@@ -168,7 +169,11 @@ public class HuaweiCrypto {
|
|||||||
}
|
}
|
||||||
return computeDigestHiChainLite(MESSAGE_CHALLENGE, secretKey, nonce);
|
return computeDigestHiChainLite(MESSAGE_CHALLENGE, secretKey, nonce);
|
||||||
}
|
}
|
||||||
return computeDigest(MESSAGE_CHALLENGE, nonce);
|
if (authVersion == 4) {
|
||||||
|
return computeDigest(MESSAGE_CHALLENGE_V4, nonce);
|
||||||
|
} else {
|
||||||
|
return computeDigest(MESSAGE_CHALLENGE, nonce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] digestResponse(byte[] secretKey, byte[] nonce) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, UnsupportedEncodingException {
|
public byte[] digestResponse(byte[] secretKey, byte[] nonce) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, UnsupportedEncodingException {
|
||||||
|
|||||||
Reference in New Issue
Block a user