private bool[] generateStream(byte[] kc, uint count) { bool[] keytsream = new bool[114]; CryptA5 A5Algo = new CryptA5(kc); A5Algo.Count = count; A5Algo.RunAlgo(); Array.Copy(A5Algo.DownlinkKey, keytsream, keytsream.Length); return(keytsream); }
private void btnEncryptToL1_Click(object sender, EventArgs e) { bool error = false; if (textL2Data.Text.Length != 23 * 2 && textL2Data.Text.Length != 23 * 3 - 1) { MessageBox.Show(this, "Supply 23 bytes L2 data ..."); error = true; } if (textKc.Text.Length != 8 * 2) { MessageBox.Show(this, "Supply 8 bytes Kc ..."); error = true; } if (textFN.Text.Length == 0) { MessageBox.Show(this, "Supply frame number ..."); error = true; } if (error) { textL1crypt0.Text = ""; textL1crypt1.Text = ""; textL1crypt2.Text = ""; textL1crypt3.Text = ""; return; } byte[] l2data = new byte[23]; ByteUtil.BytesFromString(textL2Data.Text, ref l2data); bool[][] l1bursts = new bool[4][]; for (int i = 0; i < l1bursts.Length; i++) { l1bursts[i] = new bool[114]; } SDCCHBurst sdcch = new SDCCHBurst(); sdcch.L2DataAdd(l2data); sdcch.L2ToL1Convert(); sdcch.L1BurstIGet(ref l1bursts); /* crypt it */ byte[] kc = new byte[8]; ByteUtil.BytesFromString(textKc.Text, ref kc); GSMParameters param = new GSMParameters(); param.FN = uint.Parse(textFN.Text); CryptA5 A5Algo = new CryptA5(kc); if (radioSameFN.Checked) { A5Algo.CryptDownlink(l1bursts[0], param.Count); A5Algo.CryptDownlink(l1bursts[1], param.Count); A5Algo.CryptDownlink(l1bursts[2], param.Count); A5Algo.CryptDownlink(l1bursts[3], param.Count); } else { A5Algo.CryptDownlink(l1bursts[0], param.Count); param.FN++; A5Algo.CryptDownlink(l1bursts[1], param.Count); param.FN++; A5Algo.CryptDownlink(l1bursts[2], param.Count); param.FN++; A5Algo.CryptDownlink(l1bursts[3], param.Count); } textL1crypt0.Text = ByteUtil.BitsToString(l1bursts[0]); textL1crypt1.Text = ByteUtil.BitsToString(l1bursts[1]); textL1crypt2.Text = ByteUtil.BitsToString(l1bursts[2]); textL1crypt3.Text = ByteUtil.BitsToString(l1bursts[3]); }