Skip to content
Next Next commit
Add PNSE version of NegotiateStreamPal class
  • Loading branch information
MaximLipnin committed Apr 28, 2021
commit 457c937753fadaffbd7ea4c4ae585be9758bd4c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.IO;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Authentication;
using System.Security.Authentication.ExtendedProtection;
using System.Security.Principal;
using System.Text;
using System.Threading;
using Microsoft.Win32.SafeHandles;

namespace System.Net.Security
{
//
// The class maintains the state of the authentication process and the security context.
// It encapsulates security context and does the real work in authentication and
// user data encryption with NEGO SSPI package.
//
internal static partial class NegotiateStreamPal
{
internal static string QueryContextClientSpecifiedSpn(SafeDeleteContext securityContext)
{
throw new PlatformNotSupportedException(SR.net_nego_server_not_supported);
}

internal static string QueryContextAuthenticationPackage(SafeDeleteContext securityContext)
{
throw new PlatformNotSupportedException();
}

internal static SecurityStatusPal InitializeSecurityContext(
ref SafeFreeCredentials credentialsHandle,
ref SafeDeleteContext? securityContext,
string? spn,
ContextFlagsPal requestedContextFlags,
byte[]? incomingBlob,
ChannelBinding? channelBinding,
ref byte[]? resultBlob,
ref ContextFlagsPal contextFlags)
{
throw new PlatformNotSupportedException();
}

internal static SecurityStatusPal AcceptSecurityContext(
SafeFreeCredentials? credentialsHandle,
ref SafeDeleteContext? securityContext,
ContextFlagsPal requestedContextFlags,
byte[]? incomingBlob,
ChannelBinding? channelBinding,
ref byte[] resultBlob,
ref ContextFlagsPal contextFlags)
{
throw new PlatformNotSupportedException();
}

internal static Win32Exception CreateExceptionFromError(SecurityStatusPal statusCode)
{
throw new PlatformNotSupportedException();
}

internal static int QueryMaxTokenSize(string package)
{
throw new PlatformNotSupportedException();
}

internal static SafeFreeCredentials AcquireDefaultCredential(string package, bool isServer)
{
throw new PlatformNotSupportedException();
}

internal static SafeFreeCredentials AcquireCredentialsHandle(string package, bool isServer, NetworkCredential credential)
{
throw new PlatformNotSupportedException();
}

internal static SecurityStatusPal CompleteAuthToken(
ref SafeDeleteContext? securityContext,
byte[]? incomingBlob)
{
throw new PlatformNotSupportedException();
}

internal static int Encrypt(
SafeDeleteContext securityContext,
ReadOnlySpan<byte> buffer,
bool isConfidential,
bool isNtlm,
[NotNull] ref byte[]? output,
uint sequenceNumber)
{
throw new PlatformNotSupportedException();
}

internal static int Decrypt(
SafeDeleteContext securityContext,
byte[]? buffer,
int offset,
int count,
bool isConfidential,
bool isNtlm,
out int newOffset,
uint sequenceNumber)
{
throw new PlatformNotSupportedException();
}

internal static int VerifySignature(SafeDeleteContext securityContext, byte[] buffer, int offset, int count)
{
throw new PlatformNotSupportedException();
}

internal static int MakeSignature(SafeDeleteContext securityContext, byte[] buffer, int offset, int count, [AllowNull] ref byte[] output)
{
throw new PlatformNotSupportedException();
}
}
}
15 changes: 12 additions & 3 deletions src/libraries/System.Net.Security/src/System.Net.Security.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@
Link="Common\System\Net\ContextFlagsAdapterPal.Unix.cs" />
<Compile Include="$(CommonPath)System\Net\Http\TlsCertificateExtensions.cs"
Link="Common\System\Net\Http\TlsCertificateExtensions.cs" />
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.Unix.cs"
Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" />
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteContext.cs"
Link="Common\System\Net\Security\Unix\SafeDeleteContext.cs" />
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteNegoContext.cs"
Expand All @@ -266,12 +264,23 @@
Link="Common\System\Net\Security\Unix\SafeFreeNegoCredentials.cs" />
<Compile Include="$(CommonPath)System\Net\Security\Unix\SecChannelBindings.cs"
Link="Common\System\Net\Security\Unix\SecChannelBindings.cs" />
<Compile Include="System\Net\Security\NegotiateStreamPal.Unix.cs" />
<Compile Include="System\Net\Security\Pal.Managed\EndpointChannelBindingToken.cs" />
<Compile Include="System\Net\Security\Pal.Managed\SafeChannelBindingHandle.cs" />
<Compile Include="System\Net\Security\SslConnectionInfo.Unix.cs" />
<Compile Include="System\Net\Security\TlsCipherSuiteData.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(TargetstvOS)' != 'true'">
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.Unix.cs"
Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" />
<Compile Include="System\Net\Security\NegotiateStreamPal.Unix.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(TargetstvOS)' == 'true'">
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.PNSE.cs"
Link="Common\System\Net\Security\NegotiateStreamPal.PNSE.cs" />
<Compile Include="System\Net\Security\NegotiateStreamPal.PNSE.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(UseAndroidCrypto)' != 'true' and '$(UseAppleCrypto)' != 'true'">
<Compile Include="System\Net\CertificateValidationPal.Unix.cs" />
<Compile Include="System\Net\Security\CipherSuitesPolicyPal.Linux.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;
using System.Security.Principal;

namespace System.Net.Security
{
//
// The class maintains the state of the authentication process and the security context.
// It encapsulates security context and does the real work in authentication and
// user data encryption with NEGO SSPI package.
//
internal static partial class NegotiateStreamPal
{
internal static IIdentity GetIdentity(NTAuthentication context)
{
throw new PlatformNotSupportedException();
}

internal static string QueryContextAssociatedName(SafeDeleteContext? securityContext)
{
throw new PlatformNotSupportedException(SR.net_nego_server_not_supported);
}

internal static void ValidateImpersonationLevel(TokenImpersonationLevel impersonationLevel)
{
throw new PlatformNotSupportedException();
}
}
}