Skip to content

Commit 75ed394

Browse files
committed
Cleanup dead code and renames.
1 parent b02e470 commit 75ed394

File tree

9 files changed

+10
-117
lines changed

9 files changed

+10
-117
lines changed

AuthenticodeLint/ISignature.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Security.Cryptography;
43
using System.Security.Cryptography.X509Certificates;
54

AuthenticodeLint/Interop/Crypt32.cs

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,6 @@ public static extern bool CryptQueryObject
2323
[param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr ppvContext
2424
);
2525

26-
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptQueryObject", SetLastError = true)]
27-
[return: MarshalAs(UnmanagedType.Bool)]
28-
public static extern bool CryptQueryObject
29-
(
30-
[param: In, MarshalAs(UnmanagedType.U4)] CryptQueryObjectType dwObjectType,
31-
[param: In, Out, MarshalAs(UnmanagedType.Struct)] ref CRYPTOAPI_BLOB pvObject,
32-
[param: In, MarshalAs(UnmanagedType.U4)] CryptQueryContentFlagType dwExpectedContentTypeFlags,
33-
[param: In, MarshalAs(UnmanagedType.U4)] CryptQueryFormatFlagType dwExpectedFormatTypeFlags,
34-
[param: In, MarshalAs(UnmanagedType.U4)] CryptQueryObjectFlags dwFlags,
35-
[param: Out, MarshalAs(UnmanagedType.U4)] out EncodingType pdwMsgAndCertEncodingType,
36-
[param: Out, MarshalAs(UnmanagedType.U4)] out CryptQueryContentType pdwContentType,
37-
[param: Out, MarshalAs(UnmanagedType.U4)] out CryptQueryFormatType pdwFormatType,
38-
[param: Out] out CertStoreSafeHandle phCertStore,
39-
[param: Out] out CryptMsgSafeHandle phMsg,
40-
[param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr ppvContext
41-
);
42-
43-
4426
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptQueryObject", SetLastError = true)]
4527
[return: MarshalAs(UnmanagedType.Bool)]
4628
public static extern bool CryptQueryObject
@@ -86,27 +68,6 @@ public static extern unsafe bool CryptDecodeObjectEx
8668
[param: In, Out, MarshalAs(UnmanagedType.U4)] ref uint pcbStructInfo
8769
);
8870

89-
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptMsgOpenToDecode", SetLastError = true)]
90-
public static extern unsafe CryptMsgSafeHandle CryptMsgOpenToDecode
91-
(
92-
[param: In, MarshalAs(UnmanagedType.U4)] EncodingType dwCertEncodingType,
93-
[param: In, MarshalAs(UnmanagedType.U4)] CryptMsgOpenFlags dwFlags,
94-
[param: In, MarshalAs(UnmanagedType.U4)] CryptMsgType dwMsgType,
95-
[param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr hCryptProv,
96-
[param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr pRecipientInfo,
97-
[param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr pStreamInfo
98-
);
99-
100-
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptMsgUpdate", SetLastError = true)]
101-
[return: MarshalAs(UnmanagedType.Bool)]
102-
public static extern unsafe bool CryptMsgUpdate
103-
(
104-
[param: In] CryptMsgSafeHandle hCryptMsg,
105-
[param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr pbData,
106-
[param: In, MarshalAs(UnmanagedType.U4)] uint cbData,
107-
[param: In, MarshalAs(UnmanagedType.Bool)] bool fFinal
108-
);
109-
11071
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptMsgClose", SetLastError = true)]
11172
[return: MarshalAs(UnmanagedType.Bool)]
11273
public static extern bool CryptMsgClose([param: In, MarshalAs(UnmanagedType.SysInt)] IntPtr hCryptMsg);
@@ -130,17 +91,6 @@ public static unsafe extern bool CryptMsgGetParam
13091
[param: In, Out, MarshalAs(UnmanagedType.U4)] ref uint pcbData
13192
);
13293

133-
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptMsgGetParam", SetLastError = true)]
134-
[return: MarshalAs(UnmanagedType.Bool)]
135-
public static unsafe extern bool CryptMsgGetParam
136-
(
137-
[param: In] CryptMsgSafeHandle hCryptMsg,
138-
[param: In, MarshalAs(UnmanagedType.U4)] CryptMsgParamType dwParamType,
139-
[param: In, MarshalAs(UnmanagedType.U4)] uint dwIndex,
140-
[param: In] void* pvData,
141-
[param: In, Out, MarshalAs(UnmanagedType.U4)] ref uint pcbData
142-
);
143-
14494
[method: DllImport("crypt32.dll", CallingConvention = CallingConvention.Winapi, EntryPoint = "CryptBinaryToString", SetLastError = true)]
14595
[return: MarshalAs(UnmanagedType.Bool)]
14696
public static unsafe extern bool CryptBinaryToString
@@ -338,27 +288,6 @@ internal enum CryptDecodeFlags : uint
338288
CRYPT_DECODE_ALLOC_FLAG = 0x8000
339289
}
340290

341-
[type: Flags]
342-
internal enum CryptMsgOpenFlags : uint
343-
{
344-
CMSG_BARE_CONTENT_FLAG = 0x00000001,
345-
CMSG_LENGTH_ONLY_FLAG = 0x00000002,
346-
CMSG_DETACHED_FLAG = 0x00000004,
347-
CMSG_AUTHENTICATED_ATTRIBUTES_FLAG = 0x00000008,
348-
CMSG_CONTENTS_OCTETS_FLAG = 0x00000010,
349-
CMSG_MAX_LENGTH_FLAG = 0x00000020,
350-
}
351-
352-
internal enum CryptMsgType : uint
353-
{
354-
CMSG_DATA = 1,
355-
CMSG_SIGNED = 2,
356-
CMSG_ENVELOPED = 3,
357-
CMSG_SIGNED_AND_ENVELOPED = 4,
358-
CMSG_HASHED = 5,
359-
CMSG_ENCRYPTED = 6,
360-
}
361-
362291
[type: StructLayout(LayoutKind.Sequential)]
363292
internal struct CRYPTOAPI_BLOB
364293
{
@@ -437,16 +366,6 @@ internal enum SpcLinkChoice : uint
437366
SPC_FILE_LINK_CHOICE = 3
438367
}
439368

440-
[type: StructLayout(LayoutKind.Sequential)]
441-
internal struct CERT_CONTEXT
442-
{
443-
public EncodingType dwCertEncodingType;
444-
public IntPtr pbCertEncoded;
445-
public uint cbCertEncoded;
446-
public IntPtr pCertInfo;
447-
public IntPtr hCertStore;
448-
}
449-
450369
[type: StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
451370
internal struct CRYPT_ATTRIBUTE
452371
{

AuthenticodeLint/Interop/CryptMsgSafeHandle.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Runtime.InteropServices;
3-
4-
namespace AuthenticodeLint.Interop
1+
namespace AuthenticodeLint.Interop
52
{
63
internal class CryptMsgSafeHandle : Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
74
{

AuthenticodeLint/Interop/Pe.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,4 @@ public struct IMAGE_DATA_DIRECTORY
115115
public uint VirtualAddress;
116116
public uint Size;
117117
}
118-
119-
[type: StructLayout(LayoutKind.Sequential, Pack = 4)]
120-
public struct IMAGE_SECTION_HEADER
121-
{
122-
public unsafe fixed byte Name[8];
123-
public uint PhysicalAddressOrVirtualSize;
124-
public uint VirtualAddress;
125-
public uint SizeOfRawData;
126-
public uint PointerToRawData;
127-
public uint PointerToRelocations;
128-
public uint PointerToLinenumbers;
129-
public ushort NumberOfRelocations;
130-
public ushort NumberOfLinenumbers;
131-
public uint Characteristics;
132-
}
133118
}

AuthenticodeLint/KnownOids.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Security.Cryptography;
2-
3-
namespace AuthenticodeLint
1+
namespace AuthenticodeLint
42
{
53
public static class KnownOids
64
{

AuthenticodeLint/Rules/10010-NoUnknownCertificatesRule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public RuleResult Validate(IReadOnlyList<ISignature> graph, SignatureLogger verb
1717
var result = RuleResult.Pass;
1818
//We exclude Authenticode timestamps because they cannot contain "additional" certificates but rather
1919
//Use their parent. Including Authenticode timestamps will produce duplicate warnings.
20-
var signatures = graph.VisitAll(SignatureKind.AnySignature | SignatureKind.Rfc3161Signature);
20+
var signatures = graph.VisitAll(SignatureKind.AnySignature | SignatureKind.Rfc3161Timestamp);
2121
foreach (var signature in signatures)
2222
{
2323
var allEmbeddedCertificates = signature.AdditionalCertificates.Cast<X509Certificate2>().ToList();

AuthenticodeLint/Signature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public override IReadOnlyList<ISignature> GetNestedSignatures()
168168
}
169169
else if (attribute.Oid.Value == KnownOids.Rfc3161CounterSignature)
170170
{
171-
signature = new Signature(value, SignatureKind.Rfc3161Signature);
171+
signature = new Signature(value, SignatureKind.Rfc3161Timestamp);
172172
}
173173
else if (attribute.Oid.Value == KnownOids.NestedSignatureOid)
174174
{
@@ -275,7 +275,7 @@ public override IReadOnlyList<ISignature> GetNestedSignatures()
275275
}
276276
else if (attribute.Oid.Value == KnownOids.Rfc3161CounterSignature)
277277
{
278-
signature = new Signature(value, SignatureKind.Rfc3161Signature);
278+
signature = new Signature(value, SignatureKind.Rfc3161Timestamp);
279279
}
280280
else if (attribute.Oid.Value == KnownOids.NestedSignatureOid)
281281
{

AuthenticodeLint/SignatureExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public enum SignatureKind
3939
{
4040
NestedSignature = 0x1,
4141
Signature = 0x2,
42-
AuthenticodeSignature = 0x4,
43-
Rfc3161Signature = 0x8,
42+
AuthenticodeTimestamp = 0x4,
43+
Rfc3161Timestamp = 0x8,
4444
AnySignature = NestedSignature | Signature,
45-
AnyCounterSignature = AuthenticodeSignature | Rfc3161Signature,
45+
AnyCounterSignature = AuthenticodeTimestamp | Rfc3161Timestamp,
4646
Any = AnySignature | AnyCounterSignature
4747
}
4848
}

AuthenticodeLint/VerboseSignatureTextWriter.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Linq;
3-
using System.IO;
4-
using System.Security.Cryptography.Pkcs;
5-
using System.Text;
6-
using System.Collections.Generic;
1+
using System.Collections.Generic;
72

83
namespace AuthenticodeLint
94
{

0 commit comments

Comments
 (0)