Exemplo n.º 1
0
        public override byte[] GetByteMessage()
        {
            List <byte> messageArray = new List <byte>();

            messageArray.AddRange(Mhdr.ToArray());
            DevAddr.Span.Reverse();
            messageArray.AddRange(DevAddr.ToArray());
            DevAddr.Span.Reverse();
            messageArray.AddRange(Fctrl.ToArray());
            messageArray.AddRange(Fcnt.ToArray());
            if (!Fopts.Span.IsEmpty)
            {
                messageArray.AddRange(Fopts.ToArray());
            }
            if (!Fport.Span.IsEmpty)
            {
                messageArray.AddRange(Fport.ToArray());
            }
            if (!Frmpayload.Span.IsEmpty)
            {
                messageArray.AddRange(Frmpayload.ToArray());
            }
            if (Mic.Span != null)
            {
                messageArray.AddRange(Mic.Span.ToArray());
            }
            return(messageArray.ToArray());
        }
Exemplo n.º 2
0
        public override byte[] GetByteMessage()
        {
            List <byte> messageArray = new List <byte>();

            messageArray.AddRange(Mhdr.ToArray());
            messageArray.AddRange(RawMessage);

            return(messageArray.ToArray());
        }
Exemplo n.º 3
0
        public override byte[] GetByteMessage()
        {
            List <byte> messageArray = new List <byte>();

            messageArray.AddRange(Mhdr.ToArray());
            messageArray.AddRange(AppEUI.ToArray());
            messageArray.AddRange(DevEUI.ToArray());
            messageArray.AddRange(DevNonce.ToArray());
            if (!Mic.Span.IsEmpty)
            {
                messageArray.AddRange(Mic.ToArray());
            }
            return(messageArray.ToArray());
        }
Exemplo n.º 4
0
        private byte[] PerformMic(string appKey)
        {
            IMac mac = MacUtilities.GetMac("AESCMAC");

            KeyParameter key = new KeyParameter(ConversionHelper.StringToByteArray(appKey));

            mac.Init(key);

            var algoinput = Mhdr.ToArray().Concat(AppEUI.ToArray()).Concat(DevEUI.ToArray()).Concat(DevNonce.ToArray()).ToArray();

            byte[] result = new byte[19];
            mac.BlockUpdate(algoinput, 0, algoinput.Length);
            result = MacUtilities.DoFinal(mac);
            var resStr = BitConverter.ToString(result);

            return(result.Take(4).ToArray());
        }