Add crypto-initializer functions to those whose return values must be checked

This commit is contained in:
Nick Mathewson 2015-11-25 10:36:34 -05:00
parent dedea28c2e
commit 10fdee6285
3 changed files with 8 additions and 4 deletions

View File

@ -322,7 +322,8 @@ int
crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
{
if (!crypto_global_initialized_) {
crypto_early_init();
if (crypto_early_init() < 0)
return -1;
crypto_global_initialized_ = 1;

View File

@ -112,10 +112,10 @@ typedef struct crypto_dh_t crypto_dh_t;
/* global state */
const char * crypto_openssl_get_version_str(void);
const char * crypto_openssl_get_header_version_str(void);
int crypto_early_init(void);
int crypto_early_init(void) ATTR_WUR;
int crypto_global_init(int hardwareAccel,
const char *accelName,
const char *accelPath);
const char *accelPath) ATTR_WUR;
void crypto_thread_cleanup(void);
int crypto_global_cleanup(void);

View File

@ -390,7 +390,10 @@ main(int argc, char **argv)
init_logging(1);
network_init();
crypto_global_init(1, NULL, NULL);
if (crypto_global_init(1, NULL, NULL) < 0) {
printf("Couldn't initialize crypto subsystem; exiting.\n");
return 1;
}
if (crypto_seed_rng() < 0) {
printf("Couldn't seed RNG; exiting.\n");
return 1;