예제 #1
0
        public void LoadXml()
        {
            const string pValue           = "oDZlcdJA1Kf6UeNEIZqm4KDqA6zpX7CmEtAGWi9pgnBhWOUDVEfhswfsvTLR5BCbKfE6KoHvt5Hh8D1RcAko//iZkLZ+gds9y/5Oxape8tu3TUi1BnNPWu8ieXjMtdnpyudKFsCymssJked1rBeRePG23HTVwOV1DpopjRkjBEU=";
            const string qValue           = "0JxsZhjbIteTbrtfWmt5Uif6il8=";
            const string gValue           = "EOVCfv1saTWIc6Dgim24a07dqqyCJXmIT+5PrgrfV3M8/hfmaMfZtpvM0BUkXVv0dFScnN7txnSpnLWchBz0RfehL6c7Mofu/d2H1cp8zvwTasfiJhypQHDuC4p1aSXuQ1hnzzyYeHKzBH9r0PA78haL7/HnwrrscttXGhmU/L0=";
            const string yValue           = "HBHSdiOJDoZhRpK+B4Ft5hisHvRjz6rELay+aPrya2yKRUUN7ZysNi12PltAvljexay0gEpPncg6TrRtH1+7usTxbgkuIwcQ3RPPIzM7y+XldbcyVUfyze5+zXy9ALiugT+zP8DOMRj9Yj6kR6ZsgbnSdlH2hGIn9NctXgRQ6Kg=";
            const string seedValue        = "NKemrvYwT/4u8DNiXoPj9jO6LAg=";
            const string pgenCounterValue = "uA==";
            string       dsaKey           = $"<KeyValue xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><DSAKeyValue><P>{pValue}</P><Q>{qValue}</Q><G>{gValue}</G><Y>{yValue}</Y><Seed>{seedValue}</Seed><PgenCounter>{pgenCounterValue}</PgenCounter></DSAKeyValue></KeyValue>";

            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(dsaKey);

            var dsaKeyValue = new DsaKeyValue();

            dsaKeyValue.LoadXml(xmlDoc.DocumentElement);

            var parameters = dsaKeyValue.GetKey().Parameters;

            Assert.Equal(Convert.ToBase64String(parameters.P.ToByteArray()), pValue);
            Assert.Equal(Convert.ToBase64String(parameters.Q.ToByteArray()), qValue);
            Assert.Equal(Convert.ToBase64String(parameters.G.ToByteArray()), gValue);
            Assert.Equal(Convert.ToBase64String(dsaKeyValue.GetKey().Y.ToByteArray()), yValue);
            var seed = parameters.ValidationParameters.GetSeed();

            Assert.NotNull(seed);
            Assert.Equal(Convert.ToBase64String(seed), seedValue);
            Assert.Equal(BitConverter.GetBytes(parameters.ValidationParameters.Counter)[0], Convert.FromBase64String(pgenCounterValue)[0]);
        }
예제 #2
0
        public void LoadXml_Null()
        {
            DsaKeyValue dsa1 = new DsaKeyValue();

            Assert.Throws <ArgumentNullException>(() => dsa1.LoadXml(null));
        }