Exemple #1
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));
        }