Beispiel #1
0
        public byte[] GenerateKey()
        {
            byte[] firstKey, secondKey, thirdKey;

            firstKey  = FirstLfsr.GenerateKey();
            secondKey = SecondLfsr.GenerateKey();
            thirdKey  = ThirdLfsr.GenerateKey();

            var resultKey = new byte[BytesMessageLength];

            for (int i = 0; i < BytesMessageLength; ++i)
            {
                resultKey[i] = (byte)((firstKey[i] & secondKey[i]) | (~firstKey[i] & thirdKey[i]));
            }

            return(resultKey);
        }
Beispiel #2
0
        public void Initialize(string InitialState, long bytesMessageLength)
        {
            var fixedBinaryString = GetFixedBinaryString(InitialState);

            if (fixedBinaryString.Length != Taps2[0])
            {
                throw new ArgumentException($"Initial state length was not right. Try setting it to default value '{Taps2[0]}' ");
            }

            InitialState2 = Convert.ToInt32(InitialState, 2);
            InitialState1 = Convert.ToInt32(InitialState.PadLeft(Taps1[0], '1'), 2);
            InitialState3 = Convert.ToInt32(InitialState.PadLeft(Taps3[0], '1'), 2);

            BytesMessageLength = bytesMessageLength;

            FirstLfsr.Initialize(InitialState1, BytesMessageLength);
            SecondLfsr.Initialize(InitialState2, BytesMessageLength);
            ThirdLfsr.Initialize(InitialState2, BytesMessageLength);
        }