授权绑定改用磁盘固件序列号:消费级主板常缺出厂序列号,改用物理磁盘序列号散列作为硬件机器码,多盘去重排序保证稳定

This commit is contained in:
tfarcraw 2026-11-23 17:59:28 +08:00
parent 8afc2edf1d
commit c018869acd
11 changed files with 92 additions and 80 deletions

View File

@ -1,12 +1,12 @@
# 试用与主板授权
# 试用与磁盘硬件授权
首次运行本版本,从当前时刻开始试用一个自然月。例如 1 月 31 日开始,到 2 月最后一天同一时刻到期。已有版本升级后首次启动本功能才开始计时。
从主窗口“登录 / 切换用户”打开登录窗口,点击其中的“软件授权”可以查看有效期、复制主板机器码和输入授权码,无需先登录;首次创建管理员窗口也提供该入口。试用到期后自动弹出授权窗口:到期启动只显示授权窗口,通过授权后才创建业务主界面和自动启动 D3。运行中每 30 秒检查一次,到期会停止 SOP 和相机检测并遮挡业务界面,续期后需手动重新开始作业。已有登录窗口时,授权提示会显示在其前面。关闭到期授权窗口会退出软件。
从主窗口“登录 / 切换用户”打开登录窗口,点击其中的“软件授权”可以查看有效期、复制磁盘机器码和输入授权码,无需先登录;首次创建管理员窗口也提供该入口。试用到期后自动弹出授权窗口:到期启动只显示授权窗口,通过授权后才创建业务主界面和自动启动 D3。运行中每 30 秒检查一次,到期会停止 SOP 和相机检测并遮挡业务界面,续期后需手动重新开始作业。已有登录窗口时,授权提示会显示在其前面。关闭到期授权窗口会退出软件。
- 短期码 `Month`:从当前有效期与激活时间中较晚的一项开始,延长一个自然月。提前续期不会损失剩余时间;过期后从激活时刻续期。每个码只可兑换一次,不同码可以累加。
- 长期码 `Permanent`:绑定本机主板永久使用。已永久授权时不再消耗短期码。
- 所有码均验证发行方 RSA-PSS/SHA-256 签名及主板机器码。主板序列号缺失或为厂商占位值时不启动试用,也不生成共用的兜底机器码。
- 长期码 `Permanent`:绑定本机磁盘硬件永久使用。已永久授权时不再消耗短期码。
- 所有码均验证发行方 RSA-PSS/SHA-256 签名及硬件机器码。磁盘序列号缺失或为占位值时不启动试用,也不生成共用的兜底机器码。
- 检测到超过 5 分钟的系统时间回拨会暂停有限期授权,校准时间后可重新检查。永久授权不依赖时间到期检查。
## 发行方发码
@ -39,9 +39,9 @@ C:\Users\Administrator\.codex\secrets\aisop-license\issuer-private.pem
授权记录与安装、配方目录独立,位于当前系统用户的 LocalApplicationData 下 `Bellwether/AISOP/license.dat`。Windows 采用当前用户 DPAPI 加密并在 `HKCU\Software\Bellwether\AISOP\Licensing` 保存相同密文镜像;单独删除文件不会重置试用。记录损坏、镜像不一致或写入失败时禁止放行,不会自动重建试用。应对文件和注册表记录做同一时点的备份与恢复。
主板机器码由厂家、型号和固件主板序列号散列得到,移动程序或更换硬盘不会因路径或磁盘编号改变机器码。Windows 读取 CIM 的 `Win32_BaseBoard`;Linux 读取 `/sys/class/dmi/id/board_*`,运行账号必须具备读取权限。某些主板没有有效固件序列号,这类设备需要先由供应商修复固件信息。
硬件机器码由所有有效物理磁盘的固件序列号去重、排序后散列得到,读取顺序变化不会改变机器码;移动程序目录或更换未参与绑定的备用磁盘不影响授权,更换整组磁盘才失效。Windows 读取 CIM 的 `Win32_DiskDrive`;Linux 读取 `/sys/block/*/device/serial` 并过滤 loop、ram、dm- 等虚拟设备。磁盘固件序列号为空、全零/全 F 或短于 8 字符的设备会被剔除;一台机器没有任何有效序列号时拒绝签发授权。
当前授权记录按“电脑+系统账号”保存:不同系统账号需要各自激活,同一主板的授权码可在另一个账号使用。更换主板后原码失效,需要联系发行方重新签发,并由支持人员处理旧的本地记录。重装操作系统、清除全部记录、更换系统账号、完整回滚系统快照或修改客户端,无法靠纯离线方案彻底限制。Linux 使用主板派生 AES-GCM 密钥及用户文件权限保护记录,其防本机调试能力弱于 Windows DPAPI。严格的全机跨账号试用、防回滚或撤销授权需增加在线授权服务或受保护的安装服务。
当前授权记录按“电脑+系统账号”保存:不同系统账号需要各自激活,同一硬件的授权码可在另一个账号使用。更换磁盘集合后原码失效,需要联系发行方重新签发,并由支持人员处理旧的本地记录。重装操作系统、清除全部记录、更换系统账号、完整回滚系统快照或修改客户端,无法靠纯离线方案彻底限制。Linux 使用硬件机器码派生 AES-GCM 密钥及用户文件权限保护记录,其防本机调试能力弱于 Windows DPAPI。严格的全机跨账号试用、防回滚或撤销授权需增加在线授权服务或受保护的安装服务。
## 验证

View File

@ -6,7 +6,7 @@ Windows / Linux 共用一套 Avalonia 桌面程序:相机采集、双手关键
## 运行
软件首次运行可试用一个自然月,登录窗口中的“软件授权”支持输入绑定主板的短期码或永久码;试用到期会自动弹出授权窗口。发码、私钥备份及离线限制见 [AUTHORIZATION.md](AUTHORIZATION.md)。
软件首次运行可试用一个自然月,登录窗口中的“软件授权”支持输入绑定磁盘硬件的短期码或永久码;试用到期会自动弹出授权窗口。发码、私钥备份及离线限制见 [AUTHORIZATION.md](AUTHORIZATION.md)。
```powershell
dotnet build SopHelper.Avalonia.slnx

View File

@ -84,7 +84,7 @@ public partial class App : PrismApplication
containerRegistry.RegisterDialog<RecipeEditor,RecipeEditorViewModel>("RecipeEditorDialog");
containerRegistry.RegisterDialogWindow<RecipeDialogWindow>();
}
/// <summary>读取主板及授权状态;有效时创建业务窗口,否则只创建授权拦截窗口。</summary>
/// <summary>读取磁盘硬件码及授权状态;有效时创建业务窗口,否则只创建授权拦截窗口。</summary>
/// <returns>当前许可状态允许展示的窗口。</returns>
protected override AvaloniaObject CreateShell()
{
@ -93,7 +93,7 @@ public partial class App : PrismApplication
{
if (_license is null)
{
var machine = MotherboardIdentity.ReadMachineCode();
var machine = DiskIdentity.ReadMachineCode();
_license = new LicenseService(machine, new ProtectedLicenseStore(machine), LicenseService.ReadIssuerPublicKey());
}
if (_license.Check().Allowed) return CreateAuthorizedShell();

View File

@ -12,7 +12,7 @@ public sealed class LicenseWindow : Window
/// <summary>兑换成功后通知应用切换到主窗口;事件仅在授权状态已经写盘后触发。</summary>
public event Action? Authorized;
/// <summary>主板读取失败时保留错误说明并禁止激活,避免使用空机器码签发授权。</summary>
/// <summary>磁盘读取失败时保留错误说明并禁止激活,避免使用空机器码签发授权。</summary>
public LicenseWindow(LicenseService? service, string? initializationError = null)
{
Title = "软件授权"; Width = 600; SizeToContent = SizeToContent.Height; CanResize = false;
@ -20,9 +20,9 @@ public sealed class LicenseWindow : Window
var panel = new StackPanel { Margin = new Thickness(24), Spacing = 12 };
panel.Children.Add(new TextBlock { Text = "试用与授权", FontSize = 22 });
var status = new TextBlock { Name = "LicenseStatus", TextWrapping = TextWrapping.Wrap,
Text = service?.Check().Message ?? "无法读取主板信息:" + initializationError + "。请排除问题后重启软件。" };
Text = service?.Check().Message ?? "无法读取磁盘硬件信息:" + initializationError + "。请排除问题后重启软件。" };
panel.Children.Add(status);
panel.Children.Add(new TextBlock { Text = "本机主板机器码(请提供给软件发行方)" });
panel.Children.Add(new TextBlock { Text = "本机磁盘机器码(请提供给软件发行方)" });
var machine = new TextBox { Name = "LicenseMachineCode", Text = service?.Machine ?? "无法获取", IsReadOnly = true };
panel.Children.Add(machine);
var copy = new Button { Content = "复制机器码", IsEnabled = service is not null };
@ -32,7 +32,7 @@ public sealed class LicenseWindow : Window
catch (Exception error) { status.Text = "复制失败,请手动选择机器码复制:" + error.Message; }
};
panel.Children.Add(copy);
panel.Children.Add(new TextBlock { Text = "短期码延长一个自然月;长期码永久有效。授权仅限本机主板。", TextWrapping = TextWrapping.Wrap });
panel.Children.Add(new TextBlock { Text = "短期码延长一个自然月;长期码永久有效。授权仅限本机磁盘硬件。", TextWrapping = TextWrapping.Wrap });
var code = new TextBox { Name = "LicenseCodeInput", PlaceholderText = "粘贴完整授权码", AcceptsReturn = true,
TextWrapping = TextWrapping.Wrap, Height = 110 };
panel.Children.Add(code);

View File

@ -0,0 +1,59 @@
using System.Diagnostics;
using System.Text.Json;
namespace SopHelper.Engine.Licensing;
/// <summary>读取物理磁盘固件序列号作为硬件绑定锚点;无法识别时明确拒绝,不能退回所有机器共用的空值或随机值。</summary>
public static class DiskIdentity
{
/// <summary>
/// Windows 通过 CIM 枚举物理磁盘序列号,Linux 读取 /sys/block 下设备 serial 文件;
/// 多块有效磁盘按序列号排序后合并散列,保证同一硬件集合在任何读取顺序下得到相同机器码。
/// 更换整机才改变机器码;单独更换一块未参与绑定的磁盘不影响授权。
/// </summary>
public static string ReadMachineCode()
{
var serials = new List<string>();
if (OperatingSystem.IsWindows())
{
var info = new ProcessStartInfo("powershell.exe")
{ UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true };
foreach (var argument in new[] { "-NoProfile", "-NonInteractive", "-Command",
"$ErrorActionPreference='Stop'; Get-CimInstance Win32_DiskDrive | Select-Object -First 32 SerialNumber | ConvertTo-Json -Compress" })
info.ArgumentList.Add(argument);
using var process = Process.Start(info) ?? throw new InvalidOperationException("无法读取磁盘信息");
var output = process.StandardOutput.ReadToEndAsync();
var error = process.StandardError.ReadToEndAsync();
if (!process.WaitForExit(15000)) { process.Kill(true); throw new TimeoutException("读取磁盘信息超时"); }
if (process.ExitCode != 0) throw new InvalidOperationException("读取磁盘信息失败,请检查 Windows CIM 服务:" + error.GetAwaiter().GetResult());
// 单块磁盘时 CIM 返回对象而非数组,两种形状都要兼容。
using var data = JsonDocument.Parse(output.GetAwaiter().GetResult());
if (data.RootElement.ValueKind == JsonValueKind.Array)
foreach (var item in data.RootElement.EnumerateArray())
if (item.TryGetProperty("SerialNumber", out var s) && s.ValueKind == JsonValueKind.String) serials.Add(s.GetString()!);
else if (data.RootElement.TryGetProperty("SerialNumber", out var single) && single.ValueKind == JsonValueKind.String)
serials.Add(single.GetString()!);
}
else if (OperatingSystem.IsLinux())
{
foreach (var path in Directory.EnumerateDirectories("/sys/block"))
{
// 过滤 loop/ram/dm 等虚拟设备,它们没有固件序列号且会在任意机器上重现。
var name = Path.GetFileName(path);
if (name.StartsWith("loop") || name.StartsWith("ram") || name.StartsWith("dm-")) continue;
var serialPath = Path.Combine(path, "device", "serial");
if (!File.Exists(serialPath)) continue;
serials.Add(File.ReadAllText(serialPath));
}
}
else throw new PlatformNotSupportedException("当前平台不支持读取磁盘序列号");
// 过滤无效与占位值后去重排序,保证机器码对同一硬件集合稳定且唯一。
var valid = serials.Select(s => s.Trim().ToUpperInvariant())
.Where(s => s.Length >= 8 && !s.All(c => c is '0' or 'F' or '-' or ' '))
.Distinct().Order().ToList();
if (valid.Count == 0)
throw new InvalidOperationException("未读到有效磁盘序列号,无法绑定授权。请检查磁盘固件是否写入序列号。");
return LicenseService.MachineCode("DISK|" + string.Join("|", valid));
}
}

View File

@ -17,7 +17,7 @@ public interface ILicenseStore
void Write(byte[] value);
}
/// <summary>离线授权状态机:验签、主板匹配、防重复兑换与时间回拨检查集中在此处理。</summary>
/// <summary>离线授权状态机:验签、硬件机器码匹配、防重复兑换与时间回拨检查集中在此处理。</summary>
public sealed class LicenseService
{
private sealed record State(string Machine, DateTimeOffset StartedUtc, DateTimeOffset LastUtc,
@ -31,7 +31,7 @@ public sealed class LicenseService
/// <summary>注入时钟及存储便于验证边界;生产环境使用嵌入公钥,禁止通过配置替换信任根。</summary>
public LicenseService(string machine, ILicenseStore store, string publicKey, Func<DateTimeOffset>? clock = null)
{
if (!IsMachineCode(machine)) throw new ArgumentException("主板机器码无效");
if (!IsMachineCode(machine)) throw new ArgumentException("硬件机器码无效");
Machine = machine; _store = store; _publicKey = publicKey; _clock = clock ?? (() => DateTimeOffset.UtcNow);
}
@ -72,7 +72,7 @@ public sealed class LicenseService
using var lease = AcquireLease();
var grant = Verify(code);
var now = _clock();
if (grant.Machine != Machine) throw new InvalidOperationException("授权码与本机主板不匹配。");
if (grant.Machine != Machine) throw new InvalidOperationException("授权码与本机硬件不匹配。");
if (grant.IssuedUtc > now.AddMinutes(5)) throw new InvalidOperationException("授权码签发时间晚于系统时间,请校准时间。");
var state = Load(now);
if (!state.Permanent && now < state.LastUtc.AddMinutes(-5))
@ -113,7 +113,7 @@ public sealed class LicenseService
var bytes = _store.Read();
if (bytes is null) return new(Machine, now, now, now.AddMonths(1), false, []);
var state = JsonSerializer.Deserialize<State>(bytes) ?? throw new InvalidDataException("授权记录为空");
if (state.Machine != Machine) throw new InvalidDataException("主板已更换或授权记录来自其他电脑,请联系发行方。");
if (state.Machine != Machine) throw new InvalidDataException("硬件已更换或授权记录来自其他电脑,请联系发行方。");
if (state.StartedUtc == default || state.LastUtc < state.StartedUtc || state.ExpiresUtc <= state.StartedUtc
|| state.UsedIds is null) throw new InvalidDataException("授权记录损坏,请恢复备份并联系发行方。");
return state;
@ -139,11 +139,11 @@ public sealed class LicenseService
public void Dispose() { mutex.ReleaseMutex(); mutex.Dispose(); }
}
private static LicenseStatus Describe(State state, DateTimeOffset now) => state.Permanent
? new(true, true, null, "永久授权(已绑定本机主板)")
? new(true, true, null, "永久授权(已绑定本机磁盘硬件)")
: new(now < state.ExpiresUtc, false, state.ExpiresUtc,
$"{(state.UsedIds.Count == 0 ? "试用" : "短期授权")}{(now < state.ExpiresUtc ? "有效至" : "已到期于")} {state.ExpiresUtc.ToLocalTime():yyyy-MM-dd HH:mm},{(now < state.ExpiresUtc ? "可输入授权码续期" : "请输入授权码后继续使用")}。");
/// <summary>机器码仅暴露主板标识的 SHA-256,不在授权码里存储原始硬件序列号。</summary>
/// <summary>机器码仅暴露硬件标识的 SHA-256,不在授权码里存储原始磁盘序列号。</summary>
public static string MachineCode(string hardwareIdentity) => Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes("AISOP1|" + hardwareIdentity.Trim().ToUpperInvariant())));
private static bool IsMachineCode(string value) => value is { Length: 64 } && value.All(c => c is >= '0' and <= '9' or >= 'A' and <= 'F');
}

View File

@ -1,50 +0,0 @@
using System.Diagnostics;
using System.Text.Json;
namespace SopHelper.Engine.Licensing;
/// <summary>读取固件主板序列号;无法识别时明确拒绝,不能退回所有机器共用的空值或随机值。</summary>
public static class MotherboardIdentity
{
/// <summary>Windows 通过 CIM 读取主板,Linux 读取 DMI;更换硬盘或移动程序目录不改变机器码。</summary>
public static string ReadMachineCode()
{
string serial, vendor, model;
if (OperatingSystem.IsWindows())
{
var info = new ProcessStartInfo("powershell.exe")
{ UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true };
foreach (var argument in new[] { "-NoProfile", "-NonInteractive", "-Command",
"$ErrorActionPreference='Stop'; Get-CimInstance Win32_BaseBoard | Select-Object -First 1 SerialNumber,Manufacturer,Product | ConvertTo-Json -Compress" })
info.ArgumentList.Add(argument);
using var process = Process.Start(info) ?? throw new InvalidOperationException("无法读取主板信息");
var output = process.StandardOutput.ReadToEndAsync();
var error = process.StandardError.ReadToEndAsync();
if (!process.WaitForExit(15000)) { process.Kill(true); throw new TimeoutException("读取主板信息超时"); }
if (process.ExitCode != 0) throw new InvalidOperationException("读取主板信息失败,请检查 Windows CIM 服务:" + error.GetAwaiter().GetResult());
using var data = JsonDocument.Parse(output.GetAwaiter().GetResult());
serial = data.RootElement.GetProperty("SerialNumber").GetString() ?? "";
vendor = data.RootElement.GetProperty("Manufacturer").GetString() ?? "";
model = data.RootElement.GetProperty("Product").GetString() ?? "";
}
else if (OperatingSystem.IsLinux())
{
serial = File.ReadAllText("/sys/class/dmi/id/board_serial");
vendor = File.ReadAllText("/sys/class/dmi/id/board_vendor");
model = File.ReadAllText("/sys/class/dmi/id/board_name");
}
else throw new PlatformNotSupportedException("当前平台不支持读取主板信息");
return FromBoard(serial, vendor, model);
}
/// <summary>过滤厂商占位序列号,防止没有真实序列号的不同主板生成相同机器码。</summary>
public static string FromBoard(string serial, string vendor, string model)
{
var normalized = serial.Trim().ToUpperInvariant();
if (normalized.Length < 4 || normalized.All(c => c is '0' or 'F' or '-' or ' ')
|| new[] { "DEFAULT", "TO BE FILLED", "UNKNOWN", "NONE", "NOT SPECIFIED", "SYSTEM SERIAL", "INVALID", "N/A", "OEM" }
.Any(normalized.Contains))
throw new InvalidOperationException("主板未提供有效序列号,无法绑定授权,请联系设备供应商。");
return LicenseService.MachineCode($"{vendor.Trim()}|{model.Trim()}|{normalized}");
}
}

View File

@ -17,7 +17,7 @@ public sealed class ProtectedLicenseStore : ILicenseStore
private readonly string _path;
private readonly byte[] _entropy;
/// <summary>固定用户数据目录,不受配方工作区和程序位置影响;Linux 使用主板派生密钥及仅本人可读写权限。</summary>
/// <summary>固定用户数据目录,不受配方工作区和程序位置影响;Linux 使用硬件机器码派生密钥及仅本人可读写权限。</summary>
public ProtectedLicenseStore(string machine)
: this(machine, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Bellwether", "AISOP", "license.dat"), @"Software\Bellwether\AISOP\Licensing") { }
@ -30,7 +30,7 @@ public sealed class ProtectedLicenseStore : ILicenseStore
_entropy = SHA256.HashData(Encoding.UTF8.GetBytes("AISOP-state-v1|" + machine));
}
/// <summary>文件和镜像均存在时必须一致;损坏、主板不匹配和权限错误均上抛,禁止静默重置。</summary>
/// <summary>文件和镜像均存在时必须一致;损坏、硬件不匹配和权限错误均上抛,禁止静默重置。</summary>
public byte[]? Read()
{
byte[]? file = File.Exists(_path) ? File.ReadAllBytes(_path) : null;

View File

@ -47,7 +47,7 @@ internal sealed class LicenseUiTests
}
Check(desktop.MainWindow is LicenseWindow, "到期启动仅显示授权拦截窗口");
var gate = (LicenseWindow)desktop.MainWindow!;
Check(Find<TextBox>(gate, "LicenseMachineCode").Text == Service.Machine, "授权窗口提供可选择复制的主板机器码");
Check(Find<TextBox>(gate, "LicenseMachineCode").Text == Service.Machine, "授权窗口提供可选择复制的硬件机器码");
Submit(gate, "invalid");
Check(gate.IsVisible && Find<TextBlock>(gate, "LicenseStatus").Text!.Contains("无效"), "错误授权码保留拦截并显示错误");
var shortCode = Code(); Submit(gate, shortCode);

View File

@ -34,7 +34,7 @@ internal static class LicenseTests
var renewed = service.Activate(" \n" + shortCode + "\n");
Check(renewed.Allowed && renewed.ExpiresUtc == trial.ExpiresUtc!.Value.AddMonths(1), "提前激活保留剩余期限并增加一个月");
Reject(() => Create().Activate(shortCode), "重启后仍拒绝重复兑换同一码");
Reject(() => service.Activate(Code(board: LicenseService.MachineCode("other"))), "拒绝其他主板的授权码");
Reject(() => service.Activate(Code(board: LicenseService.MachineCode("other"))), "拒绝其他硬件的授权码");
using var stranger = RSA.Create(2048);
Reject(() => service.Activate(Code(signer: stranger)), "拒绝非发行方签名");
Reject(() => service.Activate(Code(kind: "Unknown")), "拒绝未知授权类型");
@ -43,7 +43,7 @@ internal static class LicenseTests
var parts = Code().Split('.');
var bytes = Convert.FromBase64String(parts[1]); bytes[5] ^= 1; parts[1] = Convert.ToBase64String(bytes);
Reject(() => service.Activate(string.Join('.', parts)), "拒绝被篡改的签名内容");
Check(!Create(LicenseService.MachineCode("replacement")).Check().Allowed, "更换主板后原记录不可使用");
Check(!Create(LicenseService.MachineCode("replacement")).Check().Allowed, "更换硬件后原记录不可使用");
now = renewed.ExpiresUtc!.Value;
Check(!service.Check().Allowed, "到期时刻立即失效");
now = now.AddDays(5);
@ -70,11 +70,14 @@ internal static class LicenseTests
store.Fail = false; store.Data = null; store.FailWrite = true;
Check(!service.Check().Allowed, "试用记录写盘失败时禁止放行");
Reject(() => service.Activate(Code()), "激活写盘失败不返回成功");
Reject(() => MotherboardIdentity.FromBoard("To be filled by O.E.M.", "vendor", "model"), "拒绝主板占位序列号");
Check(MotherboardIdentity.FromBoard(" Serial-123 ", "Vendor", "Model") == MotherboardIdentity.FromBoard("serial-123", "vendor", "model"), "主板标识忽略大小写与外部空白");
using var publicKey = RSA.Create(); publicKey.ImportFromPem(LicenseService.ReadIssuerPublicKey());
Check(publicKey.KeySize >= 3072, "生产验签公钥已嵌入程序集");
if (OperatingSystem.IsWindows()) Check(MotherboardIdentity.ReadMachineCode().Length == 64, "本机 CIM 主板读取成功");
if (OperatingSystem.IsWindows())
{
// 磁盘硬件码必须能稳定读取:两次读取结果一致且为标准 64 位十六进制散列。
var first = DiskIdentity.ReadMachineCode();
Check(first.Length == 64 && first == DiskIdentity.ReadMachineCode(), "本机磁盘序列号读取成功且结果稳定");
}
CheckProtectedStore(machine);
// 可选验收发行脚本真实输出,仍只写入内存,不激活当前电脑的正式记录。
@ -112,7 +115,7 @@ internal static class LicenseTests
target.Write(clear);
using (var key = Registry.CurrentUser.OpenSubKey(registryPath, true)!) key.DeleteValue("State");
Check(target.Read()!.SequenceEqual(clear), "镜像缺失时仍保留文件中的原始授权");
Check(Refused(new ProtectedLicenseStore(LicenseService.MachineCode("different-board"), path, registryPath)), "不同主板无法解密复制的授权记录");
Check(Refused(new ProtectedLicenseStore(LicenseService.MachineCode("different-board"), path, registryPath)), "不同硬件无法解密复制的授权记录");
target.Write(clear);
File.WriteAllBytes(path, [1, 2, 3]);
Check(Refused(target), "授权文件与镜像不同则拒绝加载");

View File

@ -1,8 +1,8 @@
<#
.SYNOPSIS
发行方离线签发绑定主板的短期或永久授权;要求 PowerShell 7,不能把私钥发给客户。
发行方离线签发绑定磁盘硬件的短期或永久授权;要求 PowerShell 7,不能把私钥发给客户。
.EXAMPLE
pwsh -File tools/New-License.ps1 -Machine 64位主板机器码 -Kind Month
pwsh -File tools/New-License.ps1 -Machine 64位硬件机器码 -Kind Month
#>
[CmdletBinding()]
param(