Ejemplo n.º 1
0
        public MFTestResults AesTest_EncryptUpdate()
        {
            MFTestResults res;

            try
            {
                using (AesCryptoServiceProvider csp = new AesCryptoServiceProvider())
                {
                    res = SymmetricTestHelper.Test_EncryptUpdate(csp);
                }

                if (res == MFTestResults.Pass && m_isEmulator)
                {
                    using (AesCryptoServiceProvider csp = new AesCryptoServiceProvider("Emulator_Crypto"))
                    {
                        res = SymmetricTestHelper.Test_EncryptUpdate(csp);
                    }
                }
            }
            catch
            {
                res = MFTestResults.Fail;
            }

            return(res);
        }
Ejemplo n.º 2
0
        bool SessionTest_CloseWithCreateKeyObjects_internal(string svcProvider)
        {
            bool res = true;

            CryptoKey key;

            using (Session sess = new Session(svcProvider, MechanismType.AES_CBC))
            {
                AesCryptoServiceProvider aes = new AesCryptoServiceProvider(sess);

                aes.GenerateKey();

                key = aes.Key;

                SymmetricTestHelper.Test_EncryptUpdate(aes);
            }

            try
            {
                using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider(svcProvider))
                {
                    aes.Key = key;

                    SymmetricTestHelper.Test_EncryptUpdate(aes);
                }

                res = false;
            }
            catch (Exception)
            {
            }

            return(res);
        }
Ejemplo n.º 3
0
        bool SessionTest_CloseWithOpenKeyObjects_internal(string svcProvider)
        {
            bool res = true;

            CryptoKey key;

            using (Session sess = new Session(svcProvider, MechanismType.AES_CBC))
            {
                using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider(sess))
                {
                    key = CryptoKey.LoadKey(sess, m_key);

                    aes.Key = key;

                    SymmetricTestHelper.Test_EncryptUpdate(aes);
                }

                using (AesCryptoServiceProvider aes2 = new AesCryptoServiceProvider(sess))
                {
                    key = CryptoKey.LoadKey(sess, m_key);

                    aes2.Key = key;

                    SymmetricTestHelper.Test_EncryptUpdate(aes2);
                }
            }

            try
            {
                // new session should fail, key should be disposed
                using (AesCryptoServiceProvider aes = new AesCryptoServiceProvider(svcProvider))
                {
                    aes.Key = key;

                    SymmetricTestHelper.Test_EncryptUpdate(aes);
                }

                res = false;
            }
            catch (Exception)
            {
            }

            return(res);
        }