예제 #1
0
        internal override XmlElement GetXml(XmlDocument xmlDocument)
        {
            XmlElement keyValueElement    = xmlDocument.CreateElement(KeyValueElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);
            XmlElement dsaKeyValueElement = xmlDocument.CreateElement(DSAKeyValueElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);

            XmlElement pElement = xmlDocument.CreateElement(PElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);

            pElement.AppendChild(xmlDocument.CreateTextNode(Convert.ToBase64String(_key.Parameters.P.ToByteArrayUnsigned())));
            dsaKeyValueElement.AppendChild(pElement);

            XmlElement qElement = xmlDocument.CreateElement(QElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);

            qElement.AppendChild(xmlDocument.CreateTextNode(Convert.ToBase64String(_key.Parameters.Q.ToByteArrayUnsigned())));
            dsaKeyValueElement.AppendChild(qElement);

            XmlElement gElement = xmlDocument.CreateElement(GElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);

            gElement.AppendChild(xmlDocument.CreateTextNode(Convert.ToBase64String(_key.Parameters.G.ToByteArrayUnsigned())));
            dsaKeyValueElement.AppendChild(gElement);

            XmlElement yElement = xmlDocument.CreateElement(YElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);

            yElement.AppendChild(xmlDocument.CreateTextNode(Convert.ToBase64String(_key.Y.ToByteArrayUnsigned())));
            dsaKeyValueElement.AppendChild(yElement);


            if (_key.Parameters.ValidationParameters != null)
            {  // note we assume counter is correct if Seed is present
                XmlElement seedElement = xmlDocument.CreateElement(SeedElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);
                seedElement.AppendChild(xmlDocument.CreateTextNode(Convert.ToBase64String(_key.Parameters.ValidationParameters.GetSeed())));
                dsaKeyValueElement.AppendChild(seedElement);

                XmlElement counterElement = xmlDocument.CreateElement(PgenCounterElementName, XmlNameSpace.Url[NS.XmlDsigNamespaceUrl]);
                counterElement.AppendChild(xmlDocument.CreateTextNode(Convert.ToBase64String(EncodingUtils.ConvertIntToByteArray(_key.Parameters.ValidationParameters.Counter))));
                dsaKeyValueElement.AppendChild(counterElement);
            }

            keyValueElement.AppendChild(dsaKeyValueElement);

            return(keyValueElement);
        }