예제 #1
0
        /// <summary>
        /// Create and initialize RSAParameters structure
        /// </summary>
        /// <returns>Initialized structure</returns>
        /// <note>http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsaparameters.aspx</note>
        public RSAParameters ToRSAParameters()
        {
            var @params = RSAPubKey.ToRSAParameters();

            @params.N = new byte[Modulus.Length];

            for (int i = 0; i < @params.N.Length; i++)
            {
                @params.N[i] = Modulus[Modulus.Length - i - 1];
            }

            return(@params);
        }
예제 #2
0
        /// <summary>
        /// Create and initialize RSAParameters structure
        /// </summary>
        /// <returns>Initialized structure</returns>
        /// <note>http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsaparameters.aspx</note>
        public RSAParameters ToRSAParameters()
        {
            var @params = RSAPubKey.ToRSAParameters();

            @params.N = new byte[Modulus.Length];
            for (int i = 0; i < @params.N.Length; i++)
            {
                @params.N[i] = Modulus[Modulus.Length - i - 1];
            }

            @params.P = new byte[Prime1.Length];
            for (int i = 0; i < @params.P.Length; i++)
            {
                @params.P[i] = Prime1[Prime1.Length - i - 1];
            }

            @params.Q = new byte[Prime2.Length];
            for (int i = 0; i < @params.Q.Length; i++)
            {
                @params.Q[i] = Prime2[Prime2.Length - i - 1];
            }

            @params.DP = new byte[Exponent1.Length];
            for (int i = 0; i < @params.DP.Length; i++)
            {
                @params.DP[i] = Exponent1[Exponent1.Length - i - 1];
            }

            @params.DQ = new byte[Exponent2.Length];
            for (int i = 0; i < @params.DQ.Length; i++)
            {
                @params.DQ[i] = Exponent2[Exponent2.Length - i - 1];
            }

            @params.IQ = new byte[Coefficient.Length];
            for (int i = 0; i < @params.IQ.Length; i++)
            {
                @params.IQ[i] = Coefficient[Coefficient.Length - i - 1];
            }

            @params.D = new byte[PrivateExponent.Length];
            for (int i = 0; i < @params.D.Length; i++)
            {
                @params.D[i] = PrivateExponent[PrivateExponent.Length - i - 1];
            }

            return(@params);
        }