{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/50213760","id":50213760,"diff_hunk":"@@ -0,0 +1,162 @@\n+// Copyright (c) Microsoft. All rights reserved.\n+// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n+\n+using System;\n+using System.Diagnostics;\n+using System.Runtime.InteropServices;\n+using System.Text;\n+using Microsoft.Win32.SafeHandles;\n+\n+internal static partial class Interop\n+{\n+    internal static class GssApi\n+    {\n+        internal static bool EstablishSecurityContext(\n+            ref SafeGssContextHandle context,\n+            SafeGssCredHandle credential,\n+            bool isNtlm,\n+            SafeGssNameHandle targetName,\n+            Interop.libgssapi.GssFlags inFlags,\n+            byte[] buffer,\n+            out byte[] outputBuffer,\n+            out uint outFlags)\n+        {\n+            outputBuffer = null;\n+            outFlags = 0;\n+\n+            if (context == null)\n+            {\n+                context = new SafeGssContextHandle();\n+            }\n+\n+            using (SafeGssBufferHandle outputToken = new SafeGssBufferHandle())\n+            {\n+                libgssapi.Status status;\n+                libgssapi.Status minorStatus;\n+\n+                status = libgssapi.GssInitSecContext(\n+                                    out minorStatus,\n+                                    credential,\n+                                    ref context,\n+                                    isNtlm,\n+                                    targetName,\n+                                    (uint)inFlags,\n+                                    buffer,\n+                                    (buffer == null) ? 0 : buffer.Length,\n+                                    outputToken,\n+                                    out outFlags);\n+\n+                if ((status != libgssapi.Status.GSS_S_COMPLETE) && (status != libgssapi.Status.GSS_S_CONTINUE_NEEDED))\n+                {\n+                    throw libgssapi.GssApiException.Create(SR.net_context_establishment_failed, status, minorStatus);\n+                }\n+\n+                outputBuffer = new byte[outputToken.Length]; // Always return non-null\n+                if (outputToken.Length > 0)\n+                {\n+                    Marshal.Copy(outputToken.Value, outputBuffer, 0, outputToken.Length);\n+                }\n+                return (status == libgssapi.Status.GSS_S_COMPLETE) ? true : false;\n+            }\n+        }\n+\n+        internal static int Encrypt(\n+            SafeGssContextHandle context,\n+            bool encrypt,\n+            byte[] buffer,\n+            int offset,\n+            int count,\n+            out byte[] outputBuffer)\n+        {\n+            outputBuffer = null;\n+            Debug.Assert((buffer != null) && (buffer.Length > 0), \"Invalid input buffer passed to Encrypt\");\n+            Debug.Assert((offset >= 0) && (offset < buffer.Length), \"Invalid input offset passed to Encrypt\");\n+            Debug.Assert((count > 0) && (count <= (buffer.Length - offset)), \"Invalid input count passed to Encrypt\");\n+\n+            using (SafeGssBufferHandle outputToken = new SafeGssBufferHandle())\n+            {\n+                libgssapi.Status minorStatus;\n+                libgssapi.Status status = libgssapi.GssWrap(out minorStatus, context, encrypt, buffer, offset, count, outputToken);\n+                if (status != libgssapi.Status.GSS_S_COMPLETE)\n+                {\n+                    throw libgssapi.GssApiException.Create(SR.net_context_wrap_failed, status, minorStatus);\n+                }\n+\n+                outputBuffer = new byte[outputToken.Length]; // Always return non-null\n+                if (outputToken.Length > 0)\n+                {\n+                    Marshal.Copy(outputToken.Value, outputBuffer, 0, outputToken.Length);\n+                }\n+\n+                return outputBuffer.Length;\n+            }\n+        }\n+\n+        internal static int Decrypt(\n+            SafeGssContextHandle context,\n+            byte[] buffer,\n+            int offset,\n+            int count)\n+        {\n+            Debug.Assert((buffer != null) && (buffer.Length > 0), \"Invalid input buffer passed to Decrypt\");\n+            Debug.Assert((offset >= 0) && (offset < buffer.Length), \"Invalid input offset passed to Decrypt\");\n+            Debug.Assert((count > 0) && (count <= (buffer.Length - offset)), \"Invalid input count passed to Decrypt\");\n+\n+            using (SafeGssBufferHandle outputToken = new SafeGssBufferHandle())\n+            {\n+                libgssapi.Status minorStatus;\n+                libgssapi.Status status = libgssapi.GssUnwrap(out minorStatus, context, buffer, offset, count, outputToken);\n+                if (status != libgssapi.Status.GSS_S_COMPLETE)\n+                {\n+                    throw libgssapi.GssApiException.Create(SR.net_context_unwrap_failed, status, minorStatus);\n+                }\n+\n+                int length = buffer.Length - offset;\n+                if (outputToken.Length > length)\n+                {\n+                    throw libgssapi.GssApiException.Create(SR.Format(SR.net_context_buffer_too_small, outputToken.Length, length));\n+                }\n+\n+                if (outputToken.Length > 0)\n+                {\n+                    Marshal.Copy(outputToken.Value, buffer, offset, outputToken.Length);\n+                }\n+\n+                return outputToken.Length;\n+            }\n+        }\n+\n+        internal static string GetSourceName(SafeGssContextHandle context)\n+        {\n+            libgssapi.Status minorStatus;\n+            SafeGssNameHandle sourceName;\n+            libgssapi.Status status = libgssapi.GssInquireSourceName(\n+                         out minorStatus,\n+                         context,\n+                         out sourceName);\n+\n+            if (status != libgssapi.Status.GSS_S_COMPLETE)","path":"src/Common/src/Interop/Unix/libgss/Interop.GssApi.cs","position":138,"original_position":138,"commit_id":"fb0e12a4f7e980d0eef43860cd373f3de37ebb16","original_commit_id":"fb0e12a4f7e980d0eef43860cd373f3de37ebb16","user":{"login":"vijaykota","id":11638339,"avatar_url":"https://avatars.githubusercontent.com/u/11638339?v=3","gravatar_id":"","url":"https://api.github.com/users/vijaykota","html_url":"https://github.com/vijaykota","followers_url":"https://api.github.com/users/vijaykota/followers","following_url":"https://api.github.com/users/vijaykota/following{/other_user}","gists_url":"https://api.github.com/users/vijaykota/gists{/gist_id}","starred_url":"https://api.github.com/users/vijaykota/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vijaykota/subscriptions","organizations_url":"https://api.github.com/users/vijaykota/orgs","repos_url":"https://api.github.com/users/vijaykota/repos","events_url":"https://api.github.com/users/vijaykota/events{/privacy}","received_events_url":"https://api.github.com/users/vijaykota/received_events","type":"User","site_admin":false},"body":"This code is going to be removed. It is not supposed to be populated on error else gss_release_name will be needed. The sample code we have seen does not do this on errors","created_at":"2016-01-20T04:32:08Z","updated_at":"2016-01-20T04:32:08Z","html_url":"https://github.com/dotnet/corefx/pull/5500#discussion_r50213760","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/5500","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/50213760"},"html":{"href":"https://github.com/dotnet/corefx/pull/5500#discussion_r50213760"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/5500"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/5500","id":56331189,"html_url":"https://github.com/dotnet/corefx/pull/5500","diff_url":"https://github.com/dotnet/corefx/pull/5500.diff","patch_url":"https://github.com/dotnet/corefx/pull/5500.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/5500","number":5500,"state":"open","locked":false,"title":"Interop Layer for supporting xplat NegotiateStream","user":{"login":"kapilash","id":113322,"avatar_url":"https://avatars.githubusercontent.com/u/113322?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilash","html_url":"https://github.com/kapilash","followers_url":"https://api.github.com/users/kapilash/followers","following_url":"https://api.github.com/users/kapilash/following{/other_user}","gists_url":"https://api.github.com/users/kapilash/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilash/subscriptions","organizations_url":"https://api.github.com/users/kapilash/orgs","repos_url":"https://api.github.com/users/kapilash/repos","events_url":"https://api.github.com/users/kapilash/events{/privacy}","received_events_url":"https://api.github.com/users/kapilash/received_events","type":"User","site_admin":false},"body":"Introducing native shims for libgssapi in order to support NegotiateStream","created_at":"2016-01-18T11:31:29Z","updated_at":"2016-01-20T04:32:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64ab4cfcc6ecd18a1a2b23c6097b9bb875099bd6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/5500/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/5500/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/5500/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/fb0e12a4f7e980d0eef43860cd373f3de37ebb16","head":{"label":"kapilash:spnego","ref":"spnego","sha":"fb0e12a4f7e980d0eef43860cd373f3de37ebb16","user":{"login":"kapilash","id":113322,"avatar_url":"https://avatars.githubusercontent.com/u/113322?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilash","html_url":"https://github.com/kapilash","followers_url":"https://api.github.com/users/kapilash/followers","following_url":"https://api.github.com/users/kapilash/following{/other_user}","gists_url":"https://api.github.com/users/kapilash/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilash/subscriptions","organizations_url":"https://api.github.com/users/kapilash/orgs","repos_url":"https://api.github.com/users/kapilash/repos","events_url":"https://api.github.com/users/kapilash/events{/privacy}","received_events_url":"https://api.github.com/users/kapilash/received_events","type":"User","site_admin":false},"repo":{"id":32931025,"name":"corefx","full_name":"kapilash/corefx","owner":{"login":"kapilash","id":113322,"avatar_url":"https://avatars.githubusercontent.com/u/113322?v=3","gravatar_id":"","url":"https://api.github.com/users/kapilash","html_url":"https://github.com/kapilash","followers_url":"https://api.github.com/users/kapilash/followers","following_url":"https://api.github.com/users/kapilash/following{/other_user}","gists_url":"https://api.github.com/users/kapilash/gists{/gist_id}","starred_url":"https://api.github.com/users/kapilash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kapilash/subscriptions","organizations_url":"https://api.github.com/users/kapilash/orgs","repos_url":"https://api.github.com/users/kapilash/repos","events_url":"https://api.github.com/users/kapilash/events{/privacy}","received_events_url":"https://api.github.com/users/kapilash/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kapilash/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/kapilash/corefx","forks_url":"https://api.github.com/repos/kapilash/corefx/forks","keys_url":"https://api.github.com/repos/kapilash/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kapilash/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kapilash/corefx/teams","hooks_url":"https://api.github.com/repos/kapilash/corefx/hooks","issue_events_url":"https://api.github.com/repos/kapilash/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/kapilash/corefx/events","assignees_url":"https://api.github.com/repos/kapilash/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/kapilash/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/kapilash/corefx/tags","blobs_url":"https://api.github.com/repos/kapilash/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kapilash/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kapilash/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/kapilash/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kapilash/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/kapilash/corefx/languages","stargazers_url":"https://api.github.com/repos/kapilash/corefx/stargazers","contributors_url":"https://api.github.com/repos/kapilash/corefx/contributors","subscribers_url":"https://api.github.com/repos/kapilash/corefx/subscribers","subscription_url":"https://api.github.com/repos/kapilash/corefx/subscription","commits_url":"https://api.github.com/repos/kapilash/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/kapilash/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/kapilash/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/kapilash/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/kapilash/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/kapilash/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kapilash/corefx/merges","archive_url":"https://api.github.com/repos/kapilash/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kapilash/corefx/downloads","issues_url":"https://api.github.com/repos/kapilash/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/kapilash/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/kapilash/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/kapilash/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kapilash/corefx/labels{/name}","releases_url":"https://api.github.com/repos/kapilash/corefx/releases{/id}","created_at":"2015-03-26T14:08:29Z","updated_at":"2016-01-11T04:01:08Z","pushed_at":"2016-01-18T11:29:33Z","git_url":"git://github.com/kapilash/corefx.git","ssh_url":"git@github.com:kapilash/corefx.git","clone_url":"https://github.com/kapilash/corefx.git","svn_url":"https://github.com/kapilash/corefx","homepage":"","size":45596,"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":"10e9b23d75e62d04a5212ae5e018916142104776","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}","created_at":"2014-11-06T23:42:48Z","updated_at":"2016-01-20T03:12:13Z","pushed_at":"2016-01-20T04:18:12Z","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":55938,"stargazers_count":8951,"watchers_count":8951,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2059,"mirror_url":null,"open_issues_count":811,"forks":2059,"open_issues":811,"watchers":8951,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/5500"},"html":{"href":"https://github.com/dotnet/corefx/pull/5500"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/5500"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/5500/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/5500/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/5500/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/fb0e12a4f7e980d0eef43860cd373f3de37ebb16"}}}}