Add a DRBG to each SSL object
[openssl.git] / crypto / rand / drbg_lib.c
index e3d97d38d96e3f79988dfd8ca2e7746bcad81319..a24ec8e2e4961de1ff41765e2ddc04094bd6253c 100644 (file)
@@ -78,6 +78,9 @@ RAND_DRBG *RAND_DRBG_new(int type, unsigned int flags, RAND_DRBG *parent)
         goto err;
 
     if (parent != NULL) {
+        if (parent->state == DRBG_UNINITIALISED
+                && RAND_DRBG_instantiate(parent, NULL, 0) == 0)
+            goto err;
         if (!RAND_DRBG_set_callbacks(drbg, drbg_entropy_from_parent,
                                      drbg_release_entropy,
                                      NULL, NULL)
@@ -98,6 +101,11 @@ err:
     return NULL;
 }
 
+RAND_DRBG *RAND_DRBG_get0_global(void)
+{
+    return &rand_drbg;
+}
+
 /*
  * Uninstantiate |drbg| and free all memory.
  */