Permalink
Browse files

key.cpp: fail with a friendlier message on missing ssl EC support

  • Loading branch information...
Tranz5 committed Aug 15, 2014
1 parent 3441039 commit 9793788054c68d6870e56501467b70c23ef5d614
Showing with 34 additions and 0 deletions.
  1. +20 −0 src/init.cpp
  2. +11 −0 src/key.cpp
  3. +3 −0 src/key.h
View
@@ -399,6 +399,23 @@ bool LoadWallets(ostringstream& strErrors)
return true;
}
/** Sanity checks
* Ensure that Bitcoin is running in a usable environment with all
* necessary library support.
*/
bool InitSanityCheck(void)
{
if(!ECC_InitSanityCheck()) {
InitError("OpenSSL appears to lack support for elliptic curve cryptography. For more "
"information, visit https://en.bitcoin.it/wiki/OpenSSL_and_EC_Libraries");
return false;
}
// TODO: remaining sanity checks, see #4081
return true;
}
/** Initialize bitcoin.
* @pre Parameters should be parsed and config file should be read.
*/
@@ -570,6 +587,9 @@ bool AppInit2()
}
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
// Sanity check
if (!InitSanityCheck())
return InitError(_("Initialization sanity check failed. HoboNickels is shutting down."));
std::string strDataDir = GetDataDir().string();
View
@@ -397,3 +397,14 @@ bool CKey::IsValid()
key2.SetSecret(secret, fCompr);
return GetPubKey() == key2.GetPubKey();
}
bool ECC_InitSanityCheck() {
EC_KEY *pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
if(pkey == NULL)
return false;
EC_KEY_free(pkey);
// TODO Is there more EC functionality that could be missing?
return true;
}
View
@@ -156,4 +156,7 @@ class CKey
bool IsValid();
};
/** Check that required EC support is available at runtime */
bool ECC_InitSanityCheck(void);
#endif

0 comments on commit 9793788

Please sign in to comment.