Skip to content

Commit 881eefe

Browse files
committed
Appease mono
1 parent f0ca5f3 commit 881eefe

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.editorconfig

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Avoid looking for .editorconfig files in parent directories
1+
// Avoid looking for .editorconfig files in parent directories
22
root=true
33

44
[*]
@@ -87,6 +87,10 @@ dotnet_diagnostic.S1144.severity = none
8787
# This is a duplicate of IDE0060.
8888
dotnet_diagnostic.S1172.severity = none
8989

90+
# S1199: Nested code blocks should not be used
91+
# https://rules.sonarsource.com/csharp/RSPEC-1199
92+
dotnet_diagnostic.S1199.severity = none
93+
9094
# S1481: Unused local variables should be removed
9195
# https://rules.sonarsource.com/csharp/RSPEC-1481
9296
#

src/Renci.SshNet/Security/Cryptography/DsaKey.cs

+13-5
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,32 @@ public DsaKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y, BigInteger
158158
DSA = LoadDSA();
159159
}
160160

161-
#pragma warning disable CA1859 // Use concrete types when possible for improved performance
162161
#pragma warning disable CA5384 // Do Not Use Digital Signature Algorithm (DSA)
163162
private DSA LoadDSA()
164163
{
164+
DSA dsa;
165+
165166
#if NETFRAMEWORK
166167
// On .NET Framework we use the concrete CNG type which is FIPS-186-3
167168
// compatible. The CryptoServiceProvider type returned by DSA.Create()
168169
// is limited to FIPS-186-1 (max 1024 bit key).
169-
var dsa = new DSACng();
170-
#else
171-
var dsa = DSA.Create();
170+
171+
// We give some consideration to a mono build on non-Windows.
172+
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
173+
{
174+
dsa = new DSACng();
175+
}
176+
else
172177
#endif
178+
{
179+
dsa = DSA.Create();
180+
}
181+
173182
dsa.ImportParameters(GetDSAParameters());
174183

175184
return dsa;
176185
}
177186
#pragma warning restore CA5384 // Do Not Use Digital Signature Algorithm (DSA)
178-
#pragma warning restore CA1859 // Use concrete types when possible for improved performance
179187

180188
internal DSAParameters GetDSAParameters()
181189
{

0 commit comments

Comments
 (0)