1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Internal.Cryptography; 6 7 namespace System.Security.Cryptography 8 { 9 public sealed partial class DSACng : DSA 10 { 11 /// <summary> 12 /// Creates a new DSACng object that will use the specified key. The key's 13 /// <see cref="CngKey.AlgorithmGroup" /> must be Dsa. This constructor 14 /// creates a copy of the key. Hence, the caller can safely dispose of the 15 /// passed in key and continue using the DSACng object. 16 /// </summary> 17 /// <param name="key">Key to use for DSA operations</param> 18 /// <exception cref="ArgumentException">if <paramref name="key" /> is not an DSA key</exception> 19 /// <exception cref="ArgumentNullException">if <paramref name="key" /> is null.</exception> DSACng(CngKey key)20 public DSACng(CngKey key) 21 { 22 if (key == null) 23 throw new ArgumentNullException(nameof(key)); 24 25 if (key.AlgorithmGroup != CngAlgorithmGroup.Dsa) 26 throw new ArgumentException(SR.Cryptography_ArgDSARequiresDSAKey, nameof(key)); 27 28 Key = CngAlgorithmCore.Duplicate(key); 29 } 30 Dispose(bool disposing)31 protected override void Dispose(bool disposing) 32 { 33 _core.Dispose(); 34 } 35 36 private CngAlgorithmCore _core; 37 } 38 } 39