29 if (secModule.SecurityPackages ==
null)
33 if (secModule.SecurityPackages ==
null)
39 int num = secModule.EnumerateSecurityPackages(out pkgnum, out pkgArray);
49 for (
int i = 0; i < pkgnum; i++)
57 secModule.SecurityPackages =
array;
66 return secModule.SecurityPackages;
74 for (
int i = 0; i <
array.Length; i++)
109 return outCredential;
128 return outCredential;
137 int num = secModule.InitializeSecurityContext(ref credential, ref context, targetName, inFlags, datarep, inputBuffers, ref outputBuffer, ref outFlags);
140 System.
Net.
NetEventSource.
Log.SecurityContextInputBuffers(
"InitializeSecurityContext", inputBuffers.Count, outputBuffer.size, (global::Interop.SECURITY_STATUS)num);
151 int num = secModule.AcceptSecurityContext(credential, ref context, inputBuffers, inFlags, datarep, ref outputBuffer, ref outFlags);
154 System.
Net.
NetEventSource.
Log.SecurityContextInputBuffers(
"AcceptSecurityContext", inputBuffers.Count, outputBuffer.size, (global::Interop.SECURITY_STATUS)num);
161 int num = secModule.CompleteAuthToken(ref context, in inputBuffer);
181 global::Interop.SspiCli.SecBufferDesc inputOutput =
new global::Interop.SspiCli.SecBufferDesc(
input.Length);
182 Span<global::Interop.SspiCli.SecBuffer> span = stackalloc global::Interop.SspiCli.SecBuffer[
input.Length];
184 fixed (global::Interop.SspiCli.SecBuffer* pBuffers = span)
186 fixed (
byte* ptr4 = ((
input.Length > 0) ?
input[0].token :
null))
188 fixed (
byte* ptr3 = ((
input.Length > 1) ?
input[1].token :
null))
190 fixed (
byte* ptr2 = ((
input.Length > 2) ?
input[2].token :
null))
192 inputOutput.pBuffers = pBuffers;
195 for (
int i = 0; i <
input.Length; i++)
198 span[i].cbBuffer = reference.
size;
199 span[i].BufferType = reference.type;
200 if (reference.token ==
null || reference.token.Length == 0)
206 span2[i] = reference.token;
210 OP.Encrypt => secModule.EncryptMessage(context, ref inputOutput, sequenceNumber),
211 OP.Decrypt => secModule.DecryptMessage(context, ref inputOutput, sequenceNumber),
212 OP.MakeSignature => secModule.MakeSignature(context, ref inputOutput, sequenceNumber),
213 _ => secModule.VerifySignature(context, ref inputOutput, sequenceNumber),
215 for (
int j = 0; j <
input.Length; j++)
218 reference2.size = span[j].cbBuffer;
219 reference2.type = span[j].BufferType;
220 if (reference2.size == 0)
222 reference2.offset = 0;
223 reference2.token =
null;
227 for (k = 0; k <
input.Length; k++)
229 if (span2[k] !=
null)
234 if ((
void*)span[j].pvBuffer >= ptr && unchecked((nuint)(
void*)span[j].pvBuffer) + unchecked((nuint)reference2.size) <= unchecked((nuint)ptr) + unchecked((nuint)span2[k].Length))
236 reference2.offset = (int)(unchecked((
byte*)(
void*)span[j].pvBuffer) - ptr);
237 reference2.token = span2[k];
243 if (k >=
input.Length)
246 reference2.offset = 0;
247 reference2.token =
null;
265 int num = secModule.QueryContextAttributes(securityContext, contextAttribute,
MemoryMarshal.AsBytes(span),
null, out refHandle);
284 return "An exception when invoking Win32 API";
286 return (global::Interop.SECURITY_STATUS)errorCode
switch
288 global::Interop.SECURITY_STATUS.InvalidHandle =>
"Invalid handle",
289 global::Interop.SECURITY_STATUS.InvalidToken =>
"Invalid token",
290 global::Interop.SECURITY_STATUS.ContinueNeeded =>
"Continue needed",
291 global::Interop.SECURITY_STATUS.IncompleteMessage =>
"Message incomplete",
292 global::Interop.SECURITY_STATUS.WrongPrincipal =>
"Wrong principal",
293 global::Interop.SECURITY_STATUS.TargetUnknown =>
"Target unknown",
294 global::Interop.SECURITY_STATUS.PackageNotFound =>
"Package not found",
295 global::Interop.SECURITY_STATUS.BufferNotEnough =>
"Buffer not enough",
296 global::Interop.SECURITY_STATUS.MessageAltered =>
"Message altered",
297 global::Interop.SECURITY_STATUS.UntrustedRoot =>
"Untrusted root",
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
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 int MakeSignature(System.Net.ISSPIInterface secModule, System.Net.Security.SafeDeleteContext context, Span< System.Net.Security.SecurityBuffer > input, uint sequenceNumber)
static string ErrorDescription(int errorCode)
static int VerifySignature(System.Net.ISSPIInterface secModule, System.Net.Security.SafeDeleteContext context, Span< System.Net.Security.SecurityBuffer > input, uint sequenceNumber)
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 unsafe int EncryptDecryptHelper(OP op, System.Net.ISSPIInterface secModule, System.Net.Security.SafeDeleteContext context, Span< System.Net.Security.SecurityBuffer > input, uint sequenceNumber)
static bool QueryBlittableContextAttributes< T >(System.Net.ISSPIInterface secModule, System.Net.Security.SafeDeleteContext securityContext, global::Interop.SspiCli.ContextAttribute contextAttribute, Type safeHandleType, out SafeHandle sspiHandle, ref T attribute)
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.SecurityPackageInfoClass[] EnumerateSecurityPackages(System.Net.ISSPIInterface secModule)
static System.Net.Security.SafeFreeCredentials AcquireCredentialsHandle(System.Net.ISSPIInterface secModule, string package, global::Interop.SspiCli.CredentialUse intent, ref System.Net.Security.SafeSspiAuthDataHandle authdata)
static unsafe int AcquireDefaultCredential(string package, global::Interop.SspiCli.CredentialUse intent, out System.Net.Security.SafeFreeCredentials outCredential)
static unsafe int AcquireCredentialsHandle(string package, global::Interop.SspiCli.CredentialUse intent, ref System.Net.Security.SafeSspiAuthDataHandle authdata, out System.Net.Security.SafeFreeCredentials outCredential)
static unsafe IntPtr UnsafeAddrOfPinnedArrayElement(Array arr, int index)
static string net_securitypackagesupport
static string event_OperationReturnedSomething
static string Format(string resourceFormat, object p1)
static string net_log_operation_failed_with_error
static readonly IntPtr Zero