You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
176
85
protectedvirtualvoidDispose(booldisposing)
177
86
{
178
-
if(_isDisposed)
179
-
{
180
-
return;
181
-
}
182
-
183
-
if(disposing)
184
-
{
185
-
varhash=_hash;
186
-
if(hash!=null)
187
-
{
188
-
hash.Dispose();
189
-
_hash=null;
190
-
}
191
-
192
-
_isDisposed=true;
193
-
}
194
-
}
195
-
196
-
/// <summary>
197
-
/// Finalizes an instance of the <see cref="DsaDigitalSignature"/> class.
@@ -147,6 +154,54 @@ public DsaKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y, BigInteger
147
154
G=g;
148
155
Y=y;
149
156
X=x;
157
+
158
+
DSA=LoadDSA();
159
+
}
160
+
161
+
#pragma warning disable CA1859// Use concrete types when possible for improved performance
162
+
#pragma warning disable CA5384// Do Not Use Digital Signature Algorithm (DSA)
163
+
privateDSALoadDSA()
164
+
{
165
+
#if NETFRAMEWORK
166
+
// On .NET Framework we use the concrete CNG type which is FIPS-186-3
167
+
// compatible. The CryptoServiceProvider type returned by DSA.Create()
168
+
// is limited to FIPS-186-1 (max 1024 bit key).
169
+
vardsa=newDSACng();
170
+
#else
171
+
vardsa=DSA.Create();
172
+
#endif
173
+
dsa.ImportParameters(GetDSAParameters());
174
+
175
+
returndsa;
176
+
}
177
+
#pragma warning restore CA5384// Do Not Use Digital Signature Algorithm (DSA)
178
+
#pragma warning restore CA1859// Use concrete types when possible for improved performance
179
+
180
+
internalDSAParametersGetDSAParameters()
181
+
{
182
+
// P, G, Y, Q are required.
183
+
// P, G, Y must have the same length.
184
+
// If X is present, it must have the same length as Q.
185
+
186
+
// See https://github.com/dotnet/runtime/blob/fadd8313653f71abd0068c8bf914be88edb2c8d3/src/libraries/Common/src/System/Security/Cryptography/DSACng.ImportExport.cs#L23
187
+
// and https://github.com/dotnet/runtime/blob/fadd8313653f71abd0068c8bf914be88edb2c8d3/src/libraries/Common/src/System/Security/Cryptography/DSAKeyFormatHelper.cs#L18
/// <param name="disposing"><see langword="true"/> to release both managed and unmanaged resources; <see langword="false"/> to release only unmanaged resources.</param>
165
220
protectedvirtualvoidDispose(booldisposing)
166
221
{
167
-
if(_isDisposed)
168
-
{
169
-
return;
170
-
}
171
-
172
222
if(disposing)
173
223
{
174
-
vardigitalSignature=_digitalSignature;
175
-
if(digitalSignature!=null)
176
-
{
177
-
digitalSignature.Dispose();
178
-
_digitalSignature=null;
179
-
}
180
-
181
-
_isDisposed=true;
224
+
_digitalSignature?.Dispose();
225
+
DSA.Dispose();
182
226
}
183
227
}
184
-
185
-
/// <summary>
186
-
/// Finalizes an instance of the <see cref="DsaKey"/> class.
0 commit comments