Skip to content

Commit 03eb522

Browse files
Support "Details" button & Cleanup
1 parent 7d7d386 commit 03eb522

File tree

7 files changed

+200
-368
lines changed

7 files changed

+200
-368
lines changed

src/Files.App/Data/Items/CertNodeInfoItem.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,8 @@ public class CertNodeInfoItem
1111

1212
public string Version { get; set; } = string.Empty;
1313

14-
public string SerialNumber { get; set; } = string.Empty;
15-
16-
public string Thumbprint { get; set; } = string.Empty;
17-
1814
public string ValidFrom { get; set; } = string.Empty;
1915

2016
public string ValidTo { get; set; } = string.Empty;
21-
22-
public string SignAlgorithm { get; set; } = string.Empty;
2317
}
2418
}

src/Files.App/Data/Models/SignatureInfoItem.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
// Copyright (c) Files Community
22
// Licensed under the MIT License.
33

4+
using Files.App.Utils.Signatures;
45
using System.Windows.Input;
56

67
namespace Files.App.Data.Models
78
{
89
public sealed partial class SignatureInfoItem : ObservableObject
910
{
11+
private readonly string _fileName;
12+
13+
private readonly IntPtr _hwndParent;
14+
15+
private readonly int _index;
16+
1017
private string _Version = string.Empty;
1118
public string Version
1219
{
@@ -66,14 +73,18 @@ public bool Verified
6673

6774
public ICommand OpenDetailsCommand { get; }
6875

69-
public SignatureInfoItem(List<CertNodeInfoItem> chain)
76+
public SignatureInfoItem(string fileName, int index, IntPtr hWnd, List<CertNodeInfoItem> chain)
7077
{
78+
_fileName = fileName;
79+
_hwndParent = hWnd;
80+
_index = index;
7181
SignChain = chain ?? new List<CertNodeInfoItem>();
7282
OpenDetailsCommand = new AsyncRelayCommand(DoOpenDetails);
7383
}
7484

7585
private Task DoOpenDetails()
7686
{
87+
DigitalSignaturesUtil.DisplaySignerInfoDialog(_fileName, _hwndParent, _index);
7788
return Task.CompletedTask;
7889
}
7990
}

src/Files.App/Helpers/Win32/Win32PInvoke.Methods.cs

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,6 @@ public static extern bool CryptDecodeObject(
415415
ref uint pcbStructInfo
416416
);
417417

418-
[DllImport("crypt32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
419-
public static extern bool CryptBinaryToStringA(
420-
IntPtr pbBinary,
421-
uint cbBinary,
422-
uint dwFlags,
423-
IntPtr pszString,
424-
ref uint pcchString
425-
);
426-
427418
[DllImport("crypt32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
428419
public static extern IntPtr CertFindCertificateInStore(
429420
IntPtr hCertStore,
@@ -462,70 +453,13 @@ public static extern bool CertCloseStore(
462453
uint dwFlags
463454
);
464455

465-
// wintrust.dll
466-
[DllImport("wintrust.dll", SetLastError = true, CharSet = CharSet.Unicode)]
467-
public static extern bool CryptCATAdminCalcHashFromFileHandle(
468-
IntPtr hFile,
469-
ref uint pdwHash,
470-
IntPtr pReserved,
471-
uint dwFlags
472-
);
473-
474456
[DllImport("wintrust.dll")]
475457
public static extern long WinVerifyTrust(
476458
IntPtr hwnd,
477459
IntPtr pgActionID,
478460
IntPtr pWVTData
479461
);
480462

481-
// ncrypt.dll
482-
[DllImport("ncrypt.dll", SetLastError = true, CharSet = CharSet.Unicode)]
483-
public static extern bool BCryptDestroyHash(
484-
IntPtr hHash
485-
);
486-
487-
[DllImport("ncrypt.dll", SetLastError = true, CharSet = CharSet.Unicode)]
488-
public static extern uint BCryptFinishHash(
489-
IntPtr hHash,
490-
IntPtr pbOutput,
491-
uint cbOutput,
492-
uint dwFlags
493-
);
494-
495-
[DllImport("ncrypt.dll", SetLastError = true, CharSet = CharSet.Unicode)]
496-
public static extern uint BCryptOpenAlgorithmProvider(
497-
out IntPtr phAlgorithm,
498-
string pszAlgId,
499-
string pszImplementation,
500-
uint dwFlags
501-
);
502-
503-
[DllImport("ncrypt.dll", SetLastError = true, CharSet = CharSet.Unicode)]
504-
public static extern uint BCryptCloseAlgorithmProvider(
505-
IntPtr hAlgorithm,
506-
uint dwFlags
507-
);
508-
509-
[DllImport("ncrypt.dll", SetLastError = true, CharSet = CharSet.Unicode)]
510-
public static extern uint BCryptCreateHash(
511-
IntPtr hAlgorithm,
512-
out IntPtr hHash,
513-
IntPtr pbHashObject,
514-
uint cbHashObject,
515-
IntPtr pbSecret,
516-
uint cbSecret,
517-
uint flags
518-
);
519-
520-
521-
[DllImport("ncrypt.dll", SetLastError = true, CharSet = CharSet.Unicode)]
522-
public static extern uint BCryptHashData(
523-
IntPtr hHash,
524-
IntPtr pbInput,
525-
uint cbInput,
526-
uint dwFlags
527-
);
528-
529463
// kernel32.dll
530464
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
531465
public static extern bool FileTimeToSystemTime(
@@ -544,5 +478,9 @@ public static extern bool SystemTimeToFileTime(
544478
IntPtr lpSystemTime,
545479
IntPtr lpFileTime
546480
);
481+
482+
// cryptui.dll
483+
[DllImport("cryptui.dll", SetLastError = true, CharSet = CharSet.Auto)]
484+
public static extern bool CryptUIDlgViewSignerInfo(IntPtr pViewInfo);
547485
}
548486
}

src/Files.App/Helpers/Win32/Win32PInvoke.Structs.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,6 @@ public struct CERT_ALT_NAME_INFO
257257
public IntPtr rgAltEntry;
258258
}
259259

260-
[StructLayout(LayoutKind.Sequential)]
261-
public struct CRL_DIST_POINT_NAME
262-
{
263-
public uint dwDistPointNameChoice;
264-
public CERT_ALT_NAME_INFO FullName;
265-
}
266-
267260
[StructLayout(LayoutKind.Sequential)]
268261
public struct CERT_CONTEXT
269262
{
@@ -343,5 +336,22 @@ public struct WINTRUST_DATA
343336
public uint dwUIContext;
344337
public IntPtr pSignatureSettings;
345338
}
339+
340+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
341+
public struct CRYPTUI_VIEWSIGNERINFO_STRUCT
342+
{
343+
public uint dwSize;
344+
public IntPtr hwndParent;
345+
public uint dwFlags;
346+
public IntPtr szTitle;
347+
public IntPtr pSignerInfo;
348+
public IntPtr hMsg;
349+
public IntPtr pszOID;
350+
public uint? dwReserved;
351+
public uint cStores;
352+
public IntPtr rghStores;
353+
public uint cPropPages;
354+
public IntPtr rgPropPages;
355+
}
346356
}
347357
}

0 commit comments

Comments
 (0)