rand_unix.c: open random devices on first use only
[oweals/openssl.git] / crypto / rand / rand_vms.c
index 0037466ef725217f983cc67f13ceb4f89d1d43b6..bfcf6f0a86c508e9b0c23411f67c6ae2ac2d77d4 100644 (file)
@@ -277,13 +277,13 @@ static size_t prepare_item_list(const struct item_st *items_input,
 
     for (; items_input_num-- > 0; items_input++, items++) {
 
+        items->ile3$w_code = items_input->code;
         /* Special treatment of JPI$_FINALEXC */
         if (items->ile3$w_code == JPI$_FINALEXC)
             items->ile3$w_length = 4;
         else
             items->ile3$w_length = items_input->length;
 
-        items->ile3$w_code = items_input->code;
         items->ile3$ps_bufaddr = databuffer;
         items->ile3$ps_retlen_addr = 0;
 
@@ -478,13 +478,18 @@ int rand_pool_add_nonce_data(RAND_POOL *pool)
     } data = { 0 };
 
     /*
-     * Add process id, thread id, and a high resolution timestamp to
-     * ensure that the nonce is unique whith high probability for
-     * different process instances.
+     * Add process id, thread id, and a high resolution timestamp
+     * (where available, which is OpenVMS v8.4 and up) to ensure that
+     * the nonce is unique whith high probability for different process
+     * instances.
      */
     data.pid = getpid();
     data.tid = CRYPTO_THREAD_get_current_id();
+#if __CRTL_VER >= 80400000
     sys$gettim_prec(&data.time);
+#else
+    sys$gettim((void*)&data.time);
+#endif
 
     return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
 }
@@ -507,4 +512,17 @@ int rand_pool_add_additional_data(RAND_POOL *pool)
     return rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0);
 }
 
+int rand_pool_init(void)
+{
+    return 1;
+}
+
+void rand_pool_cleanup(void)
+{
+}
+
+void rand_pool_keep_random_devices_open(int keep)
+{
+}
+
 #endif