Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ EncryptMessage()

static unsafe SecurityStatusPal System.Net.Security.SslStreamPal.EncryptMessage ( SafeDeleteSslContext securityContext,
ReadOnlyMemory< byte > input,
int headerSize,
int trailerSize,
ref byte[] output,
out int resultSize )
inlinestatic

Definition at line 197 of file SslStreamPal.cs.

198 {
199 checked
200 {
201 int num = input.Length + headerSize + trailerSize;
202 if (output == null || output.Length < num)
203 {
204 output = new byte[num];
205 }
206 input.Span.CopyTo(new Span<byte>(output, headerSize, input.Length));
207 global::Interop.SspiCli.SecBuffer* ptr = stackalloc global::Interop.SspiCli.SecBuffer[4];
208 global::Interop.SspiCli.SecBufferDesc secBufferDesc = new global::Interop.SspiCli.SecBufferDesc(4);
209 secBufferDesc.pBuffers = ptr;
210 global::Interop.SspiCli.SecBufferDesc inputOutput = secBufferDesc;
211 fixed (byte* ptr3 = output)
212 {
213 global::Interop.SspiCli.SecBuffer* ptr2 = ptr;
214 ptr2->BufferType = SecurityBufferType.SECBUFFER_STREAM_HEADER;
215 ptr2->pvBuffer = (IntPtr)ptr3;
216 ptr2->cbBuffer = headerSize;
217 global::Interop.SspiCli.SecBuffer* ptr4 = ptr + 1;
218 ptr4->BufferType = SecurityBufferType.SECBUFFER_DATA;
219 ptr4->pvBuffer = (IntPtr)(ptr3 + headerSize);
220 ptr4->cbBuffer = input.Length;
221 global::Interop.SspiCli.SecBuffer* ptr5 = ptr + 2;
222 ptr5->BufferType = SecurityBufferType.SECBUFFER_STREAM_TRAILER;
223 ptr5->pvBuffer = (IntPtr)(ptr3 + headerSize + input.Length);
224 ptr5->cbBuffer = trailerSize;
225 global::Interop.SspiCli.SecBuffer* ptr6 = ptr + 3;
226 ptr6->BufferType = SecurityBufferType.SECBUFFER_EMPTY;
227 ptr6->cbBuffer = 0;
228 ptr6->pvBuffer = IntPtr.Zero;
229 int num2 = GlobalSSPI.SSPISecureChannel.EncryptMessage(securityContext, ref inputOutput, 0u);
230 if (num2 != 0)
231 {
232 if (System.Net.NetEventSource.Log.IsEnabled())
233 {
234 System.Net.NetEventSource.Info(securityContext, $"Encrypt ERROR {num2:X}", "EncryptMessage");
235 }
236 resultSize = 0;
237 return SecurityStatusAdapterPal.GetSecurityStatusPalFromNativeInt(num2);
238 }
239 resultSize = ptr2->cbBuffer + ptr4->cbBuffer + ptr5->cbBuffer;
240 return new SecurityStatusPal(SecurityStatusPalErrorCode.OK);
241 }
242 }
243 }
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)

References System.Collections.Generic.Dictionary< TKey, TValue >.CopyTo(), System.Net.SecurityStatusAdapterPal.GetSecurityStatusPalFromNativeInt(), System.Net.NetEventSource.Info(), System.input, System.Net.NetEventSource.Log, System.Net.GlobalSSPI.SSPISecureChannel, and System.IntPtr.Zero.

Referenced by System.Net.Security.SecureChannel.Encrypt().