public MFTestResults AesTest_Encrypt() { MFTestResults res; try { using (AesCryptoServiceProvider csp = new AesCryptoServiceProvider()) { res = SymmetricTestHelper.Test_Encrypt(csp); } if (res == MFTestResults.Pass && m_isEmulator) { using (AesCryptoServiceProvider csp = new AesCryptoServiceProvider("Emulator_Crypto")) { res = SymmetricTestHelper.Test_Encrypt(csp); } } } catch { res = MFTestResults.Fail; } return(res); }
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); }
public MFTestResults TDesTest_EncryptUpdate() { MFTestResults res; try { using (TripleDESCryptoServiceProvider csp = new TripleDESCryptoServiceProvider()) { res = SymmetricTestHelper.Test_EncryptUpdate(csp); } if (res == MFTestResults.Pass && m_isEmulator) { using (TripleDESCryptoServiceProvider csp = new TripleDESCryptoServiceProvider("Emulator_Crypto")) { res = SymmetricTestHelper.Test_EncryptUpdate(csp); } } } catch { return(MFTestResults.Fail); } return(res); }
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); }
public MFTestResults AesTest_EncryptCsps() { MFTestResults res = MFTestResults.Skip; try { if (m_isEmulator) { using (AesCryptoServiceProvider csp1 = new AesCryptoServiceProvider()) { using (AesCryptoServiceProvider csp2 = new AesCryptoServiceProvider("Emulator_Crypto")) { res = SymmetricTestHelper.Test_EncryptCsp(csp1, csp2, m_key); } } } } catch { res = MFTestResults.Fail; } return(res); }