Exemplo n.º 1
0
 private void button6_Click(object sender, EventArgs e)
 {
     /* decrypt the key using TGS key and get CS key
      */
     f.printProcess("\n\nDecrypt Key CS using Key TGS (Scenario 13)", ncolor);
     textBox5.Text = secCol.getCharString(secCol.decryption(p.getCSKey(), tabCol, p.getTGSKey(), f));
     p.setCSKey(secCol.getCharString(secCol.decryption(p.getCSKey(), tabCol, p.getTGSKey(), f)));
     button7.Enabled = true;
     button6.Enabled = false;
     mainPage.setFlag(13);
 }
        private void button3_Click(object sender, EventArgs e)
        {
            //verification Timestamp

            /* 1. get time stamp
             * 2. get first 9char
             * 3. it the first chun is timestamp then it is timestamp pakcet if not return it is invalid
             * 4. get next chunks y,m,h,m 4 chnuks
             * 5. if the time has difference then 2 minuts, the message is invalid*/
            f.printProcess("\n\nDecrypt Message using Key TGS (Scenario 8)", ncolor);
            f.printProcess("If the time stamp is sent in five minute, then it is valid (Scenario 9)", ncolor);

            decMessage    = secCol.decryption(p.getEncMessage(), tabCol, tgServer.geTGSkey(), f);
            decMessage    = secCol.getCharString(decMessage);
            textBox9.Text = decMessage;
            string[] result = ((decMessage).Split(':'));//splitting message


            if (result.Length == 10) // check the message whether it has correct timestamp format
            {
                string ticket = "";

                for (int i = 0; i < result.Length - 2; i++)
                {
                    if (i == result.Length - 3)
                    {
                        ticket += result[i];
                    }
                    else
                    {
                        ticket += result[i] + ":";
                    }
                }
                string timestamp = result[result.Length - 1];
                textBox13.Text = ticket;
                string curTime = DateTime.Now.ToString("yyyyMMddHHmm");
                long   flag    = Convert.ToInt64(curTime) - Convert.ToInt64(timestamp);
                //if the time is send in five minutes
                if (flag < 5)
                {
                    button4.Enabled = true;
                    textBox8.Text   = timestamp;
                    textBox3.Text   = "valid";
                }
                else
                {
                    textBox8.Text = timestamp;
                    textBox3.Text = "invalid";
                }
            }

            else
            {
                textBox3.Text = "invalid";
            }
            button3.Enabled = false;
            mainPage.setFlag(8);
            mainPage.setFlag(9);
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            /*
             * 1. get client's pw
             * 2. decrypt Encrpyted Message, using PW then display the KEY(TGS)
             * 2. if the password is right then show ticket and Key TGS
             * 3. but current procedure is not right. actually whether pw is right or not, the values should be same, and TGSerer will check it by decrypting
             * 4. Create timestamp by system
             */
            if (pwBox.Text.Length != 8)
            {
                MessageBox.Show("Password should be 8 characters");
            }
            else
            {
                f.printProcess("\n\nMessage decryption using Password in PW Text Box(Scenario 4,5)", ncolor);
                decKey = secCol.decryption(p.getMessage(), tabCol, pwBox.Text, f); // decrypt encrypyed Key tgs using password
                p.setMessage(secCol.getCharString(decKey));
                decKeyBox.Text = p.getMessage();                                   // get char string format of decrypted message

                string[] result    = (p.getMessage()).Split(':');                  //splitting message
                string   timestamp = null;                                         // create timestamp

                timestamp += (DateTime.Now.ToString("yyyyMMddHHmm"));
                p.setTimeStamp(timestamp);
                timeStamp.Text = p.getTimeStamp();

                try
                {
                    if (result[5] != null)
                    {
                        textBox2.Text = result[5];
                        p.setTGSKey(result[5]);//Client get TGS Key by decrypting message
                    }
                }
                catch
                {
                    textBox2.Text  = "";
                    timeStamp.Text = "";
                    MessageBox.Show("Failed to decrypt Message");
                }

                button2.Enabled = true;
                mainPage.setFlag(4);
                mainPage.setFlag(5);
            }
        }