コード例 #1
0
        private void btnBoolGadConvert_Click(object sender, EventArgs e)
        {
            bool inputError   = false;
            bool dirBoolToGad = radioBoolToGad.Checked;

            if (dirBoolToGad)
            {
                if (textBool0.Text.Length != 114 || textBool1.Text.Length != 114 ||
                    textBool2.Text.Length != 114 || textBool3.Text.Length != 114)
                {
                    inputError = true;
                }
                MessageBox.Show("not supported yet!");
                return;
            }
            else
            {
                byte[] byteBuf = new byte[19];

                GSMParameters param = new GSMParameters();
                SDCCHBurst    sdcch = new SDCCHBurst();

                ByteUtil.BytesFromString(textGad0.Text, ref byteBuf);
                sdcch.ParseData(param, ByteUtil.BitsFromBytes(byteBuf), 0);

                ByteUtil.BytesFromString(textGad1.Text, ref byteBuf);
                sdcch.ParseData(param, ByteUtil.BitsFromBytes(byteBuf), 1);

                ByteUtil.BytesFromString(textGad2.Text, ref byteBuf);
                sdcch.ParseData(param, ByteUtil.BitsFromBytes(byteBuf), 2);

                ByteUtil.BytesFromString(textGad3.Text, ref byteBuf);
                sdcch.ParseData(param, ByteUtil.BitsFromBytes(byteBuf), 3);

                bool[][] boolBuf = new bool[4][];
                for (int i = 0; i < boolBuf.Length; i++)
                {
                    boolBuf[i] = new bool[114];
                }

                sdcch.L1BurstEGet(ref boolBuf);

                if (boolBuf == null)
                {
                    MessageBox.Show("error reading bits");
                    return;
                }

                textBool0.Text = ByteUtil.BitsToString(boolBuf[0]);
                textBool1.Text = ByteUtil.BitsToString(boolBuf[1]);
                textBool2.Text = ByteUtil.BitsToString(boolBuf[2]);
                textBool3.Text = ByteUtil.BitsToString(boolBuf[3]);
            }
        }
コード例 #2
0
        public void Read(bool[] bitsDownlink, bool[] bitsUplink)
        {
            lock (this)
            {
                if (DumpStream != null)
                {
                    long deltaSlots = (FN - Parameters.FN) * 8 + (TN - Parameters.TN);

                    /* does the analyzer want the next burst or are we too far away? (need synchronization) */
                    if (deltaSlots <= 1 || deltaSlots > (DeltaFrameCount * 8))
                    {
                        /* give him the actual data */
                        Parameters.FN = FN;
                        Parameters.TN = TN;

                        /* do not set ARFCN if we are not sure about its value */
                        if (ARFCN != -1)
                        {
                            Parameters.ARFCN = ARFCN;
                        }

                        ByteUtil.BitsFromBytes(DataDown, bitsDownlink, 8, 0, 148);
                        if (bitsUplink != null)
                        {
                            ByteUtil.BitsFromBytes(DataUp, bitsUplink, 8, 0, 148);
                        }

                        ReadNextRecord();
                    }
                    else
                    {
                        /* fake some dummy bursts here. those were omitted in the dump. */
                        Array.Copy(DummyBits, bitsDownlink, 148);
                        Array.Copy(DummyBits, bitsUplink, 148);

                        /* also update TN and such */
                        Parameters.TN++;
                        Parameters.TN %= 8;
                        if (Parameters.TN == 0)
                        {
                            Parameters.FN++;
                        }
                    }
                }
            }
        }
コード例 #3
0
        public GsmAnalyzerDumpReader(GSMParameters param, string fileName)
        {
            DumpFileName = fileName;
            Parameters   = param;

            ByteUtil.BitsFromBytes(GsmAnalyzerDumpWriter.DummyData, DummyBits, 8, 0, 148);

            try
            {
                FileIsBeingUpdated = IsBeingUpdated();

                DumpFile   = File.Open(DumpFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                DumpStream = new StreamReader(DumpFile);

                ReadNextRecord();
            }
            catch (Exception e)
            {
            }
        }
コード例 #4
0
ファイル: CryptA5.cs プロジェクト: g3gg0/rx-fft
        /* Test the code by comparing it against a known-good test vector. */
        public static void SelfCheck()
        {
            uint testFrame = 0x134;

            byte[] testKey  = new byte[] { 0xEF, 0xCD, 0xAB, 0x89, 0x67, 0x45, 0x23, 0x12 };
            bool[] goodAtoB = ByteUtil.BitsFromBytes(new byte[] { 0x53, 0x4E, 0xAA, 0x58, 0x2F, 0xE8, 0x15, 0x1A, 0xB6, 0xE1, 0x85, 0x5A, 0x72, 0x8C, 0x00 });
            bool[] goodBtoA = ByteUtil.BitsFromBytes(new byte[] { 0x24, 0xFD, 0x35, 0xA3, 0x5D, 0x5F, 0xB6, 0x52, 0x6D, 0x32, 0xF9, 0x06, 0xDF, 0x1A, 0xC0 });
            int    i        = 0;
            bool   failed   = false;

            CryptA5 a5 = new CryptA5();

            a5.Key   = testKey;
            a5.Count = testFrame;
            a5.RunAlgo();

            /* Compare against the test vector. */
            for (i = 0; i < 114; i++)
            {
                if (a5.DownlinkKey[i] != goodAtoB[i])
                {
                    failed = true;
                }
            }
            for (i = 0; i < 114; i++)
            {
                if (a5.UplinkKey[i] != goodBtoA[i])
                {
                    failed = true;
                }
            }

            if (failed)
            {
                /* Problems!  The test vectors didn't compare*/
                StringBuilder builder = new StringBuilder();

                /* Print some debugging output. */
                builder.Append("key: 0x");
                for (i = 0; i < 8; i++)
                {
                    builder.AppendFormat("{0:X02}", testKey[i]);
                }
                builder.Append("\r\n");
                builder.AppendFormat("frame number: 0x{0:X6}\r\n", (uint)testFrame);
                builder.Append("known good output:\r\n");
                builder.Append(" A->B: ");
                for (i = 0; i < 114; i++)
                {
                    builder.Append(goodAtoB[i] ? 1 : 0);
                }
                builder.Append("  B->A: ");
                for (i = 0; i < 114; i++)
                {
                    builder.Append(goodBtoA[i] ? 1 : 0);
                }
                builder.Append("\r\n");
                builder.Append("observed output:\r\n");
                builder.Append(" A->B: ");
                for (i = 0; i < 114; i++)
                {
                    builder.Append(a5.DownlinkKey[i] ? 1 : 0);
                }
                builder.Append("  B->A: ");
                for (i = 0; i < 114; i++)
                {
                    builder.Append(a5.UplinkKey[i] ? 1 : 0);
                }
                builder.Append("\r\n");

                builder.Append("\r\nI don't know why this broke; contact the authors.\r\n");
                Log.AddMessage(builder.ToString());
            }
        }