Skip to content

Commit af6c425

Browse files
Store the encrypted bytes in CorePassSearchSpace + test
1 parent 79dbe76 commit af6c425

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Src/FinderOuter/Services/SearchSpaces/CorePassSearchSpace.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class CorePassSearchSpace : SearchSpaceBase
2323
/// Maximum possible password size in bytes (will be padded to be divisible by 4)
2424
/// </summary>
2525
public int MaxPasswordSize { get; private set; }
26+
public byte[] Encrypted { get; private set; }
2627
public byte[] Salt { get; private set; }
2728
public byte[] XOR { get; private set; }
2829
public int Iteration { get; private set; }
@@ -148,6 +149,7 @@ public bool Process(string hex, int passLength, out string error)
148149
PasswordLength = passLength;
149150
Iteration = iteration;
150151
Salt = salt;
152+
Encrypted = encKey.SubArray(32, 16);
151153
XOR = encKey.SubArray(16, 16);
152154

153155
error = string.Empty;

Src/Tests/Services/SearchSpaces/CorePassSearchSpaceTests.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public static IEnumerable<object[]> GetProcessCases()
1919
2,
2020
true, string.Empty,
2121
Helper.HexToBytes("9ca0271b64c0e66f"),
22+
Helper.HexToBytes("0032153d50cbf924a2ac1dc5f6279436"),
2223
Helper.HexToBytes("55f5e848d66586747cc000826d4c0c35"),
2324
327366
2425
};
@@ -27,55 +28,56 @@ public static IEnumerable<object[]> GetProcessCases()
2728
"43000130ac71182a748152bb788fb9deb11f2f5a55f5e848d66586747cc000826d4c0c350032153d50cbf924a2ac1dc5f6279436089ca0271b64c0e66f00000000c6fe040000",
2829
0,
2930
false, "Password length must be at least 1.",
30-
null, null, 0
31+
null, null, null, 0
3132
};
3233
yield return new object[]
3334
{
3435
"43000130ac71182a748152bb788fb9deb11f2f5a55f5e848d66586747cc000826d4c0c350032153d50cbf924a2ac1dc5f6279436089ca0271b64c0e66f00000000c6fe040000",
3536
-1,
3637
false, "Password length must be at least 1.",
37-
null, null, 0
38+
null, null, null, 0
3839
};
3940
yield return new object[]
4041
{
4142
null,
4243
2,
4344
false, "Input hex can not be null or empty.",
44-
null, null, 0
45+
null, null, null, 0
4546
};
4647
yield return new object[]
4748
{
4849
"abcx",
4950
2,
5051
false, "Invalid character \"x\" found at index=3.",
51-
null, null, 0
52+
null, null, null, 0
5253
};
5354
yield return new object[]
5455
{
5556
"abc",
5657
2,
5758
false, "Invalid hex string.",
58-
null, null, 0
59+
null, null, null, 0
5960
};
6061
yield return new object[]
6162
{
6263
"abcd",
6364
2,
6465
false, "Input hex is expected to be at least 70 bytes but it is 2 bytes.",
65-
null, null, 0
66+
null, null, null, 0
6667
};
6768
yield return new object[]
6869
{
6970
Helper.GetBytesHex(70),
7071
2,
7172
false, "Could not find 0x43000130 in the given hex.",
72-
null, null, 0
73+
null, null, null, 0
7374
};
7475
}
7576

7677
[Theory]
7778
[MemberData(nameof(GetProcessCases))]
78-
public void ProcessTest(string hex, int passLength, bool expected, string expError, byte[] expSalt, byte[] expXor, int expIter)
79+
public void ProcessTest(string hex, int passLength, bool expected, string expError,
80+
byte[] expSalt, byte[] expEncrypted, byte[] expXor, int expIter)
7981
{
8082
CorePassSearchSpace searchSpace = new();
8183
bool actual = searchSpace.Process(hex, passLength, out string error);
@@ -87,6 +89,7 @@ public void ProcessTest(string hex, int passLength, bool expected, string expErr
8789
{
8890
Assert.Equal(searchSpace.PasswordLength, passLength);
8991
Assert.Equal(searchSpace.Salt, expSalt);
92+
Assert.Equal(searchSpace.Encrypted, expEncrypted);
9093
Assert.Equal(searchSpace.XOR, expXor);
9194
Assert.Equal(searchSpace.Iteration, expIter);
9295
}

0 commit comments

Comments
 (0)