Skip to content

Commit 9072d67

Browse files
committed
Merge branch 'dev'
2 parents 1490a8e + d9494d3 commit 9072d67

10 files changed

Lines changed: 625 additions & 200 deletions
Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
using AutoUpdaterDotNET;
21
using System;
32

43
namespace ZenTimings
54
{
6-
public sealed class UpdaterPersistenceProvider : IPersistenceProvider
5+
public sealed class UpdaterPersistenceProvider
76
{
87
internal readonly AppSettings appSettings = AppSettings.Instance;
98
public UpdaterPersistenceProvider() { }
109

1110
/// <summary>
1211
/// Reads the flag indicating whether a specific version should be skipped or not.
1312
/// </summary>
14-
/// <returns>Returns a version to skip. If skip value is false or not present then it will return null.</returns>
1513
public Version GetSkippedVersion()
1614
{
17-
// return Assembly.GetExecutingAssembly().GetName().Version;
18-
if (appSettings != null && appSettings.UpdaterSkippedVersion != null && appSettings.UpdaterSkippedVersion != "")
15+
if (appSettings != null && !string.IsNullOrEmpty(appSettings.UpdaterSkippedVersion))
1916
{
2017
return new Version(appSettings.UpdaterSkippedVersion);
2118
}
@@ -24,24 +21,8 @@ public Version GetSkippedVersion()
2421
}
2522

2623
/// <summary>
27-
/// Reads the value containing the date and time at which the user must be given again the possibility to upgrade the application.
24+
/// Sets the values indicating the specific version that must be ignored.
2825
/// </summary>
29-
/// <returns>Returns a DateTime value at which the user must be given again the possibility to upgrade the application. If remind later value is not present then it will return null.</returns>
30-
public DateTime? GetRemindLater()
31-
{
32-
if (appSettings?.UpdaterRemindLaterAt != null)
33-
{
34-
DateTime.TryParse(appSettings?.UpdaterRemindLaterAt, out DateTime result);
35-
return result;
36-
}
37-
38-
return null;
39-
}
40-
41-
/// <summary>
42-
/// Sets the values indicating the specific version that must be ignored by AutoUpdater.
43-
/// </summary>
44-
/// <param name="version">Version code for the specific version that must be ignored. Set it to null if you don't want to skip any version.</param>
4526
public void SetSkippedVersion(Version version)
4627
{
4728
if (appSettings != null && version != null)
@@ -50,18 +31,5 @@ public void SetSkippedVersion(Version version)
5031
appSettings.Save();
5132
}
5233
}
53-
54-
/// <summary>
55-
/// Sets the date and time at which the user must be given again the possibility to upgrade the application.
56-
/// </summary>
57-
/// <param name="remindLaterAt">Date and time at which the user must be given again the possibility to upgrade the application.</param>
58-
public void SetRemindLater(DateTime? remindLaterAt)
59-
{
60-
if (appSettings != null && remindLaterAt != null)
61-
{
62-
appSettings.UpdaterRemindLaterAt = remindLaterAt.ToString();
63-
appSettings.Save();
64-
}
65-
}
6634
}
6735
}

WPF/AgesaHelper.cs

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Diagnostics;
33
using System.Threading;
44
using ZenStates.Core;
5-
using ZenTimings.Decompressor;
65

76
namespace ZenTimings
87
{
@@ -59,40 +58,40 @@ public static byte[] DumpImage()
5958
/// <summary>
6059
/// Finds the AGESA version string in a BIOS image.
6160
/// </summary>
62-
public static string FindAgesaVersion(byte[] image)
63-
{
64-
const string AGESA_UNKNOWN = AppSettings.AGESA_UNKNOWN;
61+
//public static string FindAgesaVersion(byte[] image)
62+
//{
63+
// const string AGESA_UNKNOWN = AppSettings.AGESA_UNKNOWN;
6564

66-
if (image == null || image.Length == 0)
67-
return AGESA_UNKNOWN;
65+
// if (image == null || image.Length == 0)
66+
// return AGESA_UNKNOWN;
6867

69-
try
70-
{
71-
// Find the GUID in the BIOS data
72-
byte[] fileGuid = new Guid("9E21FD93-9C72-4C15-8C4B-E77F1DB2D792").ToByteArray();
73-
int fileOffset = Utils.FindSequence(image, 0, fileGuid);
74-
if (fileOffset == -1) return AGESA_UNKNOWN;
68+
// try
69+
// {
70+
// // Find the GUID in the BIOS data
71+
// byte[] fileGuid = new Guid("9E21FD93-9C72-4C15-8C4B-E77F1DB2D792").ToByteArray();
72+
// int fileOffset = Utils.FindSequence(image, 0, fileGuid);
73+
// if (fileOffset == -1) return AGESA_UNKNOWN;
7574

76-
// Read compressed size
77-
int compressedSize = BitConverter.ToInt32(image, fileOffset + HeaderSize) & 0xFFFFFF;
78-
//int decompressedSize = BitConverter.ToInt32(image, fileOffset + 0x35) & 0xFFFFFF;
79-
// Start of lzma block
80-
int lzmaStart = fileOffset + 0x30;
75+
// // Read compressed size
76+
// int compressedSize = BitConverter.ToInt32(image, fileOffset + HeaderSize) & 0xFFFFFF;
77+
// //int decompressedSize = BitConverter.ToInt32(image, fileOffset + 0x35) & 0xFFFFFF;
78+
// // Start of lzma block
79+
// int lzmaStart = fileOffset + 0x30;
8180

82-
byte[] compressedData = new byte[compressedSize];
83-
Array.Copy(image, lzmaStart, compressedData, 0, compressedSize);
81+
// byte[] compressedData = new byte[compressedSize];
82+
// Array.Copy(image, lzmaStart, compressedData, 0, compressedSize);
8483

85-
byte[] decompressedData = LZMACompressor.Decompress(compressedData);
84+
// byte[] decompressedData = LZMACompressor.Decompress(compressedData);
8685

87-
return AgesaUtils.ParseVersion(decompressedData);
88-
}
89-
catch (Exception ex)
90-
{
91-
Console.WriteLine($"FindAgesaVersion error: {ex.Message}");
92-
}
86+
// return AgesaUtils.ParseVersion(decompressedData);
87+
// }
88+
// catch (Exception ex)
89+
// {
90+
// Console.WriteLine($"FindAgesaVersion error: {ex.Message}");
91+
// }
9392

94-
return AGESA_UNKNOWN;
95-
}
93+
// return AGESA_UNKNOWN;
94+
//}
9695

9796
public static string FindAgesaVersionInMemory()
9897
{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Security.Cryptography;
3+
4+
namespace ZenTimings.Encryption
5+
{
6+
/// <summary>
7+
/// RSA signature verification for the update metadata file.
8+
/// </summary>
9+
internal static class UpdaterSignature
10+
{
11+
// RSA-2048 public key in XML format.
12+
private const string PublicKeyXml = "<RSAKeyValue><Modulus>xd+oBWB2K0hnfCOb8K3jT2IMAI90APR4mM7TnXht2EqBH/3OKHDyJNO/SWVhD5IRkl888swW12/kSymnuj/+U9eolOvqVJFzAee45kFfZab/L0h71shvqDOIdncasO+pBL23GF7KKUXXN5D4eDs7V9vDOnOra6vVtkdaOSoGtMDvnDG6auadsOHn/nojXRIpjn1lEB1f74ecLqy+SRHA++Di2eut/SOETsWwsS1J/9rjEgwliIHQN7pV7kd7ktGQqfndIjJYx/8F3+HU2pB0RFfjrYQAYjIejNIncz3LJOdVNlJa2H4+TzTIiFRVTF/1pNtY/OaL1nNFUH3uzlGUrQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>;
13+
14+
/// <summary>
15+
/// Verifies that <paramref name="data"/> was signed with the matching private key.
16+
/// </summary>
17+
/// <param name="data">The raw bytes of the update XML.</param>
18+
/// <param name="signature">The RSA-SHA256 signature bytes.</param>
19+
/// <returns>true if the signature is valid; otherwise false.</returns>
20+
public static bool Verify(byte[] data, byte[] signature)
21+
{
22+
// ProviderType 24 = PROV_RSA_AES — required on .NET 4.5 for SHA-256 signatures
23+
using (var rsa = new RSACryptoServiceProvider(new CspParameters { ProviderType = 24 }))
24+
{
25+
try
26+
{
27+
rsa.FromXmlString(PublicKeyXml);
28+
return rsa.VerifyData(data, CryptoConfig.MapNameToOID("SHA256"), signature);
29+
}
30+
finally
31+
{
32+
rsa.PersistKeyInCsp = false;
33+
}
34+
}
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)