Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Util::IniFileConfiguration of an ecrypted stream (Crypto::CryptoInputStream) using wrong password, hangs #4577

Open
omerbrandis opened this issue Jun 7, 2024 · 0 comments
Labels

Comments

@omerbrandis
Copy link
Contributor

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,
:-)

@omerbrandis omerbrandis added the bug label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant