public void WriteAndReadECParameters(ECParameters parameters, int keySize)
        {
            parameters.Validate();

            var xmlString = ECParametersFormatter.ToXmlString(parameters);

            Assert.False(string.IsNullOrEmpty(xmlString));

            // TODO: fix big integer value validation
            var settings = new XmlReaderSettings
            {
                ConformanceLevel = ConformanceLevel.Document,
                //ValidationType = ValidationType.Schema,
                //Schemas = ECDsaXmlSchemaSet,
                //ValidationFlags =
                //    XmlSchemaValidationFlags.ProcessInlineSchema |
                //    XmlSchemaValidationFlags.ProcessSchemaLocation |
                //    XmlSchemaValidationFlags.ReportValidationWarnings,
            };

            using (var textReader = new StringReader(xmlString))
                using (var reader = XmlReader.Create(textReader, settings))
                    while (reader.Read())
                    {
                        ;
                    }

            var newParameters = ECParametersFormatter.FromXml(xmlString, keySize);

            ECHelper.AssertEqual(parameters, newParameters, false);
        }
Example #2
0
        protected void WriteAndReadXmlString(ECParameters parameters)
        {
            parameters.Validate();

            string xmlString;

            using (var algorithm = Create(parameters))
                xmlString = algorithm.ToXmlString(false);

            Assert.False(string.IsNullOrEmpty(xmlString));

            ECParameters newParameters;

            using (var algorithm = Create(xmlString))
                newParameters = algorithm.ExportParameters(false);

            ECHelper.AssertEqual(parameters, newParameters, false);
        }
Example #3
0
        protected void CheckExportParameters(ECParameters parameters)
        {
            ECParameters exportedParameters;

            using var algorithm = Create(parameters);
            exportedParameters  = algorithm.ExportParameters(false);

            exportedParameters.Validate();
            ECHelper.AssertEqual(parameters, exportedParameters, false);
            Assert.Null(exportedParameters.D);

            if (parameters.D != null)
            {
                exportedParameters = algorithm.ExportParameters(true);
                exportedParameters.Validate();
                ECHelper.AssertEqual(parameters, exportedParameters, true);
            }
        }