static size_t fips_get_entropy(DRBG_CTX *dctx, unsigned char **pout,
				int entropy, size_t min_len, size_t max_len)
	{
	unsigned char *tout, *p;
	size_t bl = dctx->entropy_blocklen, rv;
	if (!dctx->get_entropy)
		return 0;
	if (dctx->xflags & DRBG_FLAG_TEST || !bl)
		return dctx->get_entropy(dctx, pout, entropy, min_len, max_len);
	rv = dctx->get_entropy(dctx, &tout, entropy + bl,
				min_len + bl, max_len + bl);
	*pout = tout + bl;
	if (rv < (min_len + bl) || (rv % bl))
		return 0;
	/* Compare consecutive blocks for continuous PRNG test */
	for (p = tout; p < tout + rv - bl; p += bl)
		{
		if (!memcmp(p, p + bl, bl))
			{
			FIPSerr(FIPS_F_FIPS_GET_ENTROPY, FIPS_R_ENTROPY_SOURCE_STUCK);
			return 0;
			}
		}
	rv -= bl;
	if (rv > max_len)
		return max_len;
	return rv;
	}
static size_t fips_get_entropy(DRBG_CTX *dctx, unsigned char **pout,
				int entropy, size_t min_len, size_t max_len)
	{
	unsigned char *tout, *p;
	size_t bl = dctx->entropy_blocklen, rv;
	if (!dctx->get_entropy)
		return 0;
	if (dctx->xflags & DRBG_FLAG_TEST || !bl)
		return dctx->get_entropy(dctx, pout, entropy, min_len, max_len);
	rv = dctx->get_entropy(dctx, &tout, entropy + bl,
				min_len + bl, max_len + bl);
	*pout = tout + bl;
	if (rv < (min_len + bl) || (rv % bl))
		return 0;
	 
	for (p = tout; p < tout + rv - bl; p += bl)
		{
		if (!memcmp(p, p + bl, bl))
			{
			FIPSerr(FIPS_F_FIPS_GET_ENTROPY, FIPS_R_ENTROPY_SOURCE_STUCK);
			return 0;
			}
		}
	rv -= bl;
	if (rv > max_len)
		return max_len;
	return rv;
	}