Esempio n. 1
0
        public override void HandleAu1Frame(MaslAu1Frame au1Frame)
        {
            if (au1Frame.EncryAlgorithm != EncryptionAlgorithm.TripleDES)
            {
                throw new SafetyFeatureNotSupportedException();
            }

            var expectedDir = MaslFrameDirection.Client2Server;

            if (au1Frame.Direction != expectedDir)
            {
                throw new DirectionFlagException(expectedDir);
            }

            // 更新远程设备(主动方)类型。
            this.Context.RsspEP.RemoteEquipType = au1Frame.DeviceType;

            // 更新RandomB
            this.Context.MacCalculator.RandomB = au1Frame.RandomB;

            // 初始化Mac计算器。
            this.Context.MacCalculator.UpdateSessionKeys();

            // 设置下一个状态。
            this.Context.CurrentState = new MaslWaitingforAu3State(this.Context);

            // 启动握手计时器,等待AU3
            this.Context.StartHandshakeTimer();
        }
Esempio n. 2
0
        public byte[] BuildAu1Packet()
        {
            var frame = new MaslAu1Frame(_rsspEndPoint.LocalEquipType, _rsspEndPoint.LocalID,
                                         EncryptionAlgorithm.TripleDES, _macCalc.RandomB);

            return(frame.GetBytes());
        }
Esempio n. 3
0
        public void Test1()
        {
            var randomB = new byte[] { 0x0F, 0x95, 0xEF, 0x4A, 0x66, 0x25, 0xA9, 0x0D };
            var frame1  = new MaslAu1Frame(5, 0x8AC002, EncryptionAlgorithm.TripleDES, randomB);

            var bytes = frame1.GetBytes();

            var frame2 = new MaslAu1Frame();

            frame2.ParseBytes(bytes, 0, bytes.Length);

            Assert.AreEqual(frame1.ClientID, frame2.ClientID);
            Assert.AreEqual(frame1.DeviceType, frame2.DeviceType);
            Assert.AreEqual(frame1.Direction, frame2.Direction);
            Assert.AreEqual(frame1.EncryAlgorithm, frame2.EncryAlgorithm);
            Assert.AreEqual(frame1.FrameType, frame2.FrameType);
            CollectionAssert.AreEqual(frame1.RandomB, frame2.RandomB);
        }
Esempio n. 4
0
 public override void HandleAu1Frame(MaslAu1Frame frame)
 {
     throw new SequenceIntegrityException();
 }
Esempio n. 5
0
 public override void HandleAu1Frame(MaslAu1Frame frame)
 {
     throw new NotArObtainedAfterAu3Exception();
 }
Esempio n. 6
0
 public virtual void HandleAu1Frame(MaslAu1Frame frame)
 {
     LogUtility.Error(string.Format("{0}: {1}.{2} not implement!",
                                    this.Context.RsspEP.ID, this.GetType().Name,
                                    new StackFrame(0).GetMethod().Name.Split('.').Last()));
 }