void runWithCipher(const string& cipherName, int blockSize, void (*func)(FSConfigPtr& config)) { shared_ptr<CipherV1> cipher = CipherV1::New(cipherName); ASSERT_TRUE(cipher.get() != NULL); FSConfigPtr cfg = makeConfig(cipher, blockSize); ASSERT_NO_FATAL_FAILURE(func(cfg)); }
void runWithAllCiphers(void (*func)(FSConfigPtr& config)) { list<CipherV1::CipherAlgorithm> algorithms = CipherV1::GetAlgorithmList(); list<CipherV1::CipherAlgorithm>::const_iterator it; for (it = algorithms.begin(); it != algorithms.end(); ++it) { int blockSize = it->blockSize.closest(512); int keyLength = it->keyLength.closest(128); SCOPED_TRACE(testing::Message() << "Testng with cipher " << it->name << ", blocksize " << blockSize << ", keyLength " << keyLength); shared_ptr<CipherV1> cipher = CipherV1::New(it->iface, keyLength); ASSERT_TRUE(cipher.get() != NULL); FSConfigPtr cfg = makeConfig(cipher, blockSize); ASSERT_NO_FATAL_FAILURE(func(cfg)); } }
int cmd_eemem( int argc, char ** argv ) { int ERROR = -1; char string[ 32 ]; if ( argc == 2 ) { if ( !strcmp_P( argv[1], PSTR("protect") ) ) { strcpy_P( string, PSTR("ON")); changeConfig_P( PSTR("WRITE_PROTECT"), string ); setprotectConfig( PROTECT ); ERROR = 0; } if ( !strcmp_P( argv[1], PSTR("unprotect") ) ) { setprotectConfig( UNPROTECT ); strcpy_P( string, PSTR("OFF")); changeConfig_P( PSTR("WRITE_PROTECT"), string ); printf_P( PSTR("unprotectet\r\n")); ERROR = 0; } if ( !strcmp_P( argv[1], PSTR("print") ) ) { PrintConfig(); ERROR = 0; } if ( !strcmp_P( argv[1], PSTR("clean") ) ) { makeConfig(); ERROR = 0; } } if ( ERROR == -1 ) printf_P( PSTR("eemem <protect>|<unprotect> <print> <clean>\r\n")); }