poco
poco copied to clipboard
Util::IniFileConfiguration of an ecrypted stream (Crypto::CryptoInputStream) using wrong password, hangs
Hello
I'm using poco version 1.12.3.
problem description : i've followed this link the encryption/decryption functions. i'm using Util::IniFileConfiguration to read an ecrypted file using Crypto::CryptoInputStream. and as long as I'm providing the correct password and salt to the Crypto::CipherKey ctor, all is well.
but I am unable to handle the case of wrong password/salt, the application hangs when trying the read from the undecryptable stream :
here's the code std::string password = ""; std::string salt = "";
try { // create crypto engine Poco::Crypto::CipherFactory & factory = Poco::Crypto::CipherFactory::defaultFactory(); Poco::Crypto::CipherKey CK("aes-256-cbc", password, salt); std::cout << "after create cipher key" << std::endl; Poco::Crypto::Cipher * pCipher = factory.createCipher(CK);
// create a decryption stream Poco::FileInputStream sink("RunParameters.encrypted"); Poco::Crypto::CryptoInputStream DecryptorStream(sink, pCipher->createDecryptor()); std::cout << "after create decryptor stream" << std::endl;
// read from the stream Poco::AutoPtrPoco::Util::IniFileConfiguration pServerConfig(new Poco::Util::IniFileConfiguration(DecryptorStream)); std::cout << "after creating IniFileConfiguration object using the decryption stream" << std::endl; } catch (const Poco::Exception & Except) { ES.Message = "was not able to reach encrypted configuration file, exception = " + Except.displayText(); ES.Code = 8; return(ES); }
when I execute, it simply hangs. exception is not thrown. last row in the terminal is "after create decryptor stream"
please advise, :-)