internal byte[] UnprotectPDU(byte[] header, byte[] stub_data, AuthData auth_data, int recv_sequence_no) { List <SecurityBuffer> buffers = new List <SecurityBuffer>(); buffers.Add(new SecurityBufferInOut(SecurityBufferType.Data | SecurityBufferType.ReadOnly, header)); var stub_data_buffer = new SecurityBufferInOut(SecurityBufferType.Data, stub_data); buffers.Add(stub_data_buffer); byte[] signature = auth_data.Data; auth_data.Data = new byte[0]; MemoryStream stm = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stm); auth_data.Write(writer, auth_data.Padding); buffers.Add(new SecurityBufferInOut(SecurityBufferType.Data | SecurityBufferType.ReadOnly, stm.ToArray())); if (TransportSecurity.AuthenticationLevel == RpcAuthenticationLevel.PacketIntegrity) { if (!AuthContext.VerifySignature(buffers, signature, recv_sequence_no)) { throw new RpcTransportException("Invalid response PDU signature."); } } else if (TransportSecurity.AuthenticationLevel == RpcAuthenticationLevel.PacketPrivacy) { AuthContext.DecryptMessage(buffers, signature, recv_sequence_no); stub_data = stub_data_buffer.ToArray(); } else { // Do nothing. } Array.Resize(ref stub_data, stub_data.Length - auth_data.Padding); return(stub_data); }