{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/57336715","id":57336715,"diff_hunk":"@@ -0,0 +1,278 @@\n+﻿// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using Microsoft.Win32.SafeHandles;\n+\n+namespace System.Security.Cryptography\n+{\n+    public sealed partial class ECDsaOpenSsl : ECDsa\n+    {\n+        /// <summary>\n+        ///         ImportParameters will replace the existing key that ECDsaOpenSsl is working with by creating a\n+        ///         new CngKey. If the parameters structure contains only Q,\n+        ///         then only a public key will be imported. If the parameters also contains d, \n+        ///         then a full key pair will be imported. If the parameters do not specify Q,\n+        ///         a then a full key pair will be created.\n+        ///         The Curve value is required to specify what other values are imported.\n+        /// </summary>\n+        /// <exception cref=\"CryptographicException\">\n+        ///     if <paramref name=\"parameters\" /> is not a valid ECDsa key or is missing values.\n+        /// </exception>\n+        public override void ImportParameters(ECParameters parameters)\n+        {\n+            bool includePrivate;\n+            if (parameters.d == null && IsPublicKeyDefined(parameters))\n+            {\n+                includePrivate = false;\n+            }\n+            else\n+            {\n+                includePrivate = true;\n+            }\n+\n+            SafeEcKeyHandle key;\n+            if (parameters.Curve is ECPrimeCurve)\n+            {\n+                ECPrimeCurve curve = (ECPrimeCurve)parameters.Curve;\n+\n+                if (!ValidateExplicitCurve(curve))\n+                    throw new CryptographicException(SR.Argument_InvalidValue);// Cryptography_InvalidECPrimeCurveParameters);\n+\n+                key = ImportPrimeCurveParameters(parameters, curve, includePrivate);\n+            }\n+            else if (parameters.Curve is ECCharacteristic2Curve)\n+            {\n+                ECCharacteristic2Curve curve = (ECCharacteristic2Curve)parameters.Curve;\n+                try {\n+                    //TODO if (!ValidateExplicitCurve(curve, cbKey))\n+                    //    throw new CryptographicException(SR.Argument_InvalidValue);// Cryptography_InvalidECPrimeCurveParameters);\n+                    key = ImportCharacteristic2CurveParameters(parameters, curve, includePrivate);\n+                }catch(Exception e)\n+                {\n+                    Interop.Crypto.OutputDebugString(e.ToString() + e.StackTrace);\n+                    key = null;\n+                }\n+            }\n+            else if (parameters.Curve is ECNamedCurve)\n+            {\n+                ECNamedCurve curve = (ECNamedCurve)parameters.Curve;\n+\n+                if (!ValidateNamedCurve(curve))\n+                    throw new CryptographicException(SR.Argument_InvalidValue);// Cryptography_InvalidECNamedCurveParameters);\n+\n+                key = ImportNamedCurveParameters(parameters, curve, includePrivate);\n+            }\n+            else\n+            {\n+                throw new NotSupportedException();\n+            }\n+\n+            SetKey(key);\n+        }\n+\n+        /// <summary>\n+        ///     Exports the key used by the ECC object into an ECParameters object.\n+        /// </summary>\n+        public override ECParameters ExportExplicitCurveParameters(bool includePrivateParameters)\n+        {\n+            // todo char2 curve\n+            SafeEcKeyHandle currentKey = _key.Value;\n+\n+            ECParameters ecparams = ExportExplicitCurveParameters(currentKey, includePrivateParameters);\n+            return ecparams;\n+        }\n+\n+        /// <summary>\n+        ///     Exports the key used by the ECC object into an ECParameters object.\n+        /// </summary>\n+        public override ECParameters ExportNamedCurveParameters(bool includePrivateParameters)\n+        {\n+            SafeEcKeyHandle currentKey = _key.Value;\n+\n+            ECParameters ecparams = ExportNamedCurveParameters(currentKey, includePrivateParameters);\n+            string keyOidValueName = Interop.Crypto.EcKeyGetOidValueCurveName(currentKey);\n+            string keyOidFriendlyName = Interop.Crypto.EcKeyGetOidFriendyCurveName(keyOidValueName);","path":"src/System.Security.Cryptography.OpenSsl/src/System/Security/Cryptography/ECDsaOpenSsl.ImportExport.cs","position":88,"original_position":95,"commit_id":"f6ad10a2e3334ec10be8711e6e9c00c465be86db","original_commit_id":"f277b150bb80b5007223798c32694ba78c2281f9","user":{"login":"steveharter","id":6986755,"avatar_url":"https://avatars.githubusercontent.com/u/6986755?v=3","gravatar_id":"","url":"https://api.github.com/users/steveharter","html_url":"https://github.com/steveharter","followers_url":"https://api.github.com/users/steveharter/followers","following_url":"https://api.github.com/users/steveharter/following{/other_user}","gists_url":"https://api.github.com/users/steveharter/gists{/gist_id}","starred_url":"https://api.github.com/users/steveharter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveharter/subscriptions","organizations_url":"https://api.github.com/users/steveharter/orgs","repos_url":"https://api.github.com/users/steveharter/repos","events_url":"https://api.github.com/users/steveharter/events{/privacy}","received_events_url":"https://api.github.com/users/steveharter/received_events","type":"User","site_admin":false},"body":"I was not using the single-string version of the ctor so I will change to use that. I was using the double-string version or the .From methods which throw.\r\n\r\nAlso, the comments in the code for the Oid(string) ctor are misleading, as it states it looks up value from friendly name and doesn't say it also looks up friendlyname from value.\r\n// If we were passed the friendly name, retrieve the value String.\r\n","created_at":"2016-03-24T15:40:30Z","updated_at":"2016-03-24T15:40:30Z","html_url":"https://github.com/dotnet/corefx/pull/6789#discussion_r57336715","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/6789","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/57336715"},"html":{"href":"https://github.com/dotnet/corefx/pull/6789#discussion_r57336715"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6789"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/6789","id":62315654,"html_url":"https://github.com/dotnet/corefx/pull/6789","diff_url":"https://github.com/dotnet/corefx/pull/6789.diff","patch_url":"https://github.com/dotnet/corefx/pull/6789.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/6789","number":6789,"state":"open","locked":false,"title":"WIP DONT MERGE Support Elliptical Curve Cryptography named curves and export","user":{"login":"steveharter","id":6986755,"avatar_url":"https://avatars.githubusercontent.com/u/6986755?v=3","gravatar_id":"","url":"https://api.github.com/users/steveharter","html_url":"https://github.com/steveharter","followers_url":"https://api.github.com/users/steveharter/followers","following_url":"https://api.github.com/users/steveharter/following{/other_user}","gists_url":"https://api.github.com/users/steveharter/gists{/gist_id}","starred_url":"https://api.github.com/users/steveharter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveharter/subscriptions","organizations_url":"https://api.github.com/users/steveharter/orgs","repos_url":"https://api.github.com/users/steveharter/repos","events_url":"https://api.github.com/users/steveharter/events{/privacy}","received_events_url":"https://api.github.com/users/steveharter/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-09T23:39:22Z","updated_at":"2016-03-24T15:40:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cddcfe2002b74dd874e12c46aefbf33265a506e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/6789/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/6789/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/6789/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/f6ad10a2e3334ec10be8711e6e9c00c465be86db","head":{"label":"steveharter:Crypto","ref":"Crypto","sha":"f6ad10a2e3334ec10be8711e6e9c00c465be86db","user":{"login":"steveharter","id":6986755,"avatar_url":"https://avatars.githubusercontent.com/u/6986755?v=3","gravatar_id":"","url":"https://api.github.com/users/steveharter","html_url":"https://github.com/steveharter","followers_url":"https://api.github.com/users/steveharter/followers","following_url":"https://api.github.com/users/steveharter/following{/other_user}","gists_url":"https://api.github.com/users/steveharter/gists{/gist_id}","starred_url":"https://api.github.com/users/steveharter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveharter/subscriptions","organizations_url":"https://api.github.com/users/steveharter/orgs","repos_url":"https://api.github.com/users/steveharter/repos","events_url":"https://api.github.com/users/steveharter/events{/privacy}","received_events_url":"https://api.github.com/users/steveharter/received_events","type":"User","site_admin":false},"repo":{"id":39029448,"name":"dotnet_corefx","full_name":"steveharter/dotnet_corefx","owner":{"login":"steveharter","id":6986755,"avatar_url":"https://avatars.githubusercontent.com/u/6986755?v=3","gravatar_id":"","url":"https://api.github.com/users/steveharter","html_url":"https://github.com/steveharter","followers_url":"https://api.github.com/users/steveharter/followers","following_url":"https://api.github.com/users/steveharter/following{/other_user}","gists_url":"https://api.github.com/users/steveharter/gists{/gist_id}","starred_url":"https://api.github.com/users/steveharter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveharter/subscriptions","organizations_url":"https://api.github.com/users/steveharter/orgs","repos_url":"https://api.github.com/users/steveharter/repos","events_url":"https://api.github.com/users/steveharter/events{/privacy}","received_events_url":"https://api.github.com/users/steveharter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/steveharter/dotnet_corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":true,"url":"https://api.github.com/repos/steveharter/dotnet_corefx","forks_url":"https://api.github.com/repos/steveharter/dotnet_corefx/forks","keys_url":"https://api.github.com/repos/steveharter/dotnet_corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/steveharter/dotnet_corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/steveharter/dotnet_corefx/teams","hooks_url":"https://api.github.com/repos/steveharter/dotnet_corefx/hooks","issue_events_url":"https://api.github.com/repos/steveharter/dotnet_corefx/issues/events{/number}","events_url":"https://api.github.com/repos/steveharter/dotnet_corefx/events","assignees_url":"https://api.github.com/repos/steveharter/dotnet_corefx/assignees{/user}","branches_url":"https://api.github.com/repos/steveharter/dotnet_corefx/branches{/branch}","tags_url":"https://api.github.com/repos/steveharter/dotnet_corefx/tags","blobs_url":"https://api.github.com/repos/steveharter/dotnet_corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/steveharter/dotnet_corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/steveharter/dotnet_corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/steveharter/dotnet_corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/steveharter/dotnet_corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/steveharter/dotnet_corefx/languages","stargazers_url":"https://api.github.com/repos/steveharter/dotnet_corefx/stargazers","contributors_url":"https://api.github.com/repos/steveharter/dotnet_corefx/contributors","subscribers_url":"https://api.github.com/repos/steveharter/dotnet_corefx/subscribers","subscription_url":"https://api.github.com/repos/steveharter/dotnet_corefx/subscription","commits_url":"https://api.github.com/repos/steveharter/dotnet_corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/steveharter/dotnet_corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/steveharter/dotnet_corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/steveharter/dotnet_corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/steveharter/dotnet_corefx/contents/{+path}","compare_url":"https://api.github.com/repos/steveharter/dotnet_corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/steveharter/dotnet_corefx/merges","archive_url":"https://api.github.com/repos/steveharter/dotnet_corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/steveharter/dotnet_corefx/downloads","issues_url":"https://api.github.com/repos/steveharter/dotnet_corefx/issues{/number}","pulls_url":"https://api.github.com/repos/steveharter/dotnet_corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/steveharter/dotnet_corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/steveharter/dotnet_corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/steveharter/dotnet_corefx/labels{/name}","releases_url":"https://api.github.com/repos/steveharter/dotnet_corefx/releases{/id}","deployments_url":"https://api.github.com/repos/steveharter/dotnet_corefx/deployments","created_at":"2015-07-13T18:20:31Z","updated_at":"2016-01-13T22:53:29Z","pushed_at":"2016-03-23T23:04:54Z","git_url":"git://github.com/steveharter/dotnet_corefx.git","ssh_url":"git@github.com:steveharter/dotnet_corefx.git","clone_url":"https://github.com/steveharter/dotnet_corefx.git","svn_url":"https://github.com/steveharter/dotnet_corefx","homepage":"http://dotnet.github.io/core/","size":59785,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"181e6331d98acbf976ace048c63101feec0f612f","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corefx/deployments","created_at":"2014-11-06T23:42:48Z","updated_at":"2016-03-24T10:51:54Z","pushed_at":"2016-03-24T15:33:59Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/","size":82371,"stargazers_count":9368,"watchers_count":9368,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2203,"mirror_url":null,"open_issues_count":933,"forks":2203,"open_issues":933,"watchers":9368,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6789"},"html":{"href":"https://github.com/dotnet/corefx/pull/6789"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/6789"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/6789/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6789/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6789/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/f6ad10a2e3334ec10be8711e6e9c00c465be86db"}}}}