From 77167943f041b98c212a9182b4769568ed3fa8d3 Mon Sep 17 00:00:00 2001
From: JinGen Lim <1116555+jglim@users.noreply.github.com>
Date: Sat, 4 Feb 2023 21:15:41 +0800
Subject: [PATCH] Add HU45:7
---
UnlockECU/UnlockECU/Security/HU45Algo.cs | 34 ++++++++++++++++++++++++
UnlockECU/db.json | 10 +++++++
2 files changed, 44 insertions(+)
create mode 100644 UnlockECU/UnlockECU/Security/HU45Algo.cs
diff --git a/UnlockECU/UnlockECU/Security/HU45Algo.cs b/UnlockECU/UnlockECU/Security/HU45Algo.cs
new file mode 100644
index 0000000..c7bb90f
--- /dev/null
+++ b/UnlockECU/UnlockECU/Security/HU45Algo.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace UnlockECU
+{
+ ///
+ /// HU45Algo as found in HU45_hu45_sec_12_05_01, Intended for level 7 (CBF)
+ /// No algo name was formally specified, this name is unofficial
+ ///
+ class HU45Algo : SecurityProvider
+ {
+ public override bool GenerateKey(byte[] inSeed, byte[] outKey, int accessLevel, List parameters)
+ {
+ if ((inSeed.Length != 2) || (outKey.Length != 2))
+ {
+ return false;
+ }
+ // Levels, input and output length are not checked
+ // Only 2 bytes are checked and modified
+ int partial = ~(inSeed[0] + (inSeed[1] << 8)) - 0x307;
+ outKey[0] = (byte)(partial >> 8);
+ outKey[1] = (byte)(~inSeed[0] - 7);
+ return true;
+ }
+
+ public override string GetProviderName()
+ {
+ return "HU45Algo";
+ }
+ }
+}
diff --git a/UnlockECU/db.json b/UnlockECU/db.json
index 0909503..ceed5d2 100644
--- a/UnlockECU/db.json
+++ b/UnlockECU/db.json
@@ -4204,6 +4204,16 @@
}
]
},
+ {
+ "EcuName": "HU45",
+ "Aliases": [],
+ "AccessLevel": 7,
+ "SeedLength": 2,
+ "KeyLength": 2,
+ "Provider": "HU45Algo",
+ "Origin": "HU45_hu45_sec_12_05_01",
+ "Parameters": []
+ },
{
"EcuName": "HU7",
"Aliases": [],