コード例 #1
0
ファイル: ECDsaCng.cs プロジェクト: mikem8361/runtime
        public ECDsaCng(CngKey key)
        {
            ArgumentNullException.ThrowIfNull(key);

            if (!IsEccAlgorithmGroup(key.AlgorithmGroup))
            {
                throw new ArgumentException(SR.Cryptography_ArgECDsaRequiresECDsaKey, nameof(key));
            }

            Key = CngAlgorithmCore.Duplicate(key);
        }
コード例 #2
0
        public RSACng(CngKey key)
        {
            ArgumentNullException.ThrowIfNull(key);

            if (key.AlgorithmGroup != CngAlgorithmGroup.Rsa)
            {
                throw new ArgumentException(SR.Cryptography_ArgRSARequiresRSAKey, nameof(key));
            }

            Key = CngAlgorithmCore.Duplicate(key);
        }
コード例 #3
0
        public ECDiffieHellmanCng(CngKey key)
        {
            ArgumentNullException.ThrowIfNull(key);

            if (key.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
            {
                throw new ArgumentException(SR.Cryptography_ArgECDHRequiresECDHKey, nameof(key));
            }

            Key = CngAlgorithmCore.Duplicate(key);
        }
コード例 #4
0
ファイル: Gost3410Cng.cs プロジェクト: dprotopopov/corefx
        /// <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);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: RSACng.cs プロジェクト: traktraktrugui/corefx
        /// <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);
        }