public ECDsaCng(CngKey key) { ArgumentNullException.ThrowIfNull(key); if (!IsEccAlgorithmGroup(key.AlgorithmGroup)) { throw new ArgumentException(SR.Cryptography_ArgECDsaRequiresECDsaKey, nameof(key)); } Key = CngAlgorithmCore.Duplicate(key); }
public RSACng(CngKey key) { ArgumentNullException.ThrowIfNull(key); if (key.AlgorithmGroup != CngAlgorithmGroup.Rsa) { throw new ArgumentException(SR.Cryptography_ArgRSARequiresRSAKey, nameof(key)); } Key = CngAlgorithmCore.Duplicate(key); }
public ECDiffieHellmanCng(CngKey key) { ArgumentNullException.ThrowIfNull(key); if (key.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman) { throw new ArgumentException(SR.Cryptography_ArgECDHRequiresECDHKey, nameof(key)); } Key = CngAlgorithmCore.Duplicate(key); }
/// <summary> /// Creates a new Gost3410Cng object that will use the specified key. The key's /// <see cref="CngKey.AlgorithmGroup" /> must be Rsa. This constructor /// creates a copy of the key. Hence, the caller can safely dispose of the /// passed in key and continue using the Gost3410Cng object. /// </summary> /// <param name="key">Key to use for Gost3410 operations</param> /// <exception cref="ArgumentException">if <paramref name="key" /> is not an Gost3410 key</exception> /// <exception cref="ArgumentNullException">if <paramref name="key" /> is null.</exception> public Gost3410Cng(CngKey key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (key.AlgorithmGroup != CngAlgorithmGroup.Gost3410) { throw new ArgumentException(SR.Cryptography_ArgGost3410RequiresGost3410Key, nameof(key)); } Key = CngAlgorithmCore.Duplicate(key); }
/// <summary> /// Creates a new ECDsaCng object that will use the specified key. The key's /// <see cref="CngKey.AlgorithmGroup" /> must be ECDsa. This constructor /// creates a copy of the key. Hence, the caller can safely dispose of the /// passed in key and continue using the ECDsaCng object. /// </summary> /// <param name="key">Key to use for ECDsa operations</param> /// <exception cref="ArgumentException">if <paramref name="key" /> is not an ECDsa key</exception> /// <exception cref="ArgumentNullException">if <paramref name="key" /> is null.</exception> public ECDsaCng(CngKey key) { if (key == null) { throw new ArgumentNullException("key"); } if (!IsEccAlgorithmGroup(key.AlgorithmGroup)) { throw new ArgumentException(SR.Cryptography_ArgECDsaRequiresECDsaKey, "key"); } Key = CngAlgorithmCore.Duplicate(key); }
public DSACng(CngKey key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (key.AlgorithmGroup != CngAlgorithmGroup.Dsa) { throw new ArgumentException(SR.Cryptography_ArgDSARequiresDSAKey, nameof(key)); } Key = CngAlgorithmCore.Duplicate(key); }
/// <summary> /// Creates a new RSACng object that will use the specified key. The key's /// <see cref="CngKey.AlgorithmGroup" /> must be Rsa. This constructor /// creates a copy of the key. Hence, the caller can safely dispose of the /// passed in key and continue using the RSACng object. /// </summary> /// <param name="key">Key to use for RSA operations</param> /// <exception cref="ArgumentException">if <paramref name="key" /> is not an RSA key</exception> /// <exception cref="ArgumentNullException">if <paramref name="key" /> is null.</exception> public RSACng(CngKey key) { if (key == null) { throw new ArgumentNullException("key"); } if (key.AlgorithmGroup != CngAlgorithmGroup.Rsa) { throw new ArgumentException(SR.Cryptography_ArgRSAaRequiresRSAKey, "key"); } Key = CngAlgorithmCore.Duplicate(key); }