mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-09 03:37:03 +01:00
[Huawei] Add hichainlite related parsing code
This commit is contained in:
parent
676678defb
commit
a994603389
@ -234,9 +234,10 @@ public class HuaweiCrypto {
|
||||
return CryptoUtils.encryptAES_CBC_Pad(data, encryptionKey, iv);
|
||||
}
|
||||
|
||||
public byte[] decryptBondingKey(byte[] data, String mac, byte[] iv) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException, IllegalArgumentException {
|
||||
byte[] encryptionKey = createSecretKey(mac);
|
||||
return CryptoUtils.decryptAES_CBC_Pad(data, encryptionKey, iv);
|
||||
public byte[] decryptBondingKey(byte encryptMethod, byte[] data, byte[] key, byte[] iv) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, InvalidKeyException, IllegalArgumentException {
|
||||
if (encryptMethod == 0x1)
|
||||
return CryptoUtils.decryptAES_GCM_NoPad(data, key, iv, null);
|
||||
return CryptoUtils.decryptAES_CBC_Pad(data, key, iv);
|
||||
}
|
||||
|
||||
public byte[] decryptPinCode(byte encryptMethod, byte[] message, byte[] iv) throws CryptoException {
|
||||
|
@ -606,6 +606,8 @@ public class HuaweiPacket {
|
||||
return new DeviceConfig.Bond.OutgoingRequest(paramsProvider).fromPacket(this);
|
||||
case DeviceConfig.HiChain.id:
|
||||
return new DeviceConfig.HiChain.OutgoingRequest(paramsProvider).fromPacket(this);
|
||||
case DeviceConfig.Auth.id:
|
||||
return new DeviceConfig.Auth.OutgoingRequest(paramsProvider).fromPacket(this);
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
|
@ -610,6 +610,23 @@ public class DeviceConfig {
|
||||
this.isEncrypted = false;
|
||||
this.complete = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class OutgoingRequest extends HuaweiPacket {
|
||||
public byte[] challenge;
|
||||
public byte[] nonce;
|
||||
|
||||
public OutgoingRequest(ParamsProvider paramsProvider) {
|
||||
super(paramsProvider);
|
||||
this.complete = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseTlv() throws ParseException {
|
||||
this.challenge = this.tlv.getBytes(0x01);
|
||||
this.nonce = this.tlv.getBytes(0x02);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Response extends HuaweiPacket {
|
||||
|
Loading…
Reference in New Issue
Block a user