Example #1
0
        public RsaPrivateKey(RSAParameters parameters)
        {
            if (parameters.D == null ||
                parameters.DP == null ||
                parameters.DQ == null ||
                parameters.InverseQ == null ||
                parameters.P == null ||
                parameters.Q == null
                )
            {
                throw new ArgumentException("It looks like provided parameter is not private key", nameof(parameters));
            }

            Key = RsaKeyEncoder.Encode(parameters);
        }
Example #2
0
        /// <summary>
        /// Constructor accepts parameters, only stores public part of the key
        /// </summary>
        /// <param name="parameters">RSA parameters</param>
        public RsaPublicKey(RSAParameters parameters)
        {
            if (parameters.Modulus == null ||
                parameters.Exponent == null
                )
            {
                throw new ArgumentException("It looks like provided parameters are not set.", nameof(parameters));
            }

            parameters.D        = null;
            parameters.DP       = null;
            parameters.DQ       = null;
            parameters.InverseQ = null;
            parameters.P        = null;
            parameters.Q        = null;

            Key = RsaKeyEncoder.Encode(parameters);
        }