]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Provide side RNG functions renamed to have an ossl_ prefix.
authorPauli <paul.dale@oracle.com>
Mon, 16 Nov 2020 02:04:56 +0000 (12:04 +1000)
committerPauli <paul.dale@oracle.com>
Wed, 18 Nov 2020 21:39:12 +0000 (07:39 +1000)
These are: prov_crngt_cleanup_entropy(), prov_crngt_get_entropy(),
prov_pool_acquire_entropy(), prov_pool_add_nonce_data(),
prov_rand_drbg_free() and prov_rand_drbg_new().

Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13417)

13 files changed:
crypto/rand/rand_lib.c
providers/implementations/include/prov/seeding.h
providers/implementations/rands/crngt.c
providers/implementations/rands/drbg.c
providers/implementations/rands/drbg_ctr.c
providers/implementations/rands/drbg_hash.c
providers/implementations/rands/drbg_hmac.c
providers/implementations/rands/drbg_local.h
providers/implementations/rands/seeding/rand_unix.c
providers/implementations/rands/seeding/rand_vms.c
providers/implementations/rands/seeding/rand_vxworks.c
providers/implementations/rands/seeding/rand_win.c
providers/implementations/rands/test_rng.c

index 211f4f3f514dd28bf107ae8f57023e333dfb3150..9790b216469785715d40770d8efb1eb215310a26 100644 (file)
@@ -125,7 +125,7 @@ int RAND_poll(void)
         if (pool == NULL)
             return 0;
 
-        if (prov_pool_acquire_entropy(pool) == 0)
+        if (ossl_pool_acquire_entropy(pool) == 0)
             goto err;
 
         if (meth->add == NULL
index bd0a57a769babdfb261c8c024712d0f5da504872..ec6904060667f39ff4cc7344752f9f27343d4aa8 100644 (file)
@@ -18,8 +18,8 @@ size_t prov_drbg_get_additional_data(RAND_POOL *pool, unsigned char **pout);
 
 void prov_drbg_cleanup_additional_data(RAND_POOL *pool, unsigned char *out);
 
-size_t prov_pool_acquire_entropy(RAND_POOL *pool);
-int prov_pool_add_nonce_data(RAND_POOL *pool);
+size_t ossl_pool_acquire_entropy(RAND_POOL *pool);
+int ossl_pool_add_nonce_data(RAND_POOL *pool);
 
 /*
  * Add some platform specific additional data
index 5f613f1c4ede4c43a87d9e672f8d5a710a630599..72907b5a88685c13849513ba8a9a322365aa7d50 100644 (file)
@@ -41,7 +41,7 @@ static int crngt_get_entropy(OSSL_LIB_CTX *ctx, RAND_POOL *pool,
     if (pool == NULL)
         return 0;
 
-    n = prov_pool_acquire_entropy(pool);
+    n = ossl_pool_acquire_entropy(pool);
     if (n >= CRNGT_BUFSIZ) {
         fmd = EVP_MD_fetch(ctx, "SHA256", "");
         if (fmd == NULL)
@@ -104,7 +104,7 @@ static int prov_crngt_compare_previous(const unsigned char *prev,
     return res;
 }
 
-size_t prov_crngt_get_entropy(PROV_DRBG *drbg,
+size_t ossl_crngt_get_entropy(PROV_DRBG *drbg,
                               unsigned char **pout,
                               int entropy, size_t min_len, size_t max_len,
                               int prediction_resistance)
@@ -164,7 +164,7 @@ err:
     return r;
 }
 
-void prov_crngt_cleanup_entropy(PROV_DRBG *drbg,
+void ossl_crngt_cleanup_entropy(PROV_DRBG *drbg,
                                 unsigned char *out, size_t outlen)
 {
     OPENSSL_secure_clear_free(out, outlen);
index f3111fddb69d72aa2b60e9cbd7e35cfdd5734e6d..eb1353a5e7a35e614b396f9f664681dda2ade75e 100644 (file)
@@ -139,7 +139,7 @@ static unsigned int get_parent_reseed_count(PROV_DRBG *drbg)
  * is fetched using the parent's ossl_prov_drbg_generate().
  *
  * Otherwise, the entropy is polled from the system entropy sources
- * using prov_pool_acquire_entropy().
+ * using ossl_pool_acquire_entropy().
  *
  * If a random pool has been added to the DRBG using RAND_add(), then
  * its entropy will be used up first.
@@ -214,7 +214,7 @@ static size_t prov_drbg_get_entropy(PROV_DRBG *drbg, unsigned char **pout,
         }
     } else {
         /* Get entropy by polling system entropy sources. */
-        entropy_available = prov_pool_acquire_entropy(pool);
+        entropy_available = ossl_pool_acquire_entropy(pool);
     }
 
     if (entropy_available > 0) {
@@ -246,7 +246,7 @@ static size_t get_entropy(PROV_DRBG *drbg, unsigned char **pout, int entropy,
 {
 #ifdef FIPS_MODULE
     if (drbg->parent == NULL)
-        return prov_crngt_get_entropy(drbg, pout, entropy, min_len, max_len,
+        return ossl_crngt_get_entropy(drbg, pout, entropy, min_len, max_len,
                                       prediction_resistance);
 #endif
 
@@ -258,7 +258,7 @@ static void cleanup_entropy(PROV_DRBG *drbg, unsigned char *out, size_t outlen)
 {
 #ifdef FIPS_MODULE
     if (drbg->parent == NULL)
-        prov_crngt_cleanup_entropy(drbg, out, outlen);
+        ossl_crngt_cleanup_entropy(drbg, out, outlen);
     else
 #endif
         prov_drbg_cleanup_entropy(drbg, out, outlen);
@@ -353,7 +353,7 @@ static size_t prov_drbg_get_nonce(PROV_DRBG *drbg,
     if (pool == NULL)
         return 0;
 
-    if (prov_pool_add_nonce_data(pool) == 0)
+    if (ossl_pool_add_nonce_data(pool) == 0)
         goto err;
 
     data.instance = drbg;
@@ -807,7 +807,7 @@ int drbg_enable_locking(void *vctx)
  *
  * Returns a pointer to the new DRBG instance on success, NULL on failure.
  */
-PROV_DRBG *prov_rand_drbg_new
+PROV_DRBG *ossl_rand_drbg_new
     (void *provctx, void *parent, const OSSL_DISPATCH *p_dispatch,
      int (*dnew)(PROV_DRBG *ctx),
      int (*instantiate)(PROV_DRBG *drbg,
@@ -883,11 +883,11 @@ PROV_DRBG *prov_rand_drbg_new
     return drbg;
 
  err:
-    prov_rand_drbg_free(drbg);
+    ossl_rand_drbg_free(drbg);
     return NULL;
 }
 
-void prov_rand_drbg_free(PROV_DRBG *drbg)
+void ossl_rand_drbg_free(PROV_DRBG *drbg)
 {
     if (drbg == NULL)
         return;
index 6f9dc658d7308639aeda309b98026c9003e8da14..4a5b0b23daa47ef19355066f72851ec15160b222 100644 (file)
@@ -606,7 +606,7 @@ static int drbg_ctr_new(PROV_DRBG *drbg)
 static void *drbg_ctr_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return prov_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_ctr_new,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_ctr_new,
                               &drbg_ctr_instantiate, &drbg_ctr_uninstantiate,
                               &drbg_ctr_reseed, &drbg_ctr_generate);
 }
@@ -625,7 +625,7 @@ static void drbg_ctr_free(void *vdrbg)
 
         OPENSSL_secure_clear_free(ctr, sizeof(*ctr));
     }
-    prov_rand_drbg_free(drbg);
+    ossl_rand_drbg_free(drbg);
 }
 
 static int drbg_ctr_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
index 2b7ac2bd5f9a84db460bdbc95ee07f697982c6f9..9d8816996f3f09ca9b4922972b3d43b3968833bb 100644 (file)
@@ -407,7 +407,7 @@ static int drbg_hash_new(PROV_DRBG *ctx)
 static void *drbg_hash_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return prov_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hash_new,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hash_new,
                               &drbg_hash_instantiate, &drbg_hash_uninstantiate,
                               &drbg_hash_reseed, &drbg_hash_generate);
 }
@@ -422,7 +422,7 @@ static void drbg_hash_free(void *vdrbg)
         ossl_prov_digest_reset(&hash->digest);
         OPENSSL_secure_clear_free(hash, sizeof(*hash));
     }
-    prov_rand_drbg_free(drbg);
+    ossl_rand_drbg_free(drbg);
 }
 
 static int drbg_hash_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
index 95ee2a1db5d29e266efcd0127c0d152857e09d94..0436684a33737ac5817e158763573903047daeee 100644 (file)
@@ -304,7 +304,7 @@ static int drbg_hmac_new(PROV_DRBG *drbg)
 static void *drbg_hmac_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return prov_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hmac_new,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch, &drbg_hmac_new,
                               &drbg_hmac_instantiate, &drbg_hmac_uninstantiate,
                               &drbg_hmac_reseed, &drbg_hmac_generate);
 }
@@ -319,7 +319,7 @@ static void drbg_hmac_free(void *vdrbg)
         ossl_prov_digest_reset(&hmac->digest);
         OPENSSL_secure_clear_free(hmac, sizeof(*hmac));
     }
-    prov_rand_drbg_free(drbg);
+    ossl_rand_drbg_free(drbg);
 }
 
 static int drbg_hmac_get_ctx_params(void *vdrbg, OSSL_PARAM params[])
index 40ca6fadaae460c07d7e2f84047d0e9c842a45c7..7c3fcabbe0156144a346a321846b491ff66ee312 100644 (file)
@@ -191,7 +191,7 @@ struct prov_drbg_st {
     OSSL_CALLBACK *cleanup_nonce_fn;
 };
 
-PROV_DRBG *prov_rand_drbg_new
+PROV_DRBG *ossl_rand_drbg_new
     (void *provctx, void *parent, const OSSL_DISPATCH *parent_dispatch,
      int (*dnew)(PROV_DRBG *ctx),
      int (*instantiate)(PROV_DRBG *drbg,
@@ -203,7 +203,7 @@ PROV_DRBG *prov_rand_drbg_new
                    const unsigned char *adin, size_t adin_len),
      int (*generate)(PROV_DRBG *, unsigned char *out, size_t outlen,
                      const unsigned char *adin, size_t adin_len));
-void prov_rand_drbg_free(PROV_DRBG *drbg);
+void ossl_rand_drbg_free(PROV_DRBG *drbg);
 
 int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
                                int prediction_resistance,
@@ -258,11 +258,11 @@ int drbg_set_ctx_params(PROV_DRBG *drbg, const OSSL_PARAM params[]);
     OSSL_PARAM_uint64(OSSL_DRBG_PARAM_RESEED_TIME_INTERVAL, NULL)
 
 /* Continuous test "entropy" calls */
-size_t prov_crngt_get_entropy(PROV_DRBG *drbg,
+size_t ossl_crngt_get_entropy(PROV_DRBG *drbg,
                               unsigned char **pout,
                               int entropy, size_t min_len, size_t max_len,
                               int prediction_resistance);
-void prov_crngt_cleanup_entropy(PROV_DRBG *drbg,
+void ossl_crngt_cleanup_entropy(PROV_DRBG *drbg,
                                 unsigned char *out, size_t outlen);
 
 #endif
index 3696688dd2b29f947f80c11e5622a3286d0cf3e3..35d2878d5c760a6d9b8f69fcb5134b4840534afc 100644 (file)
@@ -165,7 +165,7 @@ static uint64_t get_timer_bits(void);
  *
  * As a precaution, we assume only 2 bits of entropy per byte.
  */
-size_t prov_pool_acquire_entropy(RAND_POOL *pool)
+size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
 {
     short int code;
     int i, k;
@@ -649,7 +649,7 @@ void rand_pool_keep_random_devices_open(int keep)
  * of input from the different entropy sources (trust, quality,
  * possibility of blocking).
  */
-size_t prov_pool_acquire_entropy(RAND_POOL *pool)
+size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
 {
 #  if defined(OPENSSL_RAND_SEED_NONE)
     return rand_pool_entropy_available(pool);
@@ -777,7 +777,7 @@ size_t prov_pool_acquire_entropy(RAND_POOL *pool)
 
 #if (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) \
      || defined(__DJGPP__)
-int prov_pool_add_nonce_data(RAND_POOL *pool)
+int ossl_pool_add_nonce_data(RAND_POOL *pool)
 {
     struct {
         pid_t pid;
index 7adf3e718a2c1d52157423ccc3954da1cd5a6dec..da143f3dbe44448256cd72abb550ea709a57fda3 100644 (file)
@@ -474,7 +474,7 @@ size_t data_collect_method(RAND_POOL *pool)
     return rand_pool_entropy_available(pool);
 }
 
-int prov_pool_add_nonce_data(RAND_POOL *pool)
+int ossl_pool_add_nonce_data(RAND_POOL *pool)
 {
     struct {
         pid_t pid;
@@ -568,7 +568,7 @@ size_t get_entropy_method(RAND_POOL *pool)
  * These functions are called by the RAND / DRBG functions
  */
 
-size_t prov_pool_acquire_entropy(RAND_POOL *pool)
+size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
 {
     if (init_get_entropy_address())
         return get_entropy_method(pool);
index f601f77a47efdefe7fbf7daf26d99d0a29690fe5..70b4c7b677c5d17b0cb41157b9110d516e5cfcd8 100644 (file)
@@ -96,7 +96,7 @@ int rand_pool_add_additional_data(RAND_POOL *pool)
     return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
 }
 
-int prov_pool_add_nonce_data(RAND_POOL *pool)
+int ossl_pool_add_nonce_data(RAND_POOL *pool)
 {
     struct {
         pid_t pid;
@@ -118,7 +118,7 @@ int prov_pool_add_nonce_data(RAND_POOL *pool)
     return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
 }
 
-size_t prov_pool_acquire_entropy(RAND_POOL *pool)
+size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
 {
 #if defined(RAND_SEED_VXRANDLIB)
     /* vxRandLib based entropy method */
index d820d3e395c1e51ae61ade376935ec57e9ccc86b..bac6b5723eee14c99d6c879364789d7306491ff9 100644 (file)
@@ -42,7 +42,7 @@
 #  define INTEL_DEF_PROV L"Intel Hardware Cryptographic Service Provider"
 # endif
 
-size_t prov_pool_acquire_entropy(RAND_POOL *pool)
+size_t ossl_pool_acquire_entropy(RAND_POOL *pool)
 {
 # ifndef USE_BCRYPTGENRANDOM
     HCRYPTPROV hProvider;
@@ -122,7 +122,7 @@ size_t prov_pool_acquire_entropy(RAND_POOL *pool)
 }
 
 
-int prov_pool_add_nonce_data(RAND_POOL *pool)
+int ossl_pool_add_nonce_data(RAND_POOL *pool)
 {
     struct {
         DWORD pid;
index bb0d2a46a9bcc0a6d6f027bbb4eff4c4e97bd98a..5ad4ad6d6fe05cdfaf2c79c6a3f61a75fd66ac87 100644 (file)
@@ -61,7 +61,7 @@ static void test_rng_free(void *vdrbg)
     OPENSSL_free(t->entropy);
     OPENSSL_free(t->nonce);
     OPENSSL_free(drbg->data);
-    prov_rand_drbg_free(drbg);
+    ossl_rand_drbg_free(drbg);
 }
 
 static int test_rng_instantiate(PROV_DRBG *drbg,
@@ -293,7 +293,7 @@ static int test_rng_verify_zeroization(void *vdrbg)
 static void *test_rng_new_wrapper(void *provctx, void *parent,
                                    const OSSL_DISPATCH *parent_dispatch)
 {
-    return prov_rand_drbg_new(provctx, parent, parent_dispatch,
+    return ossl_rand_drbg_new(provctx, parent, parent_dispatch,
                               &test_rng_new, &test_rng_instantiate,
                               &test_rng_uninstantiate, &test_rng_reseed,
                               &test_rng_generate);