public override void ImportParameters(DHParameters parameters)
        {
            if (parameters.P == null)
            {
                throw new CryptographicException("Missing P value.");
            }
            if (parameters.G == null)
            {
                throw new CryptographicException("Missing G value.");
            }
            BigInteger p = new BigInteger(parameters.P);
            BigInteger g = new BigInteger(parameters.G);
            BigInteger x = null;

            if (parameters.X != null)
            {
                x = new BigInteger(parameters.X);
            }
            Initialize(p, g, x, 0, checkInput: true);
        }
Exemple #2
0
        public override void FromXmlString(string xmlString)
        {
            if (xmlString == null)
            {
                throw new ArgumentNullException();
            }
            DHParameters parameters = default(DHParameters);

            try
            {
                SecurityParser securityParser = new SecurityParser();
                securityParser.LoadXml(xmlString);
                SecurityElement securityElement = securityParser.ToXml();
                if (securityElement.Tag != "DHKeyValue")
                {
                    throw new CryptographicException();
                }
                parameters.P = GetNamedParam(securityElement, "P");
                parameters.G = GetNamedParam(securityElement, "G");
                parameters.X = GetNamedParam(securityElement, "X");
                ImportParameters(parameters);
            }
            finally
            {
                if (parameters.P != null)
                {
                    Array.Clear(parameters.P, 0, parameters.P.Length);
                }
                if (parameters.G != null)
                {
                    Array.Clear(parameters.G, 0, parameters.G.Length);
                }
                if (parameters.X != null)
                {
                    Array.Clear(parameters.X, 0, parameters.X.Length);
                }
            }
        }
Exemple #3
0
 public abstract void ImportParameters(DHParameters parameters);