summaryrefslogtreecommitdiffstats
path: root/crypto/ts
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2022-08-29 14:53:45 +1000
committerPauli <pauli@openssl.org>2022-09-13 21:13:35 +1000
commit5d1bb4fc47582b06dd224a788bdfaaced60e72a0 (patch)
tree114804c929bb4ecf642752bb186aa42cfe6ebc41 /crypto/ts
parent02d0f87a8ba143eaeaee3334a2f63543b10148a9 (diff)
libcrypto: remove reliance on struct timeval
Reviewed-by: Todd Short <todd.short@me.com> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19082)
Diffstat (limited to 'crypto/ts')
-rw-r--r--crypto/ts/ts_rsp_sign.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c
index dce50eb451..88be6fa7bc 100644
--- a/crypto/ts/ts_rsp_sign.c
+++ b/crypto/ts/ts_rsp_sign.c
@@ -15,6 +15,7 @@
#include <openssl/crypto.h>
#include "internal/cryptlib.h"
#include "internal/sizes.h"
+#include "internal/time.h"
#include "crypto/ess.h"
#include "ts_local.h"
@@ -58,46 +59,27 @@ static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *ctx, void *data)
return NULL;
}
-#if defined(OPENSSL_SYS_UNIX)
-
static int def_time_cb(struct TS_resp_ctx *ctx, void *data,
long *sec, long *usec)
{
+ OSSL_TIME t;
struct timeval tv;
- if (gettimeofday(&tv, NULL) != 0) {
- ERR_raise(ERR_LIB_TS, TS_R_TIME_SYSCALL_ERROR);
- TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
- "Time is not available.");
- TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE);
- return 0;
- }
- *sec = tv.tv_sec;
- *usec = tv.tv_usec;
- return 1;
-}
-
-#else
-
-static int def_time_cb(struct TS_resp_ctx *ctx, void *data,
- long *sec, long *usec)
-{
- time_t t;
- if (time(&t) == (time_t)-1) {
+ t = ossl_time_now();
+ if (ossl_time_is_zero(t)) {
ERR_raise(ERR_LIB_TS, TS_R_TIME_SYSCALL_ERROR);
TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
"Time is not available.");
TS_RESP_CTX_add_failure_info(ctx, TS_INFO_TIME_NOT_AVAILABLE);
return 0;
}
- *sec = (long)t;
- *usec = 0;
+ tv = ossl_time_to_timeval(t);
+ *sec = (long int)tv.tv_sec;
+ *usec = (long int)tv.tv_usec;
return 1;
}
-#endif
-
static int def_extension_cb(struct TS_resp_ctx *ctx, X509_EXTENSION *ext,
void *data)
{