Mono Class Library: System.Security.Cryptography.DSACryptoServiceProvider Overview | MembersSystem.Security.Cryptography.DSACryptoServiceProvider.ExportParameters Method |
Export the instance key into a System.Security.Cryptography.DSAParameters structure. [Edit]
|
- includePrivateParameters
- True to include private parameters; otherwise, false. [Edit]
a DSAParameters structure contaning each parameters of the key. [Edit]
A System.Security.Cryptography.CryptographicException is thrown if the private key is requested but not available. Sadly there is not way (before 2.0) to know if the private key is available without throwing an exception. Here is a safe way to test for the private key presence:
C# Example bool IsPrivateKeyAvailable (DSA dsa) { if (dsa == null) throw new ArgumentNullException ("dsa"); try { DSAParameter p = dsa.ExportParameters (true); // private key is available - now zeroize it from memory Array.Clear (p.X, 0, p.X.Length); return true; } catch (CryptographicException) // private key wasn't available return false; } }You are responsable to zeroize the private key (System.Security.Cryptography.DSAParameters.DSAParameters.X) if you export it from the instance.
[Edit]
Namespace: System.Security.Cryptography
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0