public DSACryptoServiceProvider(int dwKeySize, CspParameters parameters)
        {
            if (dwKeySize < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(dwKeySize), SR.ArgumentOutOfRange_NeedNonNegNum);
            }

            _parameters = CapiHelper.SaveCspParameters(
                CapiHelper.CspAlgorithmType.Dss,
                parameters,
                s_useMachineKeyStore,
                out _randomKeyContainer);

            _keySize = dwKeySize;
            _sha1    = SHA1.Create();

            // If this is not a random container we generate, create it eagerly
            // in the constructor so we can report any errors now.
            if (!_randomKeyContainer)
            {
                // Force-read the SafeKeyHandle property, which will summon it into existence.
                SafeKeyHandle localHandle = SafeKeyHandle;
                Debug.Assert(localHandle != null);
            }
        }
Esempio n. 2
0
        public Gost3410_2012_256CryptoServiceProvider(CspParameters parameters)
        {
            _parameters = CapiHelper.SaveCspParameters(
                CapiHelper.CspAlgorithmType.Gost2012_256,
                parameters,
                s_useMachineKeyStore,
                out _randomKeyContainer);
            _keySpec           = _parameters.KeyNumber;
            LegalKeySizesValue = new KeySizes[] { new KeySizes(GostConstants.GOST3410_2012_256KEY_SIZE, GostConstants.GOST3410_2012_256KEY_SIZE, 0) };

            _hashImpl = Gost3411_2012_256.Create();
            if (!_randomKeyContainer)
            {
                GetKeyPair();
            }
        }
        public Gost3410CryptoServiceProvider(CspParameters parameters)
        {
            _parameters = CapiHelper.SaveCspParameters(
                CapiHelper.CspAlgorithmType.PROV_GOST_2001_DH,
                parameters,
                s_useMachineKeyStore,
                out _randomKeyContainer);
            _keySpec           = _parameters.KeyNumber;
            LegalKeySizesValue = new KeySizes[] { new KeySizes(GostConstants.GOST_3410EL_SIZE, GostConstants.GOST_3410EL_SIZE, 0) };

            _gost3411 = Gost3411.Create();
            if (!_randomKeyContainer)
            {
                GetKeyPair();
            }
        }
        private RSACryptoServiceProvider(int keySize, CspParameters parameters, bool useDefaultKeySize)
        {
            if (keySize < 0)
            {
                throw new ArgumentOutOfRangeException("dwKeySize", "ArgumentOutOfRange_NeedNonNegNum");
            }
            _parameters = CapiHelper.SaveCspParameters(CapiHelper.CspAlgorithmType.Rsa, parameters, s_UseMachineKeyStore, ref _randomKeyContainer);

            _keySize = useDefaultKeySize ? 1024 : keySize;

            // If this is not a random container we generate, create it eagerly
            // in the constructor so we can report any errors now.
            if (!_randomKeyContainer)
            {
                GetKeyPair();
            }
        }
Esempio n. 5
0
        private RSACryptoServiceProvider(int keySize, CspParameters?parameters, bool useDefaultKeySize)
        {
            if (keySize < 0)
            {
                throw new ArgumentOutOfRangeException("dwKeySize", "ArgumentOutOfRange_NeedNonNegNum");
            }

            _parameters = CapiHelper.SaveCspParameters(
                CapiHelper.CspAlgorithmType.Rsa,
                parameters,
                s_useMachineKeyStore,
                out _randomKeyContainer);

            _keySize = useDefaultKeySize ? 1024 : keySize;

            // If this is not a random container we generate, create it eagerly
            // in the constructor so we can report any errors now.
            if (!_randomKeyContainer)
            {
                // Force-read the SafeKeyHandle property, which will summon it into existence.
                SafeCapiKeyHandle localHandle = SafeKeyHandle;
                Debug.Assert(localHandle != null);
            }
        }