Пример #1
0
        /// <summary>
        /// Returns the *.config file XML section representing this public key.
        /// </summary>
        public string ToConfigSection()
        {
            var sb = new StringBuilder();

            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyModulus, Modulus));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyExponent, Exponent));
            return(sb.ToString());
        }
Пример #2
0
        /// <summary>
        /// Converts this public key to its XML string representation.
        /// </summary>
        public string ToXml()
        {
            var sb = new StringBuilder();

            sb.Append(KeyPairUtils.WriteXmlNode(KeyPairUtils.ElementParent));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementModulus, Modulus));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementExponent, Exponent));
            sb.Append(KeyPairUtils.WriteXmlNode(KeyPairUtils.ElementParent, true));
            return(sb.ToString());
        }
Пример #3
0
 /// <summary>
 /// Loads the private key from an XML string.
 /// </summary>
 public void LoadFromXml(string keyXml)
 {
     Modulus         = KeyPairUtils.GetXmlElement(keyXml, "Modulus");
     Exponent        = KeyPairUtils.GetXmlElement(keyXml, "Exponent");
     PrimeP          = KeyPairUtils.GetXmlElement(keyXml, "P");
     PrimeQ          = KeyPairUtils.GetXmlElement(keyXml, "Q");
     PrimeExponentP  = KeyPairUtils.GetXmlElement(keyXml, "DP");
     PrimeExponentQ  = KeyPairUtils.GetXmlElement(keyXml, "DQ");
     Coefficient     = KeyPairUtils.GetXmlElement(keyXml, "InverseQ");
     PrivateExponent = KeyPairUtils.GetXmlElement(keyXml, "D");
 }
Пример #4
0
        /// <summary>
        /// Returns the *.config file XML section representing this private key.
        /// </summary>
        public string ToConfigSection()
        {
            var sb = new StringBuilder();

            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyModulus, Modulus));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyExponent, Exponent));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyPrimeP, PrimeP));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyPrimeQ, PrimeQ));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyPrimeExponentP, PrimeExponentP));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyPrimeExponentQ, PrimeExponentQ));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyCoefficient, Coefficient));
            sb.Append(KeyPairUtils.WriteConfigKey(KeyPairUtils.KeyPrivateExponent, PrivateExponent));
            return(sb.ToString());
        }
Пример #5
0
        /// <summary>
        /// Converts this private key to its XML string representation.
        /// </summary>
        public string ToXml()
        {
            var sb = new StringBuilder();

            sb.Append(KeyPairUtils.WriteXmlNode(KeyPairUtils.ElementParent));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementModulus, Modulus));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementExponent, Exponent));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementPrimeP, PrimeP));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementPrimeQ, PrimeQ));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementPrimeExponentP, PrimeExponentP));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementPrimeExponentQ, PrimeExponentQ));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementCoefficient, Coefficient));
            sb.Append(KeyPairUtils.WriteXmlElement(KeyPairUtils.ElementPrivateExponent, PrivateExponent));
            sb.Append(KeyPairUtils.WriteXmlNode(KeyPairUtils.ElementParent, true));
            return(sb.ToString());
        }
Пример #6
0
 /// <summary>
 /// Loads the public key from an XML string.
 /// </summary>
 public void LoadFromXml(string keyXml)
 {
     Modulus  = KeyPairUtils.GetXmlElement(keyXml, "Modulus");
     Exponent = KeyPairUtils.GetXmlElement(keyXml, "Exponent");
 }