Beispiel #1
0
        private void ProcessTLVSMPMessage(byte[] smp_byte_data, OTR_TLV_TYPE tlv_type)
        {
            DebugPrint("Received SMP message with TLV of type " + tlv_type.ToString());

            _smp_event_type_1 = OTR_SMP_EVENT.INVALID;
            _smp_event_type_2 = OTR_SMP_EVENT.INVALID;
            _smp_message = string.Empty;

            StartSMPSession(false);

            byte[] _message_byte_array = null;
            byte[] _encoded_smp_bytes = _smp_manager.ProcessSMPMessage(smp_byte_data, tlv_type, ref _smp_event_type_1, ref _smp_event_type_2, ref _smp_message);

            if (_smp_event_type_2 == OTR_SMP_EVENT.SUCCEEDED)
            {
                _otr_event_args = new OTREventArgs();
                _otr_event_args.SetMessage("SMP completed succesfully");
                _otr_event_args.SetOTREvent(OTR_EVENT.SMP_MESSAGE);
                _otr_event_args.SetSMPEvent(OTR_SMP_EVENT.SUCCEEDED);

                DoOTREvent(_otr_event_args);

                EndSMPSession();

            }

            if ((_smp_event_type_1 == OTR_SMP_EVENT.SEND) &&
               (_encoded_smp_bytes != null && _encoded_smp_bytes.Length > 0))
            {
                _message_byte_array = FormatMessageWtTLV(null, _encoded_smp_bytes, null);

                if (_smp_max_fragement_length > 0)
                EncryptFragments(_message_byte_array, _smp_max_fragement_length);
                else
                    EncryptMessage(_message_byte_array, false);

            }

            else if (_smp_event_type_1 == OTR_SMP_EVENT.ABORT)
            {

                _otr_event_args = new OTREventArgs();
                _otr_event_args.SetMessage(_smp_message);
                _otr_event_args.SetOTREvent(OTR_EVENT.SMP_MESSAGE);
                _otr_event_args.SetSMPEvent(OTR_SMP_EVENT.ABORT);

                DoOTREvent(_otr_event_args);

                EndSMPSession();

            }

            else if (_smp_event_type_1 == OTR_SMP_EVENT.FAILED)
            {

                _otr_event_args = new OTREventArgs();
                _otr_event_args.SetMessage("Man in the middle attack suspected");
                _otr_event_args.SetOTREvent(OTR_EVENT.SMP_MESSAGE);
                _otr_event_args.SetSMPEvent(OTR_SMP_EVENT.FAILED);

                DoOTREvent(_otr_event_args);

                EndSMPSession();

            }
            else if (_smp_event_type_1 == OTR_SMP_EVENT.SUCCEEDED)
            {

                _otr_event_args = new OTREventArgs();
                _otr_event_args.SetMessage("SMP completed succesfully");
                _otr_event_args.SetOTREvent(OTR_EVENT.SMP_MESSAGE);
                _otr_event_args.SetSMPEvent(OTR_SMP_EVENT.SUCCEEDED);
                DoOTREvent(_otr_event_args);
                EndSMPSession();

            }
            else
            {
                DebugPrint("ProcessTLVSMPMessage:Invalid SMP event");
                EndSMPSession();

            }
        }
Beispiel #2
0
 public void SetSMPEvent(OTR_SMP_EVENT smp_event)
 {
     _smp_event = smp_event;
 }
Beispiel #3
0
 public void SetSMPEvent(OTR_SMP_EVENT smp_event)
 {
     _smp_event = smp_event;
 }