public MFTestResults ECDH_Test()
        {
            TestCase[] tests = new TestCase[]
            {
                new TestCase("Create tests", TestCreate),
                new TestCase("Key exchange (Hash)", TestKeyExchangeHash),
                //new TestCase("Key exchange (HMAC)", TestKeyExchangeHmac),
                //new TestCase("Key exchange (TLS)", TestKeyExchangeTls),
                //new TestCase("Load intereseting XML", TestLoadInterestingXml),
                //new TestCase("Roundtrip XML", TestXml)
            };

            bool passed = true;
            foreach (TestCase test in tests)
            {
                if (!RunTest(test))
                    passed = false;
            }

            return passed ? MFTestResults.Pass : MFTestResults.Fail;
        }
Ejemplo n.º 2
0
        public MFTestResults ECDsa_Test()
        {
            TestCase[] tests = new TestCase[]
            {
                new TestCase("Create tests", TestCreate),
                new TestCase("SignHash", TestSignHash),
                new TestCase("SignData (buffer)", TestSignDataBuffer),
                new TestCase("SignData (stream)", TestSignDataStream),
                //new TestCase("Roundtrip XML", TestXml)
            };

            bool passed = true;

            using (Session session = new Session("", MechanismType.ECDSA))
            {
                foreach (TestCase test in tests)
                {
                    if (!RunTest(session, test))
                        passed = false;
                }
            }

            if (m_isEmulator)
            {
                using (Session session = new Session("Emulator_Crypto", MechanismType.ECDSA))
                {
                    foreach (TestCase test in tests)
                    {
                        if (!RunTest(session, test))
                            passed = false;
                    }
                }
            }

            return passed ? MFTestResults.Pass : MFTestResults.Fail;
        }
Ejemplo n.º 3
0
        private static bool RunTest(Session session, TestCase test)
        {
            WriteStatus(test.Name);

            try
            {
                if (test.Test(session))
                {
                    WriteStatus("    OK");
                    return true;
                }
                else
                {
                    WriteStatus("    Fail");
                    return false;
                }
            }
            catch (Exception e)
            {
                WriteStatus("Failed -- got an exception");
                WriteStatus(e.ToString());
                return false;
            }
        }