Skip to content

Commit e837c39

Browse files
authored
[CodeQL][SM03800] Remove unapproved usage of DSACryptoServiceProvider (dotnet#11540)
Fixes # CodeQL SM03800 issue Context CodeQL is flagging unapproved usage of DSACryptoServiceProvider Changes Made The flagged code is not required in ClickOnce so deleting it. Testing ClickOnce signing scenarios validated from .NET Fx 3.5 through .NET 9. Notes
1 parent 353c0f3 commit e837c39

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

src/Tasks/ManifestUtil/CngLightup.cs

-31
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace System.Security.Cryptography
2626
{
2727
internal static partial class CngLightup
2828
{
29-
private const string DsaOid = "1.2.840.10040.4.1";
3029
private const string RsaOid = "1.2.840.113549.1.1.1";
3130

3231
private const string HashAlgorithmNameTypeName = "System.Security.Cryptography.HashAlgorithmName";
@@ -57,9 +56,6 @@ internal static partial class CngLightup
5756

5857
private static readonly Lazy<bool> s_preferRsaCng = new Lazy<bool>(DetectRsaCngSupport);
5958

60-
private static volatile Func<X509Certificate2, DSA> s_getDsaPublicKey;
61-
private static volatile Func<X509Certificate2, DSA> s_getDsaPrivateKey;
62-
6359
private static volatile Func<X509Certificate2, RSA> s_getRsaPublicKey;
6460
private static volatile Func<X509Certificate2, RSA> s_getRsaPrivateKey;
6561
private static volatile Func<RSA, byte[], string, byte[]> s_rsaPkcs1SignMethod;
@@ -112,30 +108,6 @@ internal static RSA GetRSAPrivateKey(X509Certificate2 cert)
112108
return s_getRsaPrivateKey(cert);
113109
}
114110

115-
internal static DSA GetDSAPublicKey(X509Certificate2 cert)
116-
{
117-
if (s_getDsaPublicKey == null)
118-
{
119-
s_getDsaPublicKey =
120-
BindCoreDelegate<DSA>("DSA", isPublic: true) ??
121-
BindGetCapiPublicKey<DSA, DSACryptoServiceProvider>(DsaOid);
122-
}
123-
124-
return s_getDsaPublicKey(cert);
125-
}
126-
127-
internal static DSA GetDSAPrivateKey(X509Certificate2 cert)
128-
{
129-
if (s_getDsaPrivateKey == null)
130-
{
131-
s_getDsaPrivateKey =
132-
BindCoreDelegate<DSA>("DSA", isPublic: false) ??
133-
BindGetCapiPrivateKey<DSA>(DsaOid, csp => new DSACryptoServiceProvider(csp));
134-
}
135-
136-
return s_getDsaPrivateKey(cert);
137-
}
138-
139111
#if !CNG_LIGHTUP_NO_SYSTEM_CORE
140112
internal static ECDsa GetECDsaPublicKey(X509Certificate2 cert)
141113
{
@@ -526,7 +498,6 @@ private static Func<X509Certificate2, T> BindCoreDelegate<T>(string algorithmNam
526498
// Load System.Core.dll and load the appropriate extension class
527499
// (one of
528500
// System.Security.Cryptography.X509Certificates.RSACertificateExtensions
529-
// System.Security.Cryptography.X509Certificates.DSACertificateExtensions
530501
// System.Security.Cryptography.X509Certificates.ECDsaCertificateExtensions
531502
// )
532503
string typeName = "System.Security.Cryptography.X509Certificates." + algorithmName + "CertificateExtensions";
@@ -547,8 +518,6 @@ private static Func<X509Certificate2, T> BindCoreDelegate<T>(string algorithmNam
547518
// (one of
548519
// GetRSAPublicKey(this X509Certificate2 c)
549520
// GetRSAPrivateKey(this X509Certificate2 c)
550-
// GetDSAPublicKey(this X509Certificate2 c)
551-
// GetDSAPrivateKey(this X509Certificate2 c)
552521
// GetECDsaPublicKey(this X509Certificate2 c)
553522
// GetECDsaPrivateKey(this X509Certificate2 c)
554523
// )

0 commit comments

Comments
 (0)