diff --git a/Crypto/include/Poco/Crypto/EVPPKey.h b/Crypto/include/Poco/Crypto/EVPPKey.h index 256f1983e8..5df187240d 100644 --- a/Crypto/include/Poco/Crypto/EVPPKey.h +++ b/Crypto/include/Poco/Crypto/EVPPKey.h @@ -237,7 +237,7 @@ class Crypto_API EVPPKey if (pFile) { pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB; - void* pPassword = pass.empty() ? (void*)0 : (void*)pass.c_str(); + void* pPassword = (void*)pass.c_str(); if (readFunc(pFile, &pKey, pCB, pPassword)) { fclose(pFile); pFile = 0; @@ -302,7 +302,7 @@ class Crypto_API EVPPKey if (pKey) { pem_password_cb* pCB = pass.empty() ? (pem_password_cb*)0 : &passCB; - void* pPassword = pass.empty() ? (void*)0 : (void*)pass.c_str(); + void* pPassword = (void*)pass.c_str(); if (readFunc(pBIO, &pKey, pCB, pPassword)) { BIO_free(pBIO); pBIO = 0; diff --git a/Crypto/testsuite/src/EVPTest.cpp b/Crypto/testsuite/src/EVPTest.cpp index 7f8b9a9606..18a20cdf56 100644 --- a/Crypto/testsuite/src/EVPTest.cpp +++ b/Crypto/testsuite/src/EVPTest.cpp @@ -518,6 +518,15 @@ void EVPTest::testECEVPSaveLoadFile() key3.save(&strPub3); std::string pubFromPrivate = strPub3.str(); assertTrue (pubFromPrivate == pubKey); + + // Create new key with empty password + EVPPKey key4(curveName); + + key4.save(filePub.path(), filePriv.path(), ""); + + // Load key from file with empty password. + // No input string should be prompted + EVPPKey key4LoadEmptyPass { "", filePriv.path(), "" }; } else std::cerr << "No elliptic curves found!" << std::endl;