/* Make sure the internal PRNG is initialised (but not necessarily seeded properly yet).  */
static int rng_init(br_ssl_engine_context *cc)
/* Make sure the internal PRNG is initialised (but not necessarily seeded properly yet).  */
static int rng_init(br_ssl_engine_context *cc)
{
	const br_hash_class *h;
	if (cc->rng_init_done != 0) {
		return 1;
	}
	h = br_multihash_getimpl(&cc->mhash, br_sha256_ID);
	if (!h) {
		h = br_multihash_getimpl(&cc->mhash, br_sha384_ID);
		if (!h) {
			h = br_multihash_getimpl(&cc->mhash,
				br_sha1_ID);
			if (!h) {
				br_ssl_engine_fail(cc, BR_ERR_BAD_STATE);
				return 0;
			}
		}
	}
	br_hmac_drbg_init(&cc->rng, h, NULL, 0);
	cc->rng_init_done = 1;
	return 1;
}