Exemple #1
0
        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));
        }
Exemple #2
0
        private byte[] ProtectPDU(byte[] header, ref byte[] stub_data, int auth_padding_length)
        {
            List <SecurityBuffer> buffers = new List <SecurityBuffer>();

            if (_negotiated_auth_type != RpcAuthenticationType.Kerberos)
            {
                buffers.Add(new SecurityBufferInOut(SecurityBufferType.Data | SecurityBufferType.ReadOnlyWithChecksum, header));
            }
            var stub_data_buffer = new SecurityBufferInOut(SecurityBufferType.Data, stub_data);

            buffers.Add(stub_data_buffer);
            if (_negotiated_auth_type != RpcAuthenticationType.Kerberos)
            {
                buffers.Add(new SecurityBufferInOut(SecurityBufferType.Data | SecurityBufferType.ReadOnlyWithChecksum,
                                                    AuthData.ToArray(_transport_security, auth_padding_length, 0, new byte[0])));
            }

            byte[] signature;
            if (_transport_security.AuthenticationLevel == RpcAuthenticationLevel.PacketIntegrity)
            {
                signature = _auth_context.MakeSignature(buffers, _send_sequence_no);
            }
            else
            {
                signature = _auth_context.EncryptMessage(buffers, SecurityQualityOfProtectionFlags.None, _send_sequence_no);
                stub_data = stub_data_buffer.ToArray();
                RpcUtils.DumpBuffer(true, "Send Encrypted Data", stub_data);
            }

            RpcUtils.DumpBuffer(true, "Send Signature Data", signature);
            return(AuthData.ToArray(_transport_security, auth_padding_length, 0, signature));
        }