Public Access
Desktop: probe for the TPM once, off the UI thread, instead of on every unlock
This commit is contained in:
1 parent
3ccafdd53b
commit
365954c541
4 files changed
+133
-5
No files matched your search
@@ -41,7 +41,12 @@ namespace DodoSSH.Client.App.Platform;
|
||||
/// </remarks>
|
||||
public static class DesktopDeviceKeyStores
|
||||
{
|
||||
/// <summary>The best store this machine supports.</summary>
|
||||
/// <summary>The best store this machine supports, chosen on the thread pool.</summary>
|
||||
/// <remarks>
|
||||
/// Returns at once: the probing that decides between them is slow — a TPM key created and deleted on
|
||||
/// Windows — and runs behind <see cref="ProbedDeviceKeyStore"/> rather than here, which is on the UI
|
||||
/// thread at startup.
|
||||
/// </remarks>
|
||||
/// <param name="paths">Where a stored key lives.</param>
|
||||
/// <param name="askForPin">
|
||||
/// Shows the Linux PIN prompt, and is never called on the other two platforms — there the platform
|
||||
@@ -57,6 +62,13 @@ public static class DesktopDeviceKeyStores
|
||||
ArgumentNullException.ThrowIfNull(paths);
|
||||
ArgumentNullException.ThrowIfNull(askForPin);
|
||||
|
||||
return new ProbedDeviceKeyStore(() => Choose(paths, askForPin));
|
||||
}
|
||||
|
||||
private static IDeviceKeyStore Choose(
|
||||
ClientPaths paths,
|
||||
Func<DevicePinPurpose, CancellationToken, ValueTask<string?>> askForPin)
|
||||
{
|
||||
if (OperatingSystem.IsWindows() && WindowsDeviceKeyStore.IsSupported())
|
||||
{
|
||||
return new WindowsDeviceKeyStore(paths);
|
||||
|
||||
Reference in new issue
Block a user