Esempio n. 1
0
        private static void AddBasicSecurityLayer(ProtocolStackState stackState, AESProtocolState aesState)
        {
            // Heartbeat
            stackState.MiddleProtocols.Add(new HeartbeatProtocol());
            // Timestamp
            stackState.MiddleProtocols.Add(new TimestampProtocol());
            // Seq (this protocol will block broadcasted messages)
            stackState.MiddleProtocols.Add(new SequenceProtocol());
            // AES
            AESProtocol aesP = new AESProtocol();

            aesP.SetState((AESProtocolState)aesState.Clone());
            stackState.MiddleProtocols.Add(aesP);
            // Framing
            stackState.MiddleProtocols.Add(new FramingProtocol());
        }
Esempio n. 2
0
        private ProtocolStack GetDefaultStack()
        {
            ProtocolStackState state = new ProtocolStackState();

            // branching
            List <ProtocolStack> branches = new List <ProtocolStack>();

            branches.Add(GetTextBranch());       // index 0
            branches.Add(GetFileBranch());       // index 1
            branches.Add(GetManagementBranch()); // index 2
            TypeBranchingProtocol branchingProtocol = new TypeBranchingProtocol();

            branchingProtocol.SetBranches(branches);
            state.MiddleProtocols.Add(branchingProtocol);

            // Block invalid DataContent
            state.MiddleProtocols.Add(new BlockProtocol());
            // Type tagging
            TypeTagProtocol typeTagProtocol = new TypeTagProtocol();

            state.MiddleProtocols.Add(typeTagProtocol);

            // Block invalid DataContent
            state.MiddleProtocols.Add(new BlockProtocol());
            // AES
            AESProtocol aesP = new AESProtocol();

            aesP.SetState((AESProtocolState)_options.SecondLowAESProtocolState.Clone());
            state.MiddleProtocols.Add(aesP);

            // Block invalid data and report
            state.MiddleProtocols.Add(new BlockProtocol());
            // Basic Security Layers
            AddBasicSecurityLayer(state, _options.FirstLowAESProtocolState);

            state.Type = DataProtocolType.Text;
            ProtocolStack protocolStack = new ProtocolStack();

            protocolStack.SetState(state);
            return(protocolStack);
        }