Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<RepositoryType>git</RepositoryType>
<PackageTags>siemens;s7</PackageTags>

<PackageVersion>1.1.2</PackageVersion>
<AssemblyVersion>1.1.2</AssemblyVersion>
<FileVersion>1.1.2</FileVersion>
<Version>1.1.2</Version>
<PackageReleaseNotes>Internal naming changes</PackageReleaseNotes>
<PackageVersion>1.1.3</PackageVersion>
<AssemblyVersion>1.1.3</AssemblyVersion>
<FileVersion>1.1.3</FileVersion>
<Version>1.1.3</Version>
<PackageReleaseNotes>Fix legacy challenge fingerprint derivation for the final lookup-table block.</PackageReleaseNotes>

<PackageIcon>nuget-icon.png</PackageIcon>
</PropertyGroup>
Expand Down
28 changes: 27 additions & 1 deletion HarpoS7.Tests/Fingerprint/HarpoFingerprintTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ namespace HarpoS7.Tests.Fingerprint;

public class HarpoFingerprintTests
{
[Test]
public void LookupTablesCoverEveryComputedBlock()
{
for (var index = 0; index < FingerprintConsts.Data1Collection.Length; index++)
{
var operations = FingerprintConsts.Data1Collection[index].Length / 3;
var requiredBytes = operations * 128;
var availableBytes = FingerprintConsts.Data2Collection[index].Length * sizeof(ushort);
Assert.That(
availableBytes,
Is.GreaterThanOrEqualTo(requiredBytes),
$"Fingerprint table {index} is too short for its computed indices");
}
}

[Test]
public void FingerprintChallengeHandlesCapturedLegacyRenewalEdgeCase()
{
Span<byte> fingerprint = stackalloc byte[FingerprintConsts.FingerprintLength];
var challenge = Convert.FromHexString("5B15B4694FC38A775E6778F0770C6E7A3118200D");

HarpoFingerprint.FingerprintChallenge(fingerprint, challenge);

Assert.That(Convert.ToHexString(fingerprint), Is.EqualTo("6AB5811DE6D28746"));
}

public static IEnumerable<TestCaseData> FingerprintSubProcedureCases
{
get
Expand Down Expand Up @@ -1003,4 +1029,4 @@ public void FingerprintChallenge()
var expectedFingerprint = new byte[8] { 0xe2, 0x87, 0xc1, 0xcb, 0x65, 0x9b, 0x9e, 0xdf }.AsSpan();
Assert.That(expectedFingerprint.SequenceEqual(fingerprint));
}
}
}
4 changes: 2 additions & 2 deletions HarpoS7/Fingerprint/FingerprintConsts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public static class FingerprintConsts
0xd7b1, 0xe73f, 0x7a90, 0xb821, 0xc54b, 0xabd6, 0x7552, 0x4a40, 0xf0d3, 0x2dbf, 0x1fc5, 0xcc99, 0x8111,
0x4305, 0x7080, 0xe835, 0xbf4, 0x43f, 0x6a5f, 0x2ab3, 0xf854, 0x1f7f, 0x3491, 0xd376, 0xd0bb, 0x7bc7,
0xed86, 0x7fbc, 0x2e5b, 0xc137, 0x8bcb, 0xe9ad, 0xb41c, 0xd4ce, 0x77d5, 0xc22f, 0x929f, 0xb6b2, 0xd74f,
0xe11d, 0xf565, 0x823f, 0x518b, 0xa857, 0xbf08
0xe11d, 0xf565, 0x823f, 0x518b, 0xa857, 0xbf08, 0x4c28
},
new ushort[]
{
Expand Down Expand Up @@ -2710,4 +2710,4 @@ public static class FingerprintConsts
0xbc27, 0xf54d, 0x261
},
};
}
}