Пример #1
0
 public string ToXmlString(ECKeyXmlFormat format)
 {
     if (format != ECKeyXmlFormat.Rfc4050)
     {
         throw new ArgumentOutOfRangeException("format");
     }
     return(Rfc4050KeyFormatter.ToXml(this.Key));
 }
Пример #2
0
        /// <summary>
        ///     Convert the key blob to XML
        ///
        ///     See code:System.Security.Cryptography.Rfc4050KeyFormatter#RFC4050ECKeyFormat for information
        ///     about the XML format used.
        /// </summary>
        public override string ToXmlString()
        {
            Contract.Ensures(!String.IsNullOrEmpty(Contract.Result <string>()));

            ECParameters ecParams = ExportParameters();

            return(Rfc4050KeyFormatter.ToXml(ecParams, isEcdh: true));
        }
 public override string ToXmlString()
 {
     if (this.m_key == null)
     {
         this.m_key = this.Import();
     }
     return(Rfc4050KeyFormatter.ToXml(this.m_key));
 }
        /// <summary>
        ///     Convert the key blob to XML
        ///
        ///     See code:System.Security.Cryptography.Rfc4050KeyFormatter#RFC4050ECKeyFormat for information
        ///     about the XML format used.
        /// </summary>
        public override string ToXmlString()
        {
            Contract.Ensures(!String.IsNullOrEmpty(Contract.Result <string>()));

            if (m_key == null)
            {
                m_key = Import();
            }

            return(Rfc4050KeyFormatter.ToXml(m_key));
        }
Пример #5
0
        public string ToXmlString(ECKeyXmlFormat format)
        {
            Contract.Ensures(Contract.Result <string>() != null);

            if (format != ECKeyXmlFormat.Rfc4050)
            {
                throw new ArgumentOutOfRangeException("format");
            }

            return(Rfc4050KeyFormatter.ToXml(Key));
        }
Пример #6
0
 public void FromXmlString(string xml, ECKeyXmlFormat format)
 {
     if (xml == null)
     {
         throw new ArgumentNullException("xml");
     }
     if (format != ECKeyXmlFormat.Rfc4050)
     {
         throw new ArgumentOutOfRangeException("format");
     }
     this.Key = Rfc4050KeyFormatter.FromXml(xml);
 }
Пример #7
0
        public string ToXmlString(ECKeyXmlFormat format)
        {
            Contract.Ensures(Contract.Result <string>() != null);

            if (format != ECKeyXmlFormat.Rfc4050)
            {
                throw new ArgumentOutOfRangeException("format");
            }

            ECParameters ecParams = ExportParameters(false);

            return(Rfc4050KeyFormatter.ToXml(ecParams, isEcdh: false));
        }
 public static ECDiffieHellmanCngPublicKey FromXmlString(string xml)
 {
     if (xml == null)
     {
         throw new ArgumentNullException("xml");
     }
     using (CngKey key = Rfc4050KeyFormatter.FromXml(xml))
     {
         if (key.AlgorithmGroup != CngAlgorithmGroup.ECDiffieHellman)
         {
             throw new ArgumentException(System.SR.GetString("Cryptography_ArgECDHRequiresECDHKey"), "xml");
         }
         return(new ECDiffieHellmanCngPublicKey(key));
     }
 }
Пример #9
0
        public void FromXmlString(string xml, ECKeyXmlFormat format)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            if (format != ECKeyXmlFormat.Rfc4050)
            {
                throw new ArgumentOutOfRangeException("format");
            }

            bool         isEcdh;
            ECParameters parameters = Rfc4050KeyFormatter.FromXml(xml, out isEcdh);

            // .NET 4.6.2 allowed ECDsaCng to wrap ECDH keys because of interop with non-Windows PFX files.
            // As a result XML marked as ECDiffieHellman loaded just fine, so no check should be done on the
            // key type.
            ImportParameters(parameters);
        }
Пример #10
0
        public void FromXmlString(string xml, ECKeyXmlFormat format)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }
            if (format != ECKeyXmlFormat.Rfc4050)
            {
                throw new ArgumentOutOfRangeException("format");
            }

            bool         isEcdh;
            ECParameters ecParams = Rfc4050KeyFormatter.FromXml(xml, out isEcdh);

            if (!isEcdh)
            {
                throw new ArgumentException(SR.GetString(SR.Cryptography_ArgECDHRequiresECDHKey), "xml");
            }

            ImportParameters(ecParams);
        }
Пример #11
0
        public static ECDiffieHellmanCngPublicKey FromXmlString(string xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException("xml");
            }

            bool         isEcdh;
            ECParameters parameters = Rfc4050KeyFormatter.FromXml(xml, out isEcdh);

            if (!isEcdh)
            {
                throw new ArgumentException(SR.GetString(SR.Cryptography_ArgECDHRequiresECDHKey), "xml");
            }

            CngKeyBlobFormat format;
            string           curveName;

            byte[] blob = ECCng.EcdhParametersToBlob(ref parameters, out format, out curveName);
            return(new ECDiffieHellmanCngPublicKey(blob, curveName, format));
        }