diff options
Diffstat (limited to 'providers/implementations/rands/test_rng.c')
-rw-r--r-- | providers/implementations/rands/test_rng.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/providers/implementations/rands/test_rng.c b/providers/implementations/rands/test_rng.c index bdad7ac9ac..4e7fed0fc7 100644 --- a/providers/implementations/rands/test_rng.c +++ b/providers/implementations/rands/test_rng.c @@ -52,9 +52,6 @@ static void *test_rng_new(void *provctx, void *parent, { PROV_TEST_RNG *t; - if (parent != NULL) - return NULL; - t = OPENSSL_zalloc(sizeof(*t)); if (t == NULL) return NULL; @@ -107,16 +104,11 @@ static int test_rng_generate(void *vtest, unsigned char *out, size_t outlen, const unsigned char *adin, size_t adin_len) { PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; - size_t i; - if (strength > t->strength) + if (strength > t->strength || t->entropy_len - t->entropy_pos < outlen) return 0; - - for (i = 0; i < outlen; i++) { - out[i] = t->entropy[t->entropy_pos++]; - if (t->entropy_pos >= t->entropy_len) - break; - } + memcpy(out, t->entropy + t->entropy_pos, outlen); + t->entropy_pos += outlen; return 1; } |