From f675456c0b803a1f92dbd311fbc489ab3c32cfcc Mon Sep 17 00:00:00 2001 From: Vlad Lupashevskyi Date: Tue, 8 Aug 2023 23:19:30 +0200 Subject: [PATCH] Introduce seed key for EGS53 --- .../UnlockECU/Security/VGSSecurityAlgoExt.cs | 35 +++++++++++++++++++ UnlockECU/db.json | 21 +++++++++++ 2 files changed, 56 insertions(+) create mode 100644 UnlockECU/UnlockECU/Security/VGSSecurityAlgoExt.cs diff --git a/UnlockECU/UnlockECU/Security/VGSSecurityAlgoExt.cs b/UnlockECU/UnlockECU/Security/VGSSecurityAlgoExt.cs new file mode 100644 index 0000000..3de80ef --- /dev/null +++ b/UnlockECU/UnlockECU/Security/VGSSecurityAlgoExt.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace UnlockECU +{ + /// + /// Implementation of extended VGS Algo with different keys for multiplication and xor + /// + class VGSSecurityAlgoExt : SecurityProvider + { + public override bool GenerateKey(byte[] inSeed, byte[] outKey, int accessLevel, List parameters) + { + byte[] cryptoKeyMultBytes = GetParameterBytearray(parameters, "M"); + uint cryptoKeyMult = BytesToInt(cryptoKeyMultBytes, Endian.Big); + + byte[] cryptoKeyXorBytes = GetParameterBytearray(parameters, "X"); + uint cryptoKeyXor = BytesToInt(cryptoKeyXorBytes, Endian.Big); + + if ((inSeed.Length != 4) || (outKey.Length != 4)) + { + return false; + } + + long seed = BytesToInt(inSeed, Endian.Big); + long seedKey = cryptoKeyMult * (cryptoKeyXor ^ seed); + + IntToBytes((uint)seedKey, outKey, Endian.Big); + return true; + } + public override string GetProviderName() + { + return "VGSSecurityAlgoExt"; + } + } +} diff --git a/UnlockECU/db.json b/UnlockECU/db.json index 984e218..c58c1fd 100644 --- a/UnlockECU/db.json +++ b/UnlockECU/db.json @@ -11818,6 +11818,27 @@ "DataType": "ByteArray" } ] + }, + { + "EcuName": "EGS53", + "Aliases": [], + "AccessLevel": 1, + "SeedLength": 4, + "KeyLength": 4, + "Provider": "VGSSecurityAlgoExt", + "Origin": "EGS53_27_05@VladLupashevskyi-@rnd-ash", + "Parameters": [ + { + "Key": "X", + "Value": "6BB6B6B6", + "DataType": "ByteArray" + }, + { + "Key": "M", + "Value": "49949494", + "DataType": "ByteArray" + } + ] }, { "EcuName": "Subaru_2EE2",