- if (ctx->meth->nonce != NULL)
- return ctx->meth->nonce(ctx->data, out, outlen);
- return ctx->meth->generate(ctx->data, out, outlen, 0, 0, NULL, 0);
+ int res = 1;
+
+ if (!evp_rand_lock(ctx))
+ return 0;
+ if (ctx->meth->nonce == NULL
+ || !ctx->meth->nonce(ctx->data, out, 0, outlen, outlen))
+ res = ctx->meth->generate(ctx->data, out, outlen, 0, 0, NULL, 0);
+ evp_rand_unlock(ctx);
+ return res;
+}
+
+unsigned int EVP_RAND_CTX_strength(EVP_RAND_CTX *ctx)
+{
+ OSSL_PARAM params[2];
+ int res;
+
+ if (ctx->strength == 0) {
+ params[0] = OSSL_PARAM_construct_uint(OSSL_RAND_PARAM_STRENGTH,
+ &ctx->strength);
+ params[1] = OSSL_PARAM_construct_end();
+ if (!evp_rand_lock(ctx))
+ return 0;
+ res = EVP_RAND_CTX_get_params(ctx, params);
+ evp_rand_unlock(ctx);
+ if (!res)
+ return 0;
+ }
+ return ctx->strength;