evp: add params argument to EVP_RAND_instantiate()
authorPauli <ppzgs1@gmail.com>
Fri, 26 Feb 2021 00:52:13 +0000 (10:52 +1000)
committerPauli <ppzgs1@gmail.com>
Sun, 28 Feb 2021 07:25:49 +0000 (17:25 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14310)

crypto/evp/evp_rand.c
doc/man3/EVP_RAND.pod
include/openssl/evp.h

index bc8c24b3b550e5bb9b4ea37044560b989a1a2f31..aea9d72ab7a87c80d1e6afab541b9fa9cb3b3458 100644 (file)
@@ -487,22 +487,23 @@ int EVP_RAND_names_do_all(const EVP_RAND *rand,
 
 static int evp_rand_instantiate_locked
     (EVP_RAND_CTX *ctx, unsigned int strength, int prediction_resistance,
-     const unsigned char *pstr, size_t pstr_len)
+     const unsigned char *pstr, size_t pstr_len, const OSSL_PARAM params[])
 {
     return ctx->meth->instantiate(ctx->data, strength, prediction_resistance,
-                                  pstr, pstr_len);
+                                  pstr, pstr_len, params);
 }
 
 int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength,
                          int prediction_resistance,
-                         const unsigned char *pstr, size_t pstr_len)
+                         const unsigned char *pstr, size_t pstr_len,
+                         const OSSL_PARAM params[])
 {
     int res;
 
     if (!evp_rand_lock(ctx))
         return 0;
     res = evp_rand_instantiate_locked(ctx, strength, prediction_resistance,
-                                      pstr, pstr_len);
+                                      pstr, pstr_len, params);
     evp_rand_unlock(ctx);
     return res;
 }
index 88ee739d946a5aeffa99efe8f0cadef82fd41db3..52cf5118d86166a1aa6506bc1f04c91f44838855 100644 (file)
@@ -50,7 +50,8 @@ EVP_RAND_STATE_ERROR - EVP RAND routines
 
  int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength,
                           int prediction_resistance,
-                          const unsigned char *pstr, size_t pstr_len);
+                          const unsigned char *pstr, size_t pstr_len,
+                          const OSSL_PARAM params[]);
  int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx);
  int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen,
                        unsigned int strength, int prediction_resistance,
@@ -78,10 +79,10 @@ If you want to do more, these calls should be used instead of the older
 RAND and RAND_DRBG functions.
 
 After creating a B<EVP_RAND_CTX> for the required algorithm using
-EVP_RAND_CTX_new(), inputs to the algorithm are supplied
-using calls to EVP_RAND_set_ctx_params() before
-calling EVP_RAND_instantiate() and then EVP_RAND_generate() to produce
-cryptographically secure random bytes.
+EVP_RAND_CTX_new(), inputs to the algorithm are supplied either by
+passing them as part of the EVP_RAND_instantiate() call or using calls to
+EVP_RAND_set_ctx_params() before calling EVP_RAND_instantiate().  Finally,
+call EVP_RAND_generate() to produce cryptographically secure random bytes.
 
 =head2 Types
 
@@ -123,8 +124,9 @@ I<ctx>.
 
 =head2 Random Number Generator Functions
 
-EVP_RAND_instantiate() instantiates the RAND I<ctx> with a minimum security
-strength of <strength> and personalisation string I<pstr> of length <pstr_len>.
+EVP_RAND_instantiate() processes any parameters in I<params> and
+then instantiates the RAND I<ctx> with a minimum security strength
+of <strength> and personalisation string I<pstr> of length <pstr_len>.
 If I<prediction_resistance> is specified, fresh entropy from a live source
 will be sought.  This call operates as per NIST SP 800-90A and SP 800-90C.
 
index a6a05b1ba6129f7083457f1563d899289c5d9af7..96a82827fc4d7e61282e514a0b9c3187b0cd43fa 100644 (file)
@@ -1193,7 +1193,8 @@ int EVP_RAND_names_do_all(const EVP_RAND *rand,
 
 __owur int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength,
                                 int prediction_resistance,
-                                const unsigned char *pstr, size_t pstr_len);
+                                const unsigned char *pstr, size_t pstr_len,
+                                const OSSL_PARAM params[]);
 int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx);
 __owur int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out,
                              size_t outlen, unsigned int strength,