mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 19:40:24 +00:00
encrypt: fixed RAND_bytes call
currntly it returns 1 on success so not only 0 is success
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#define MOD_NAME "[encrypt] "
|
||||
|
||||
struct openssl_encrypt {
|
||||
AES_KEY key;
|
||||
|
||||
@@ -76,8 +78,9 @@ static int openssl_encrypt_init(struct openssl_encrypt **state, const char *pass
|
||||
MD5Final(hash, &context);
|
||||
|
||||
AES_set_encrypt_key(hash, 128, &s->key);
|
||||
if (!RAND_bytes(s->ivec, 8)) {
|
||||
if (RAND_bytes(s->ivec, 8) < 0) {
|
||||
free(s);
|
||||
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Cannot generate random bytes!\n");
|
||||
return -1;
|
||||
}
|
||||
s->mode = mode;
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define MOD_NAME "[transmit] "
|
||||
#define TRANSMIT_MAGIC 0xe80ab15f
|
||||
|
||||
#define FEC_MAX_MULT 10
|
||||
@@ -243,7 +244,7 @@ struct tx *tx_init(struct module *parent, unsigned mtu, enum tx_media_type media
|
||||
}
|
||||
if (tx->enc_funcs->init(&tx->encryption,
|
||||
encryption, DEFAULT_CIPHER_MODE) != 0) {
|
||||
fprintf(stderr, "Unable to initialize encryption\n");
|
||||
log_msg(LOG_LEVEL_ERROR, MOD_NAME "Unable to initialize encryption\n");
|
||||
module_done(&tx->mod);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user