Skip to content

Commit 7fa917b

Browse files
fix
1 parent 01c3602 commit 7fa917b

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

BK7231Flasher/Beken_Crypto.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public static uint RotateLeft(uint value, int bits)
165165

166166
public static byte[] UnCRC(byte[] bytes)
167167
{
168+
bytes = MiscUtils.padArray(bytes, 34);
168169
var decrc = new List<byte>();
169170
int i = 0;
170171
for(i = 0; i < bytes.Length; i += 34)
@@ -184,11 +185,10 @@ public static byte[] UnCRC(byte[] bytes)
184185

185186
public static byte[] CRCBeken(byte[] bytes)
186187
{
188+
bytes = MiscUtils.padArray(bytes, 32);
187189
var crc = new List<byte>();
188190
int i = 0;
189191
var packet = new byte[34];
190-
for(int j = 0; j < packet.Length; j++)
191-
packet[j] = 0xFF;
192192
for(i = 0; i < bytes.Length; i += 32)
193193
{
194194
Array.Copy(bytes, i, packet, 0, 32);

BK7231Flasher/FormMain.Decryption.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private static string OpenFile(out string safeFileName)
4949

5050
private bool CheckDecrcLength(byte[] data, int len)
5151
{
52+
if(data == null) return false;
5253
if(data.Length < len)
5354
{
5455
if(data.Length == 0)
@@ -251,6 +252,7 @@ private void OnBtnEncryptBKNBootloaderClick(object sender, EventArgs e)
251252
private void OnBtnEncryptFirmwareClick(object sender, EventArgs e)
252253
{
253254
var fileName = OpenFile(out var safeFileName);
255+
if(fileName == null) return;
254256
var data = File.ReadAllBytes(fileName);
255257
var uintdata = Utils.U8ToU32(data);
256258
var keys = new uint[] { Convert.ToUInt32(numCoeff1.Text, 16), Convert.ToUInt32(numCoeff2.Text, 16), Convert.ToUInt32(numCoeff3.Text, 16), Convert.ToUInt32(numCoeff4.Text, 16) };

BK7231Flasher/FormMain.Designer.cs

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)