Skip to content

Commit c5a6c16

Browse files
authored
Add Renault_Radio_Code
#68
1 parent 8432e91 commit c5a6c16

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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
8+
{
9+
class RenaultRadio : SecurityProvider
10+
{
11+
public override bool GenerateKey(byte[] inSeed, byte[] outKey, int accessLevel, List<Parameter> parameters)
12+
{
13+
if (inSeed == null || outKey == null)
14+
return false;
15+
16+
// Expecting 4 bytes (HEX: 59 30 32 30)
17+
if (inSeed.Length < 4)
18+
return false;
19+
20+
// First 4 bytes as ASCII
21+
char c0 = (char)inSeed[0];
22+
char c1 = (char)inSeed[1];
23+
char c2 = (char)inSeed[2];
24+
char c3 = (char)inSeed[3];
25+
26+
int var0 = char.ToUpper(c0);
27+
int var1 = c1;
28+
int var2 = c2;
29+
int var3 = c3;
30+
31+
var0 = var0 * 5;
32+
var1 = var0 * 2 + var1 - 698;
33+
var2 = (var2 * 5) * 2 + var1;
34+
var3 = var3 + var2 - 528;
35+
36+
int sum = ((var3 << 3) - var3) % 100;
37+
38+
if (sum < 0)
39+
sum += 100;
40+
41+
int call = sum / 10;
42+
int remainder = (sum % 10) * 5;
43+
44+
int varf = remainder * 2 + call;
45+
46+
if (var1 == 0)
47+
return false;
48+
49+
int eax = 259 % var1 % 100;
50+
eax = eax * 5;
51+
int edx = eax * 5;
52+
eax = edx * 4 + varf;
53+
54+
// OUTPUT (2 bytes Big Endian)
55+
if (outKey.Length < 2)
56+
return false;
57+
58+
outKey[0] = (byte)((eax >> 8) & 0xFF);
59+
outKey[1] = (byte)(eax & 0xFF);
60+
61+
return true;
62+
}
63+
64+
public override string GetProviderName()
65+
{
66+
return "RenaultRadio";
67+
}
68+
}
69+
}

UnlockECU/db.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3391,6 +3391,16 @@
33913391
}
33923392
]
33933393
},
3394+
{
3395+
"EcuName": "Renault_Radio_Code",
3396+
"Aliases": [],
3397+
"AccessLevel": 1,
3398+
"SeedLength": 4,
3399+
"KeyLength": 2,
3400+
"Provider": "RenaultRadio",
3401+
"Origin": "RenaultRadioCode_@Feezex",
3402+
"Parameters": []
3403+
},
33943404
{
33953405
"EcuName": "EARS167",
33963406
"Aliases": [],

0 commit comments

Comments
 (0)