예제 #1
0
 /// <summary>
 ///     Initializes the RSA Provider with either only a public key or a public/private key pair.
 /// </summary>
 /// <param name="rsaKeyInfo">The XML string to initialize the RSA Provider with.</param>
 /// <param name="keySize">The length of the key.</param>
 /// <returns>PowerRSA object initialized with XML string.</returns>
 public PowerRSA(string rsaKeyInfo, int keySize)
 {
     KeySize = keySize;
     var keyLength = keySize;
     CryptoServiceProvider = new RSACryptoServiceProvider(keyLength);
     CryptoServiceProvider.FromXmlString(rsaKeyInfo);
     rsaProvider = new RSAProvider(rsaKeyInfo, keyLength);
     rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA256;
 }
예제 #2
0
        /// <summary>
        ///     Initializes the RSA Provider with either only a public key or a public/private key pair.
        /// </summary>
        /// <param name="rsaKeyInfo">The XML string to initialize the RSA Provider with.</param>
        /// <param name="keySize">The length of the key.</param>
        /// <returns>PowerRSA object initialized with XML string.</returns>
        public PowerRSA(string rsaKeyInfo, int keySize)
        {
            KeySize = keySize;
            var keyLength = keySize;

            CryptoServiceProvider = new RSACryptoServiceProvider(keyLength);
            CryptoServiceProvider.FromXmlString(rsaKeyInfo);
            rsaProvider = new RSAProvider(rsaKeyInfo, keyLength);
            rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA256;
        }
예제 #3
0
        /// <summary>
        ///     Initializes the RSA Provider with either only a public key or a public/private key pair.
        /// </summary>
        /// <param name="rsaKeyInfo">The XML string to initialize the RSA Provider with.</param>
        /// <param name="keySize">The length of the key.</param>
        /// <param name="hashAlgorithm">The hash algorithm to use.</param>
        /// <returns>PowerRSA object initialized with XML string.</returns>
        public PowerRSA(string rsaKeyInfo, int keySize, PHashAlgorithm hashAlgorithm)
        {
            KeySize = keySize;
            var keyLength = keySize;
            CryptoServiceProvider = new RSACryptoServiceProvider(keyLength);
            CryptoServiceProvider.FromXmlString(rsaKeyInfo);
            rsaProvider = new RSAProvider(rsaKeyInfo, keyLength);
            switch ((int) hashAlgorithm)
            {
                case 0:
                    rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA1;
                    break;

                case 1:
                    rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA256;
                    break;

                case 2:
                    rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA512;
                    break;
            }
        }
예제 #4
0
        /// <summary>
        ///     Initializes the RSA Provider with either only a public key or a public/private key pair.
        /// </summary>
        /// <param name="rsaKeyInfo">The XML string to initialize the RSA Provider with.</param>
        /// <param name="keySize">The length of the key.</param>
        /// <param name="hashAlgorithm">The hash algorithm to use.</param>
        /// <returns>PowerRSA object initialized with XML string.</returns>
        public PowerRSA(string rsaKeyInfo, int keySize, PHashAlgorithm hashAlgorithm)
        {
            KeySize = keySize;
            var keyLength = keySize;

            CryptoServiceProvider = new RSACryptoServiceProvider(keyLength);
            CryptoServiceProvider.FromXmlString(rsaKeyInfo);
            rsaProvider = new RSAProvider(rsaKeyInfo, keyLength);
            switch ((int)hashAlgorithm)
            {
            case 0:
                rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA1;
                break;

            case 1:
                rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA256;
                break;

            case 2:
                rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA512;
                break;
            }
        }
예제 #5
0
        private void InitRSA(int keySize, PHashAlgorithm hashAlgorithm)
        {
            KeySize = keySize;
            var keyLength = keySize;

            CryptoServiceProvider = new RSACryptoServiceProvider(keyLength);
            var rsaKeyInfo = CryptoServiceProvider.ToXmlString(true); //.Replace("><", ">\r\n<");

            rsaProvider = new RSAProvider(rsaKeyInfo, keyLength);
            switch ((int)hashAlgorithm)
            {
            case 0:
                rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA1;
                break;

            case 1:
                rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA256;
                break;

            case 2:
                rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA512;
                break;
            }
        }
예제 #6
0
        private void InitRSA(int keySize, PHashAlgorithm hashAlgorithm)
        {
            KeySize = keySize;
            var keyLength = keySize;
            CryptoServiceProvider = new RSACryptoServiceProvider(keyLength);
            var rsaKeyInfo = CryptoServiceProvider.ToXmlString(true); //.Replace("><", ">\r\n<");
            rsaProvider = new RSAProvider(rsaKeyInfo, keyLength);
            switch ((int) hashAlgorithm)
            {
                case 0:
                    rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA1;
                    break;

                case 1:
                    rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA256;
                    break;

                case 2:
                    rsaProvider.RSAProviderHashAlgorithm = RSAProviderParameters.RSAProviderHashAlgorithm.SHA512;
                    break;
            }
        }