internal byte[] ProtectPDU(byte[] header, ref byte[] stub_data, int auth_padding_length, int send_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); buffers.Add(new SecurityBufferInOut(SecurityBufferType.Data | SecurityBufferType.ReadOnly, AuthData.ToArray(TransportSecurity, auth_padding_length, ContextId, new byte[0]))); byte[] signature = new byte[0]; if (TransportSecurity.AuthenticationLevel == RpcAuthenticationLevel.PacketIntegrity) { signature = AuthContext.MakeSignature(buffers, send_sequence_no); } else if (TransportSecurity.AuthenticationLevel == RpcAuthenticationLevel.PacketPrivacy) { signature = AuthContext.EncryptMessage(buffers, SecurityQualityOfProtectionFlags.None, send_sequence_no); stub_data = stub_data_buffer.ToArray(); RpcUtils.DumpBuffer(true, "Send Encrypted Data", stub_data); } if (signature.Length > 0) { RpcUtils.DumpBuffer(true, "Send Signature Data", signature); } return(AuthData.ToArray(TransportSecurity, auth_padding_length, ContextId, signature)); }