Beispiel #1
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);
 }
 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));
     }
 }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
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));
        }