{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/55558445","id":55558445,"diff_hunk":"@@ -0,0 +1,139 @@\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 System;\n+using System.Diagnostics;\n+using System.Runtime.InteropServices;\n+using System.Security.Cryptography;\n+\n+using Test.Cryptography;\n+using Xunit;\n+\n+using DATA_BLOB = Interop.Crypt32.DATA_BLOB;\n+using CryptProtectDataFlags = Interop.Crypt32.CryptProtectDataFlags;\n+\n+namespace System.Security.Cryptography.ProtectedDataTests\n+{\n+    public static class ProtectedDataTests\n+    {\n+        [Fact]\n+        public static void RoundTripWithoutEntropyCurrentUser()\n+        {\n+            byte[] plain = { 1, 2, 3 };\n+            RoundTrip(plain, null, DataProtectionScope.CurrentUser);\n+        }\n+\n+        [Fact]\n+        public static void RoundTripWithoutEntropyLocalMachine()\n+        {\n+            byte[] plain = { 1, 2, 3 };\n+            RoundTrip(plain, null, DataProtectionScope.LocalMachine);\n+        }\n+\n+        [Fact]\n+        public static void RoundTripWithEntropyCurrentUser()\n+        {\n+            byte[] plain = { 1, 2, 3 };\n+            byte[] entropy = { 4, 5, 6 };\n+            RoundTrip(plain, null, DataProtectionScope.CurrentUser);\n+        }\n+\n+        [Fact]\n+        public static void RoundTripWithEntropyLocalMachine()\n+        {\n+            byte[] plain = { 1, 2, 3 };\n+            byte[] entropy = { 4, 5, 6 };\n+            RoundTrip(plain, null, DataProtectionScope.LocalMachine);\n+        }\n+\n+        private static void RoundTrip(byte[] plain, byte[] optionalEntropy, DataProtectionScope scope)\n+        {\n+            {\n+                // Protect using CoreFx, unprotect using direct p/invoke.\n+                byte[] encrypted = ProtectedData.Protect(plain, optionalEntropy, scope);\n+                byte[] recovered = UnprotectUsingPInvoke(encrypted, optionalEntropy, scope);","path":"src/System.Security.Cryptography.ProtectedData/tests/ProtectedDataTests.cs","position":55,"original_position":55,"commit_id":"d387d97737697e1c421dc9454fe23239da8a74a3","original_commit_id":"cc8a7040b8ea4ee07b3877462b652052879cb49a","user":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"body":"Assert.NotEqual(plain, encrypted)?","created_at":"2016-03-09T17:47:42Z","updated_at":"2016-03-09T17:47:42Z","html_url":"https://github.com/dotnet/corefx/pull/6773#discussion_r55558445","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/6773","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/55558445"},"html":{"href":"https://github.com/dotnet/corefx/pull/6773#discussion_r55558445"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6773"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/6773","id":62263485,"html_url":"https://github.com/dotnet/corefx/pull/6773","diff_url":"https://github.com/dotnet/corefx/pull/6773.diff","patch_url":"https://github.com/dotnet/corefx/pull/6773.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/6773","number":6773,"state":"open","locked":false,"title":"Implement ProtectedData.Protect() and Unprotect().","user":{"login":"AtsushiKan","id":13223578,"avatar_url":"https://avatars.githubusercontent.com/u/13223578?v=3","gravatar_id":"","url":"https://api.github.com/users/AtsushiKan","html_url":"https://github.com/AtsushiKan","followers_url":"https://api.github.com/users/AtsushiKan/followers","following_url":"https://api.github.com/users/AtsushiKan/following{/other_user}","gists_url":"https://api.github.com/users/AtsushiKan/gists{/gist_id}","starred_url":"https://api.github.com/users/AtsushiKan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AtsushiKan/subscriptions","organizations_url":"https://api.github.com/users/AtsushiKan/orgs","repos_url":"https://api.github.com/users/AtsushiKan/repos","events_url":"https://api.github.com/users/AtsushiKan/events{/privacy}","received_events_url":"https://api.github.com/users/AtsushiKan/received_events","type":"User","site_admin":false},"body":"This is a port of ProtectedData.Protect() and Unprotect()\r\n\r\nOriginal source at:\r\n\r\n  http://index/#System.Security/system/security/cryptography/dataprotection.cs\r\n\r\nChanges from desktop: Changed the interop style to CoreFx style and folded the two (nearly identical)\r\nmethods into a common helper method.\r\n\r\nInterop.CryptProtectData.cs and Interop.CryptUnprotectData.cs were left over\r\nfrom the reverted SecureString work. They're unused (and unusable due to the\r\nBSTRHandle reference) so I just swiped their filenames and paved them over.\r\n\r\n","created_at":"2016-03-09T17:17:19Z","updated_at":"2016-03-09T17:47:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d7462b4ec7c715f792454dd322ba4758d871a3a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/6773/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/6773/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/6773/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/d387d97737697e1c421dc9454fe23239da8a74a3","head":{"label":"AtsushiKan:dp","ref":"dp","sha":"d387d97737697e1c421dc9454fe23239da8a74a3","user":{"login":"AtsushiKan","id":13223578,"avatar_url":"https://avatars.githubusercontent.com/u/13223578?v=3","gravatar_id":"","url":"https://api.github.com/users/AtsushiKan","html_url":"https://github.com/AtsushiKan","followers_url":"https://api.github.com/users/AtsushiKan/followers","following_url":"https://api.github.com/users/AtsushiKan/following{/other_user}","gists_url":"https://api.github.com/users/AtsushiKan/gists{/gist_id}","starred_url":"https://api.github.com/users/AtsushiKan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AtsushiKan/subscriptions","organizations_url":"https://api.github.com/users/AtsushiKan/orgs","repos_url":"https://api.github.com/users/AtsushiKan/repos","events_url":"https://api.github.com/users/AtsushiKan/events{/privacy}","received_events_url":"https://api.github.com/users/AtsushiKan/received_events","type":"User","site_admin":false},"repo":{"id":38702362,"name":"corefx","full_name":"AtsushiKan/corefx","owner":{"login":"AtsushiKan","id":13223578,"avatar_url":"https://avatars.githubusercontent.com/u/13223578?v=3","gravatar_id":"","url":"https://api.github.com/users/AtsushiKan","html_url":"https://github.com/AtsushiKan","followers_url":"https://api.github.com/users/AtsushiKan/followers","following_url":"https://api.github.com/users/AtsushiKan/following{/other_user}","gists_url":"https://api.github.com/users/AtsushiKan/gists{/gist_id}","starred_url":"https://api.github.com/users/AtsushiKan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AtsushiKan/subscriptions","organizations_url":"https://api.github.com/users/AtsushiKan/orgs","repos_url":"https://api.github.com/users/AtsushiKan/repos","events_url":"https://api.github.com/users/AtsushiKan/events{/privacy}","received_events_url":"https://api.github.com/users/AtsushiKan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AtsushiKan/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/AtsushiKan/corefx","forks_url":"https://api.github.com/repos/AtsushiKan/corefx/forks","keys_url":"https://api.github.com/repos/AtsushiKan/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AtsushiKan/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AtsushiKan/corefx/teams","hooks_url":"https://api.github.com/repos/AtsushiKan/corefx/hooks","issue_events_url":"https://api.github.com/repos/AtsushiKan/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/AtsushiKan/corefx/events","assignees_url":"https://api.github.com/repos/AtsushiKan/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/AtsushiKan/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/AtsushiKan/corefx/tags","blobs_url":"https://api.github.com/repos/AtsushiKan/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AtsushiKan/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AtsushiKan/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/AtsushiKan/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AtsushiKan/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/AtsushiKan/corefx/languages","stargazers_url":"https://api.github.com/repos/AtsushiKan/corefx/stargazers","contributors_url":"https://api.github.com/repos/AtsushiKan/corefx/contributors","subscribers_url":"https://api.github.com/repos/AtsushiKan/corefx/subscribers","subscription_url":"https://api.github.com/repos/AtsushiKan/corefx/subscription","commits_url":"https://api.github.com/repos/AtsushiKan/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/AtsushiKan/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/AtsushiKan/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/AtsushiKan/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/AtsushiKan/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/AtsushiKan/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AtsushiKan/corefx/merges","archive_url":"https://api.github.com/repos/AtsushiKan/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AtsushiKan/corefx/downloads","issues_url":"https://api.github.com/repos/AtsushiKan/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/AtsushiKan/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/AtsushiKan/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/AtsushiKan/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AtsushiKan/corefx/labels{/name}","releases_url":"https://api.github.com/repos/AtsushiKan/corefx/releases{/id}","deployments_url":"https://api.github.com/repos/AtsushiKan/corefx/deployments","created_at":"2015-07-07T17:03:52Z","updated_at":"2016-01-13T21:05:54Z","pushed_at":"2016-03-09T17:43:30Z","git_url":"git://github.com/AtsushiKan/corefx.git","ssh_url":"git@github.com:AtsushiKan/corefx.git","clone_url":"https://github.com/AtsushiKan/corefx.git","svn_url":"https://github.com/AtsushiKan/corefx","homepage":"http://dotnet.github.io/core/","size":58083,"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":"25930081b8dee53cd1acb397bac9a9e6eff20be2","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-09T08:41:29Z","pushed_at":"2016-03-09T17:43:32Z","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":78489,"stargazers_count":9272,"watchers_count":9272,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2179,"mirror_url":null,"open_issues_count":923,"forks":2179,"open_issues":923,"watchers":9272,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6773"},"html":{"href":"https://github.com/dotnet/corefx/pull/6773"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/6773"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/6773/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6773/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/6773/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/d387d97737697e1c421dc9454fe23239da8a74a3"}}}}