Skip to content

Commit b3d113e

Browse files
committed
Cosmetic rand/drbg changes.
Reviewed-by: Matthias St. Pierre <[email protected]> (Merged from #8554)
1 parent fdf6c0b commit b3d113e

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

crypto/rand/drbg_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ static RAND_DRBG *rand_drbg_new(int secure,
241241
unsigned int flags,
242242
RAND_DRBG *parent)
243243
{
244-
RAND_DRBG *drbg = secure ?
245-
OPENSSL_secure_zalloc(sizeof(*drbg)) : OPENSSL_zalloc(sizeof(*drbg));
244+
RAND_DRBG *drbg = secure ? OPENSSL_secure_zalloc(sizeof(*drbg))
245+
: OPENSSL_zalloc(sizeof(*drbg));
246246

247247
if (drbg == NULL) {
248248
RANDerr(RAND_F_RAND_DRBG_NEW, ERR_R_MALLOC_FAILURE);

crypto/rand/rand_lib.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
137137
size_t entropy_available = 0;
138138
RAND_POOL *pool;
139139

140-
if (drbg->parent && drbg->strength > drbg->parent->strength) {
140+
if (drbg->parent != NULL && drbg->strength > drbg->parent->strength) {
141141
/*
142142
* We currently don't support the algorithm from NIST SP 800-90C
143143
* 10.1.2 to use a weaker DRBG as source
@@ -155,7 +155,7 @@ size_t rand_drbg_get_entropy(RAND_DRBG *drbg,
155155
return 0;
156156
}
157157

158-
if (drbg->parent) {
158+
if (drbg->parent != NULL) {
159159
size_t bytes_needed = rand_pool_bytes_needed(pool, 1 /*entropy_factor*/);
160160
unsigned char *buffer = rand_pool_add_begin(pool, bytes_needed);
161161

@@ -235,7 +235,7 @@ size_t rand_drbg_get_nonce(RAND_DRBG *drbg,
235235
struct {
236236
void * instance;
237237
int count;
238-
} data = { 0 };
238+
} data = { NULL, 0 };
239239

240240
pool = rand_pool_new(0, min_len, max_len);
241241
if (pool == NULL)
@@ -402,7 +402,7 @@ int RAND_poll(void)
402402
} else {
403403
/* fill random pool and seed the current legacy RNG */
404404
pool = rand_pool_new(RAND_DRBG_STRENGTH,
405-
RAND_DRBG_STRENGTH / 8,
405+
(RAND_DRBG_STRENGTH + 7) / 8,
406406
RAND_POOL_MAX_LENGTH);
407407
if (pool == NULL)
408408
return 0;
@@ -689,7 +689,7 @@ unsigned char *rand_pool_add_begin(RAND_POOL *pool, size_t len)
689689

690690
if (pool->buffer == NULL) {
691691
RANDerr(RAND_F_RAND_POOL_ADD_BEGIN, ERR_R_INTERNAL_ERROR);
692-
return 0;
692+
return NULL;
693693
}
694694

695695
return pool->buffer + pool->len;

0 commit comments

Comments
 (0)