Skip to content

Commit 03fb9ba

Browse files
authored
Merge pull request #72 from Feezex/main
Fix git reset --head
2 parents bbfbca4 + 9a39190 commit 03fb9ba

19 files changed

Lines changed: 69617 additions & 9388 deletions

.github/workflows/dotnet-desktop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252

5353
# Upload the completed build
5454
- name: Upload build artifacts
55-
uses: actions/upload-artifact@v2
55+
uses: actions/upload-artifact@v4
5656
with:
5757
name: VisualUnlockECU (Windows, ZIP)
5858
path: UnlockECU/VisualUnlockECU/bin/Release/net5.0-windows

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,9 @@ MigrationBackup/
348348

349349
# Ionide (cross platform F# VS Code tools) working folder
350350
.ionide/
351+
352+
# MacOS
353+
.DS_Store
354+
355+
# Rider
356+
.idea/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace UnlockECU
5+
{
6+
/// <summary>
7+
/// Generic array reverse algo, where the seed/output are of equal length, and output is the reversed seed array
8+
/// </summary>
9+
class ArrayReverseAlgo : SecurityProvider
10+
{
11+
public override bool GenerateKey(byte[] inSeed, byte[] outKey, int accessLevel, List<Parameter> parameters)
12+
{
13+
if (inSeed.Length != outKey.Length)
14+
{
15+
return false;
16+
}
17+
Array.Reverse(inSeed);
18+
Array.Copy(inSeed, outKey, inSeed.Length);
19+
return true;
20+
}
21+
public override string GetProviderName()
22+
{
23+
return "ArrayReverseAlgo";
24+
}
25+
}
26+
}
27+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Collections.Generic;
2+
3+
namespace UnlockECU
4+
{
5+
/// <summary>
6+
/// ESP9212Algo1
7+
/// Experimental, unverified
8+
/// </summary>
9+
class ESP9212Algo1 : SecurityProvider
10+
{
11+
public override bool GenerateKey(byte[] inSeed, byte[] outKey, int accessLevel, List<Parameter> parameters)
12+
{
13+
if (outKey.Length != 2) { return false; }
14+
if (inSeed.Length != 2) { return false; }
15+
16+
uint val = inSeed[0];
17+
val <<= 8;
18+
val |= inSeed[1];
19+
20+
uint snapshot = val;
21+
val /= 4;
22+
val ^= snapshot;
23+
val *= 8;
24+
val ^= snapshot;
25+
26+
outKey[0] = (byte)(val >> 8);
27+
outKey[1] = (byte)val;
28+
return true;
29+
}
30+
31+
public override string GetProviderName()
32+
{
33+
return "ESP9212Algo1";
34+
}
35+
}
36+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace UnlockECU.Security
8+
{
9+
/// <summary>
10+
/// HondaAlgo1
11+
/// Level 1, used for firmware flashing
12+
/// Keys are embedded as a 12-byte ascii block in the *.rwd.gz firmware files (J2534Standard/CalibFiles)
13+
/// Firmware format is documented in rwd-xray https://github.com/jpancotti/rwd-xray
14+
/// Key generation is documented in HondaReflashTool https://github.com/bouletmarc/HondaReflashTool
15+
/// </summary>
16+
class HondaAlgo1 : SecurityProvider
17+
{
18+
public override bool GenerateKey(byte[] inSeed, byte[] outKey, int accessLevel, List<Parameter> parameters)
19+
{
20+
if ((inSeed.Length != 2) || (outKey.Length != 2))
21+
{
22+
return false;
23+
}
24+
byte[] k = GetParameterBytearray(parameters, "K");
25+
26+
ushort k0_xor = (ushort)(k[0] << 8 | k[1]);
27+
ushort k1_mul = (ushort)(k[2] << 8 | k[3]);
28+
ushort k2_mod = (ushort)(k[4] << 8 | k[5]);
29+
ushort seed = (ushort)(inSeed[0] << 8 | inSeed[1]);
30+
31+
int key = seed * k1_mul;
32+
if (k2_mod != 0)
33+
{
34+
key %= k2_mod;
35+
}
36+
key ^= k0_xor + seed;
37+
key &= 0xFFFF;
38+
39+
outKey[0] = (byte)(key >> 8);
40+
outKey[1] = (byte)key;
41+
return true;
42+
}
43+
44+
public override string GetProviderName()
45+
{
46+
return "HondaAlgo1";
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)