Ejemplo n.º 1
0
        public object Clone()
        {
            AESProtocolState state = new AESProtocolState();

            state.Mode         = this.Mode;
            state.KeySize      = this.KeySize;
            state.BlockSize    = this.BlockSize;
            state.FeedbackSize = this.FeedbackSize;
            state.Padding      = this.Padding;
            state.Key          = (byte[])this.Key?.Clone();
            state.Enabled      = this.Enabled;
            return(state);
        }
Ejemplo n.º 2
0
 public void SetState(AESProtocolState state)
 {
     _state = state;
     if (state.Enabled)
     {
         // the order is important
         // set Key and IV after setting their sizes
         _aesAlg.Mode         = _state.Mode;
         _aesAlg.KeySize      = _state.KeySize;
         _aesAlg.BlockSize    = _state.BlockSize;
         _aesAlg.FeedbackSize = _state.FeedbackSize;
         _aesAlg.Padding      = _state.Padding;
         _aesAlg.Key          = _state.Key;
     }
 }
Ejemplo n.º 3
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());
        }