Esempio n. 1
0
        public static SignatureData GetSignatureFromBase64String(string aEncodedSignature, string aEncodedEmail)
        {
            SignatureData lSignatureToReturn = new SignatureData();

            //decode string
            byte[] lData          = Convert.FromBase64String(aEncodedSignature);
            string lDecodedString = Encoding.UTF8.GetString(lData);

            //parse json
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();
            dynamic lDecodedPoints =
                json_serializer.DeserializeObject(lDecodedString);

            lData = Convert.FromBase64String(aEncodedEmail);

            Signature lDecodedSignature = new Signature();

            foreach (var point in lDecodedPoints)
            {
                try
                {
                    lDecodedSignature.Add(new Point(Convert.ToDouble(point["x"].ToString()), Convert.ToDouble(point["y"].ToString()), Convert.ToDouble(point["time"].ToString()), Convert.ToDouble(point["force"].ToString())));
                }
                catch (Exception ex)
                {
                    lDecodedSignature.Add(new Point(Convert.ToDouble(point["x"].ToString()), Convert.ToDouble(point["y"].ToString()), Convert.ToDouble(point["time"].ToString())));
                }
            }

            lSignatureToReturn.Signature = lDecodedSignature;
            lSignatureToReturn.Email     = (string)json_serializer.DeserializeObject(Encoding.UTF8.GetString(lData));

            return(lSignatureToReturn);
        }
Esempio n. 2
0
        public static Signature CalculateCharacteristics(Signature aSignature)
        {
            Signature lSignatureToReturn = new Signature();

            //Calculate first and second order differences
            var lElement       = aSignature.ElementAt(1);
            var lElementBefore = aSignature.ElementAt(0);

            lElement.X1            = lElement.X - lElementBefore.X;
            lElement.Y1            = lElement.Y - lElementBefore.Y;
            lElement.Force1        = lElement.Force - lElementBefore.Force;
            lElement.Theta         = Math.Atan2(lElement.X1, lElement.Y1);
            lElement.PathVelocity  = Math.Sqrt(Math.Pow(lElement.X1, 2) + Math.Pow(lElement.Y1, 2));
            lElement.PathVelocity1 = 0;

            for (int i = 2; i < aSignature.Count; ++i)
            {
                lElement               = aSignature.ElementAt(i);
                lElementBefore         = aSignature.ElementAt(i - 1);
                lElement.X1            = lElement.X - lElementBefore.X;
                lElement.Y1            = lElement.Y - lElementBefore.Y;
                lElement.X2            = lElement.X1 - lElementBefore.X1;
                lElement.Y2            = lElement.Y1 - lElementBefore.Y1;
                lElement.Force1        = lElement.Force - lElementBefore.Force;
                lElement.Theta         = Math.Atan2(lElement.X1, lElement.Y1);
                lElement.PathVelocity  = Math.Sqrt(Math.Pow(lElement.X1, 2) + Math.Pow(lElement.Y1, 2));
                lElement.PathVelocity1 = lElement.PathVelocity - lElementBefore.PathVelocity;
                lSignatureToReturn.Add(lElement);
            }

            return(lSignatureToReturn);
        }
        public static Signature GetSignatureFromFileWithCharacteristics(string aPath)
        {
            Signature lSig = new Signature();

            using (StreamReader lReader = new StreamReader(aPath))
            {
                string lCurrentLine = lReader.ReadLine();

                while ((lCurrentLine = lReader.ReadLine()) != null)
                {
                    String[] lValues = lCurrentLine.Split(',');
                    Point    lPoint  = new Point(double.Parse(lValues[0], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[1], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[2], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[3], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[4], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[5], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[6], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[7], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[8], System.Globalization.CultureInfo.InvariantCulture),
                                                 double.Parse(lValues[9], System.Globalization.CultureInfo.InvariantCulture));

                    lSig.Add(lPoint);
                }
            }

            return(lSig);
        }
Esempio n. 4
0
        static public Signature CalcSignature(this XDocument doc)
        {
            var sig = new Signature()
            {
                HasImages = 0 < doc.GetImages().Count
            };
            var texts = doc.GetTextNodes()
                        .Select(RemoveWhitespace)
                        .Where(s => !string.IsNullOrEmpty(s))
                        .ToList();

            foreach (var s in texts)
            {
                var hash  = Encoding.UTF8.GetBytes(s).ToHash();
                int count = 0;
                if (!sig.TryGetValue(hash, out count))
                {
                    sig.Add(hash, 1);
                }
                else
                {
                    sig[hash] = count + 1;
                }
            }
            return(sig);
        }
Esempio n. 5
0
        public static ulong GetDataTypeSignature(string normalizedLayout, IEnumerable <DsdlField> fields)
        {
            var layoutSignature = Signature.Compute(normalizedLayout);
            var sig             = new Signature(layoutSignature);

            foreach (var f in fields)
            {
                var fieldSig = f.Type.GetDataTypeSignature();
                if (fieldSig != null)
                {
                    var sigValue = sig.Value;
                    sig.Add(Signature.bytes_from_crc64(fieldSig.Value));
                    sig.Add(Signature.bytes_from_crc64(sigValue));
                }
            }
            return(sig.Value);
        }
Esempio n. 6
0
    public Formal AddFormal(InputElement id, MessageWriter msg)
    {
        Formal f = new Formal(id, locals);

        f.Add(id, msg);
        signature.Add(f);
        return(f);
    }
Esempio n. 7
0
        public InputSystem(IKeyIntentTraslator translator, NamelessGame namelessGame)
        {
            this.translator                = translator;
            this.namelessGame              = namelessGame;
            namelessGame.Window.TextInput += WindowOnTextInput;
            namelessGame.Window.KeyDown   += Window_KeyDown;

            Signature.Add(typeof(InputComponent));
            Signature.Add(typeof(InputReceiver));
        }
Esempio n. 8
0
        static void TestSign()
        {
            Console.WriteLine("TestSign");
            SecretKey sec;

            sec.SetByCSPRNG();
            PublicKey pub = sec.GetPublicKey();
            string    m   = "abc";
            Signature sig = sec.Sign(m);

            Console.WriteLine("sig={0}", sig.GetHexStr());
            assert("verify", pub.Verify(sig, m));
            assert("not verify", !pub.Verify(sig, m + "a"));
            {
                Signature sig2;
                byte[]    buf = sig.Serialize();
                sig2.Deserialize(buf);
                assert("serialize", sig2.IsEqual(sig));
            }
            {
                Signature sig2 = sig;
                sig.Neg();
                sig.Add(sig2);
                assert("sig is zero", sig.IsZero());
            }
            {
                Signature sig2 = sig;
                for (int i = 0; i < 5; i++)
                {
                    sig2.Add(sig);
                }
                Signature sig3 = sig;
                SecretKey t;
                t.SetHexStr("5");
                sig3.Mul(t);
                assert("sig mul", sig2.IsEqual(sig3));
            }
        }
Esempio n. 9
0
        public void ProcessMLAPI()
        {
            string        inputname;
            string        inputdate;
            string        inputverdict;
            string        inputversion;
            int           modifycount = 0;
            List <string> filecontent = new List <string>();

            if (TCR.EndsWith(".sig"))
            {
                //do nothing
            }
            else
            {
                try
                {
                    filecontent = File.ReadAllLines(TCR).ToList <string>();       //create list to put each line into it
                }
                catch
                {
                    return;
                }
                for (int x = 0; x < filecontent.Count; x++)
                {
                    if (filecontent[x].Contains("TCR_TestCaseReport name"))                     //go through list to find values and put them in
                    {
                        string[] temp = filecontent[x].Split('=');
                        inputname = temp[1];
                        inputname = inputname.Substring(1, inputname.Length - 3);
                        string firstletter = inputname.Substring(0, 1);
                        if (firstletter != "I")
                        {
                            {
                                if (inputname.Length > 22)
                                {
                                    Name.Add(inputname.Substring(0, 22));
                                }
                                else
                                {
                                    Name.Add(inputname);
                                }
                            }
                        }
                    }
                    if (filecontent[x].Contains("TCR_ExecutionDate value"))
                    {
                        string[] temp = filecontent[x].Split('=');
                        inputdate = temp[1];
                        inputdate = inputdate.Substring(1, inputdate.Length - 4);
                        if (inputdate.Length > 10)
                        {
                            Date.Add(inputdate.Substring(0, inputdate.Length - 1));
                        }
                        else
                        {
                            Date.Add(inputdate);
                        }
                    }
                    if (filecontent[x].Contains("TCR_Verdict value"))
                    {
                        string[] temp = filecontent[x].Split('=');
                        inputverdict = temp[1];
                        inputverdict = inputverdict.Substring(1, inputverdict.Length - 4);
                        if (inputverdict.Length > 4)
                        {
                            Verdict.Add(inputverdict.Substring(0, inputverdict.Length - 1));
                        }
                        else
                        {
                            Verdict.Add(inputverdict);
                        }
                    }
                    if (filecontent[x].Contains("NOT VALID for UE certification"))
                    {
                        modifycount = modifycount | 1;
                    }
                    if (filecontent[x].Contains("ENGINEERING BuildID"))
                    {
                        modifycount = modifycount | 2;
                    }
                    if (modifycount == 1 || modifycount == 3)
                    {
                        Modify.Add("MODIFIED");
                    }
                    else
                    {
                        Modify.Add(" ");
                    }
                    if (filecontent[x].Contains("NTT DOCOMO DST"))
                    {
                        int      index   = filecontent[x].IndexOf("NTT DOCOMO DST");
                        string   removed = filecontent[x].Remove(0, index);
                        string[] nospace = removed.Split(' ');
                        inputversion = nospace[3];
                        inputversion = inputversion.Remove(0, 1);
                        if (string.IsNullOrEmpty(detail.Version))
                        {
                            Version.Add(inputversion);
                        }
                        else if (detail.Version == inputversion)
                        {
                            Version.Add("");
                        }
                        else
                        {
                            Version.Add("NG");
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(Sig))
            {
                SignatureVerifier versig = new SignatureVerifier(Sig);
                bool valid = versig.cmdverify();

                if (valid)
                {
                    Signature.Add("VALID");
                }
                else
                {
                    Signature.Add("INVALID");
                }
            }
        }
Esempio n. 10
0
        public void ProcessTTCN()
        {
            string        verdictcheck = "NONE";
            string        inputdate;
            string        inputverdict;
            string        inputversion;
            int           modifycount = 0;
            List <string> filecontent = new List <string>();

            try
            {
                filecontent = File.ReadAllLines(TCR).ToList <string>();        //create list and put each line into it
            }
            catch
            {
                return;
            }
            for (int i = 0; i < filecontent.Count; i++)
            {
                if (filecontent[i].Contains("NOT VALID for UE certification"))              //search through list for all the given values
                {
                    modifycount = modifycount | 1;
                }
                if (filecontent[i].Contains("NTT docomo DST"))
                {
                    int      index   = filecontent[i].IndexOf("NTT docomo DST");
                    string   removed = filecontent[i].Remove(0, index);
                    string[] nospace = removed.Split(' ');
                    inputversion = nospace[3];
                    inputversion = inputversion.Remove(0, 1);
                    if (string.IsNullOrEmpty(detail.Version))
                    {
                        Version.Add(inputversion);
                    }
                    else if (detail.Version.Contains(inputversion))
                    {
                        Version.Add("");
                    }
                    else
                    {
                        Version.Add("NG");
                    }
                }
                if (filecontent[i].Contains("Final Verdict: PASS"))
                {
                    verdictcheck = "PASS";
                }
                else if (filecontent[i].Contains("Final Verdict: FAIL"))
                {
                    verdictcheck = "FAIL";
                }
                else if (filecontent[i].Contains("Final Verdict: INCONC"))
                {
                    verdictcheck = "INCONC";
                }
            }
            try
            {
                filecontent = File.ReadAllLines(Summary).ToList <string>();
            }
            catch
            {
                return;
            }
            for (int x = 0; x < filecontent.Count; x++)
            {
                if (filecontent[x].Contains("Test:"))
                {
                    string[] temp = filecontent[x].Split('.');
                    Name.Add(temp[temp.Length - 1]);
                    int listlength = Name.Count;
                }
                if (filecontent[x].Contains("Result:"))
                {
                    string[] temp = filecontent[x].Split(':');
                    inputverdict = temp[temp.Length - 1].Trim();
                    if (verdictcheck != "")
                    {
                        if (inputverdict.Contains("PASS") && !verdictcheck.Contains("PASS"))
                        {
                            Verdict.Add("NONE");
                        }
                        else
                        {
                            Verdict.Add(inputverdict);
                        }
                    }
                    else
                    {
                        Verdict.Add(inputverdict);
                    }
                }
                if (filecontent[x].Contains("Date:"))
                {
                    if (filecontent[x].Contains('/'))
                    {
                        string[] temp = filecontent[x].Split(':');
                        inputdate = temp[temp.Length - 1].Trim();
                        temp      = inputdate.Split('/');
                        inputdate = temp[2] + '-' + temp[0] + '-' + temp[1];
                        Date.Add(inputdate);
                    }
                }
                if (filecontent[x].Contains("Invalid for UE certification"))
                {
                    modifycount = modifycount | 1;
                }
                if (filecontent[x].Contains("ENGINEERING"))
                {
                    modifycount = modifycount | 2;
                }
            }

            if (modifycount == 1 || modifycount == 3)
            {
                Modify.Add("MODIFIED");
            }
            else
            {
                Modify.Add(" ");
            }

            if (!string.IsNullOrEmpty(Sig))
            {
                SignatureVerifier versig = new SignatureVerifier(Sig);
                bool valid = versig.cmdverify();

                if (valid)
                {
                    Signature.Add("VALID");
                }
                else
                {
                    Signature.Add("INVALID");
                }
            }
        }