Skip to content
Prev Previous commit
Next Next commit
Fix Windows implementation of GetMIC
  • Loading branch information
filipnavara committed Jan 10, 2024
commit e2974c189472406415ee064e2eca829b6808d042
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public override unsafe void GetMIC(ReadOnlySpan<byte> message, IBufferWriter<byt
bool success = SSPIWrapper.QueryBlittableContextAttributes(GlobalSSPI.SSPIAuth, _securityContext, Interop.SspiCli.ContextAttribute.SECPKG_ATTR_SIZES, ref sizes);
Debug.Assert(success);

Span<byte> signatureBuffer = signature.GetSpan(sizes.cbSecurityTrailer);
Span<byte> signatureBuffer = signature.GetSpan(sizes.cbMaxSignature);

fixed (byte* messagePtr = message)
fixed (byte* signaturePtr = signatureBuffer)
Expand All @@ -577,7 +577,7 @@ public override unsafe void GetMIC(ReadOnlySpan<byte> message, IBufferWriter<byt
Interop.SspiCli.SecBuffer* dataBuffer = &unmanagedBuffer[1];
tokenBuffer->BufferType = SecurityBufferType.SECBUFFER_TOKEN;
tokenBuffer->pvBuffer = (IntPtr)signaturePtr;
tokenBuffer->cbBuffer = sizes.cbSecurityTrailer;
tokenBuffer->cbBuffer = sizes.cbMaxSignature;
dataBuffer->BufferType = SecurityBufferType.SECBUFFER_DATA;
dataBuffer->pvBuffer = (IntPtr)messagePtr;
dataBuffer->cbBuffer = message.Length;
Expand All @@ -597,7 +597,7 @@ public override unsafe void GetMIC(ReadOnlySpan<byte> message, IBufferWriter<byt
throw new Win32Exception(errorCode);
}

signature.Advance(signatureBuffer.Length);
signature.Advance(tokenBuffer->cbBuffer);
}
}
finally
Expand Down