libcrypto: remove reliance on struct timeval
[openssl.git] / crypto / ct / ct_policy.c
index 80a8baabe163d3b1739615e91b8bc7190678c127..ad792b740de1f76d5920c10c9694dd94906d92b0 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <openssl/ct.h>
 #include <openssl/err.h>
-#include <time.h>
+#include "internal/time.h"
 
 #include "ct_local.h"
 
@@ -29,6 +29,7 @@ CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx,
                                               const char *propq)
 {
     CT_POLICY_EVAL_CTX *ctx = OPENSSL_zalloc(sizeof(CT_POLICY_EVAL_CTX));
+    OSSL_TIME now;
 
     if (ctx == NULL) {
         ERR_raise(ERR_LIB_CT, ERR_R_MALLOC_FAILURE);
@@ -45,9 +46,9 @@ CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new_ex(OSSL_LIB_CTX *libctx,
         }
     }
 
-    /* time(NULL) shouldn't ever fail, so don't bother checking for -1. */
-    ctx->epoch_time_in_ms = (uint64_t)(time(NULL) + SCT_CLOCK_DRIFT_TOLERANCE) *
-            1000;
+    now = ossl_time_add(ossl_time_now(),
+                        ossl_seconds2time(SCT_CLOCK_DRIFT_TOLERANCE));
+    ctx->epoch_time_in_ms = ossl_time2ms(now);
 
     return ctx;
 }