mirror of
https://github.com/MichaelGrafnetter/DSInternals
synced 2025-01-05 21:49:47 +00:00
68 lines
2.3 KiB
C#
68 lines
2.3 KiB
C#
using DSInternals.Common;
|
|
using DSInternals.DataStore;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.IO;
|
|
using System.Security;
|
|
using System.Text;
|
|
|
|
namespace DSInternals.DataStore.Test
|
|
{
|
|
[TestClass]
|
|
public class BootKeyRetrieverTester
|
|
{
|
|
[TestMethod]
|
|
public void BootKeyRetriever_Hive1()
|
|
{
|
|
// HACK: Use relative path.
|
|
string path = @"C:\Users\michael\Source\Workspaces\Workspace\DSInternals\TestData\IFM\registry\SYSTEM";
|
|
string bootKey = BootKeyRetriever.GetBootKey(path).ToHex();
|
|
string expected = "41e34661faa0d182182f6ddf0f0ca0d1";
|
|
Assert.AreEqual(expected, bootKey);
|
|
}
|
|
[TestMethod]
|
|
[ExpectedException(typeof(FileNotFoundException))]
|
|
public void BootKeyRetriever_NonExistingFile()
|
|
{
|
|
BootKeyRetriever.GetBootKey(@"C:\xxxxxx");
|
|
}
|
|
[TestMethod]
|
|
[ExpectedException(typeof(ArgumentNullException))]
|
|
public void BootKeyRetriever_NullFile()
|
|
{
|
|
BootKeyRetriever.GetBootKey(null);
|
|
}
|
|
[TestMethod]
|
|
public void BootKeyRetriever_NotRegistryHiveFile()
|
|
{
|
|
throw new AssertInconclusiveException();
|
|
}
|
|
[TestMethod]
|
|
public void BootKeyRetriever_NotSystemHiveFile()
|
|
{
|
|
throw new AssertInconclusiveException();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void BootKeyRetriever_Online()
|
|
{
|
|
byte[] bootKey = BootKeyRetriever.GetBootKey();
|
|
// Just test that the key has 16B.
|
|
Assert.AreEqual(BootKeyRetriever.BootKeyLength, bootKey.Length);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void BootKeyRetriever_LDS()
|
|
{
|
|
// AD LDS/ADAM
|
|
byte[] rootObjectPekList = "e2b95102f97b7528a7e2477a2406438f97974fabd412be91aca18a2c241d513482a51553d3f28b26".HexToBinary();
|
|
byte[] schemaNCPekList = "cb6ef0da6e2069f735b8211ee6071fb206ba4ade0d048e4b279decdc174747bb55ee46a321796c8a".HexToBinary();
|
|
|
|
byte[] bootKey = BootKeyRetriever.GetBootKey(rootObjectPekList, schemaNCPekList);
|
|
string expected = "51f9a1e2282c7b7a79f0ba210d1e8ef7";
|
|
|
|
Assert.AreEqual(expected, bootKey.ToHex(false));
|
|
}
|
|
}
|
|
}
|