correctly check RAND_bytes error code

This commit is contained in:
ggkitsas 2014-10-07 16:43:18 +03:00
parent fc8d8b790e
commit 0aae00f0a9
2 changed files with 2 additions and 2 deletions

View File

@ -79,7 +79,7 @@ seafile_generate_random_key (const char *passwd, char *random_key)
int outlen;
unsigned char key[32], iv[16];
if (!RAND_bytes (secret_key, sizeof(secret_key))) {
if (RAND_bytes (secret_key, sizeof(secret_key)) != 1) {
seaf_warning ("Failed to generate secret key for repo encryption "
"with RAND_bytes(), use RAND_pseudo_bytes().\n");
RAND_pseudo_bytes (secret_key, sizeof(secret_key));

View File

@ -1231,7 +1231,7 @@ generate_session_key (BlockTxInfo *info, const char *peer_id)
char *sk_base64, *sk_enc_base64;
gsize enc_key_len;
if (!RAND_bytes (info->session_key, sizeof(info->session_key))) {
if (RAND_bytes (info->session_key, sizeof(info->session_key)) != 1) {
seaf_warning ("Failed to generate random session key with RAND_bytes(), "
"switch to RAND_pseudo_bytes().\n");
RAND_pseudo_bytes (info->session_key, sizeof(info->session_key));