Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NegotiateStreamPal.cs
Go to the documentation of this file.
3
4namespace System.Net.Security;
5
6internal static class NegotiateStreamPal
7{
8 internal static int QueryMaxTokenSize(string package)
9 {
10 return System.Net.SSPIWrapper.GetVerifyPackageInfo(System.Net.GlobalSSPI.SSPIAuth, package, throwIfMissing: true).MaxToken;
11 }
12
13 internal static System.Net.Security.SafeFreeCredentials AcquireDefaultCredential(string package, bool isServer)
14 {
15 return System.Net.SSPIWrapper.AcquireDefaultCredential(System.Net.GlobalSSPI.SSPIAuth, package, isServer ? global::Interop.SspiCli.CredentialUse.SECPKG_CRED_INBOUND : global::Interop.SspiCli.CredentialUse.SECPKG_CRED_OUTBOUND);
16 }
17
18 internal static System.Net.Security.SafeFreeCredentials AcquireCredentialsHandle(string package, bool isServer, NetworkCredential credential)
19 {
21 try
22 {
23 global::Interop.SECURITY_STATUS sECURITY_STATUS = global::Interop.SspiCli.SspiEncodeStringsAsAuthIdentity(credential.UserName, credential.Domain, credential.Password, out authData);
24 if (sECURITY_STATUS != 0)
25 {
26 if (System.Net.NetEventSource.Log.IsEnabled())
27 {
28 System.Net.NetEventSource.Error(null, System.SR.Format(System.SR.net_log_operation_failed_with_error, "SspiEncodeStringsAsAuthIdentity", $"0x{sECURITY_STATUS:X}"), "AcquireCredentialsHandle");
29 }
30 throw new Win32Exception((int)sECURITY_STATUS);
31 }
32 return System.Net.SSPIWrapper.AcquireCredentialsHandle(System.Net.GlobalSSPI.SSPIAuth, package, isServer ? global::Interop.SspiCli.CredentialUse.SECPKG_CRED_INBOUND : global::Interop.SspiCli.CredentialUse.SECPKG_CRED_OUTBOUND, ref authData);
33 }
34 finally
35 {
36 authData?.Dispose();
37 }
38 }
39
40 internal static System.Net.SecurityStatusPal InitializeSecurityContext(ref System.Net.Security.SafeFreeCredentials credentialsHandle, ref System.Net.Security.SafeDeleteContext securityContext, string spn, System.Net.ContextFlagsPal requestedContextFlags, byte[] incomingBlob, ChannelBinding channelBinding, ref byte[] resultBlob, ref System.Net.ContextFlagsPal contextFlags)
41 {
43 if (incomingBlob != null)
44 {
45 inputBuffers.SetNextBuffer(new System.Net.Security.InputSecurityBuffer(incomingBlob, System.Net.Security.SecurityBufferType.SECBUFFER_TOKEN));
46 }
47 if (channelBinding != null)
48 {
49 inputBuffers.SetNextBuffer(new System.Net.Security.InputSecurityBuffer(channelBinding));
50 }
51 System.Net.Security.SecurityBuffer outputBuffer = new System.Net.Security.SecurityBuffer(resultBlob, System.Net.Security.SecurityBufferType.SECBUFFER_TOKEN);
52 global::Interop.SspiCli.ContextFlags outFlags = global::Interop.SspiCli.ContextFlags.Zero;
54 global::Interop.SECURITY_STATUS win32SecurityStatus = (global::Interop.SECURITY_STATUS)System.Net.SSPIWrapper.InitializeSecurityContext(System.Net.GlobalSSPI.SSPIAuth, ref credentialsHandle, ref context, spn, System.Net.ContextFlagsAdapterPal.GetInteropFromContextFlagsPal(requestedContextFlags), global::Interop.SspiCli.Endianness.SECURITY_NETWORK_DREP, inputBuffers, ref outputBuffer, ref outFlags);
55 securityContext = context;
56 resultBlob = outputBuffer.token;
59 }
60
61 internal static System.Net.SecurityStatusPal CompleteAuthToken(ref System.Net.Security.SafeDeleteContext securityContext, byte[] incomingBlob)
62 {
64 System.Net.Security.SecurityBuffer inputBuffer = new System.Net.Security.SecurityBuffer(incomingBlob, System.Net.Security.SecurityBufferType.SECBUFFER_TOKEN);
65 global::Interop.SECURITY_STATUS win32SecurityStatus = (global::Interop.SECURITY_STATUS)System.Net.SSPIWrapper.CompleteAuthToken(System.Net.GlobalSSPI.SSPIAuth, ref context, in inputBuffer);
66 securityContext = context;
68 }
69
70 internal static System.Net.SecurityStatusPal AcceptSecurityContext(System.Net.Security.SafeFreeCredentials credentialsHandle, ref System.Net.Security.SafeDeleteContext securityContext, System.Net.ContextFlagsPal requestedContextFlags, byte[] incomingBlob, ChannelBinding channelBinding, ref byte[] resultBlob, ref System.Net.ContextFlagsPal contextFlags)
71 {
73 if (incomingBlob != null)
74 {
75 inputBuffers.SetNextBuffer(new System.Net.Security.InputSecurityBuffer(incomingBlob, System.Net.Security.SecurityBufferType.SECBUFFER_TOKEN));
76 }
77 if (channelBinding != null)
78 {
79 inputBuffers.SetNextBuffer(new System.Net.Security.InputSecurityBuffer(channelBinding));
80 }
81 System.Net.Security.SecurityBuffer outputBuffer = new System.Net.Security.SecurityBuffer(resultBlob, System.Net.Security.SecurityBufferType.SECBUFFER_TOKEN);
82 global::Interop.SspiCli.ContextFlags outFlags = global::Interop.SspiCli.ContextFlags.Zero;
84 global::Interop.SECURITY_STATUS win32SecurityStatus = (global::Interop.SECURITY_STATUS)System.Net.SSPIWrapper.AcceptSecurityContext(System.Net.GlobalSSPI.SSPIAuth, credentialsHandle, ref context, System.Net.ContextFlagsAdapterPal.GetInteropFromContextFlagsPal(requestedContextFlags), global::Interop.SspiCli.Endianness.SECURITY_NETWORK_DREP, inputBuffers, ref outputBuffer, ref outFlags);
85 resultBlob = outputBuffer.token;
86 securityContext = context;
89 }
90
95}
static System.Net.ContextFlagsPal GetContextFlagsPalFromInterop(global::Interop.SspiCli.ContextFlags win32Flags)
static global::Interop.SspiCli.ContextFlags GetInteropFromContextFlagsPal(System.Net.ContextFlagsPal flags)
static readonly System.Net.SSPIAuthType SSPIAuth
Definition GlobalSSPI.cs:5
static readonly System.Net.NetEventSource Log
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static System.Net.Security.SafeFreeCredentials AcquireDefaultCredential(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent)
static System.Net.SecurityPackageInfoClass GetVerifyPackageInfo(System.Net.ISSPIInterface secModule, string packageName, bool throwIfMissing)
static int InitializeSecurityContext(System.Net.ISSPIInterface secModule, ref System.Net.Security.SafeFreeCredentials credential, ref System.Net.Security.SafeDeleteSslContext context, string targetName, global::Interop.SspiCli.ContextFlags inFlags, global::Interop.SspiCli.Endianness datarep, System.Net.Security.InputSecurityBuffers inputBuffers, ref System.Net.Security.SecurityBuffer outputBuffer, ref global::Interop.SspiCli.ContextFlags outFlags)
static int CompleteAuthToken(System.Net.ISSPIInterface secModule, ref System.Net.Security.SafeDeleteSslContext context, in System.Net.Security.SecurityBuffer inputBuffer)
static int AcceptSecurityContext(System.Net.ISSPIInterface secModule, System.Net.Security.SafeFreeCredentials credential, ref System.Net.Security.SafeDeleteSslContext context, global::Interop.SspiCli.ContextFlags inFlags, global::Interop.SspiCli.Endianness datarep, System.Net.Security.InputSecurityBuffers inputBuffers, ref System.Net.Security.SecurityBuffer outputBuffer, ref global::Interop.SspiCli.ContextFlags outFlags)
static System.Net.Security.SafeFreeCredentials AcquireCredentialsHandle(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent, ref System.Net.Security.SafeSspiAuthDataHandle authdata)
static global::Interop.SECURITY_STATUS GetInteropFromSecurityStatusPal(System.Net.SecurityStatusPal status)
static System.Net.SecurityStatusPal GetSecurityStatusPalFromInterop(global::Interop.SECURITY_STATUS win32SecurityStatus, bool attachException=false)
static System.Net.SecurityStatusPal AcceptSecurityContext(System.Net.Security.SafeFreeCredentials credentialsHandle, ref System.Net.Security.SafeDeleteContext securityContext, System.Net.ContextFlagsPal requestedContextFlags, byte[] incomingBlob, ChannelBinding channelBinding, ref byte[] resultBlob, ref System.Net.ContextFlagsPal contextFlags)
static System.Net.SecurityStatusPal InitializeSecurityContext(ref System.Net.Security.SafeFreeCredentials credentialsHandle, ref System.Net.Security.SafeDeleteContext securityContext, string spn, System.Net.ContextFlagsPal requestedContextFlags, byte[] incomingBlob, ChannelBinding channelBinding, ref byte[] resultBlob, ref System.Net.ContextFlagsPal contextFlags)
static System.Net.Security.SafeFreeCredentials AcquireDefaultCredential(string package, bool isServer)
static System.Net.SecurityStatusPal CompleteAuthToken(ref System.Net.Security.SafeDeleteContext securityContext, byte[] incomingBlob)
static System.Net.Security.SafeFreeCredentials AcquireCredentialsHandle(string package, bool isServer, NetworkCredential credential)
static int QueryMaxTokenSize(string package)
static Win32Exception CreateExceptionFromError(System.Net.SecurityStatusPal statusCode)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_log_operation_failed_with_error
Definition SR.cs:154
Definition SR.cs:7
void SetNextBuffer(System.Net.Security.InputSecurityBuffer buffer)