summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_time_posix.c
diff options
context:
space:
mode:
authorbeck <>2023-11-13 12:46:07 +0000
committerbeck <>2023-11-13 12:46:07 +0000
commitd0232ec89756b3b83a7ebd92b315b65415b5f0e4 (patch)
treeea8d9b88ee224bef60061210ef255c9bf4048a1c /src/lib/libcrypto/asn1/a_time_posix.c
parent8161eba73aec9d6c1be3143e72d0f95387a0aafe (diff)
downloadopenbsd-d0232ec89756b3b83a7ebd92b315b65415b5f0e4.tar.gz
openbsd-d0232ec89756b3b83a7ebd92b315b65415b5f0e4.tar.bz2
openbsd-d0232ec89756b3b83a7ebd92b315b65415b5f0e4.zip
Prepare to expose OPENSSL_gmtime and OPENSSL_timegm as public
This matches when BoringSSL has done, and allows for getting rid of the dependency on system timegm() and gmtime() in libtls. which will make life easier for portable, and remove our dependency on the potentially very slow system versions. ok tb@ - tb will handle the minor bump bits and expose on the next minor bump CVS :----------------------------------------------------------------------
Diffstat (limited to 'src/lib/libcrypto/asn1/a_time_posix.c')
-rw-r--r--src/lib/libcrypto/asn1/a_time_posix.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_posix.c b/src/lib/libcrypto/asn1/a_time_posix.c
index 9327aa8bf0..5d10d21d3c 100644
--- a/src/lib/libcrypto/asn1/a_time_posix.c
+++ b/src/lib/libcrypto/asn1/a_time_posix.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_time_posix.c,v 1.3 2023/01/01 16:58:23 miod Exp $ */ 1/* $OpenBSD: a_time_posix.c,v 1.4 2023/11/13 12:46:07 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2022, Google Inc. 3 * Copyright (c) 2022, Google Inc.
4 * Copyright (c) 2022, Bob Beck <beck@obtuse.com> 4 * Copyright (c) 2022, Bob Beck <beck@obtuse.com>
@@ -26,6 +26,8 @@
26#include <string.h> 26#include <string.h>
27#include <time.h> 27#include <time.h>
28 28
29#include <openssl/asn1.h>
30
29#define SECS_PER_HOUR (int64_t)(60 * 60) 31#define SECS_PER_HOUR (int64_t)(60 * 60)
30#define SECS_PER_DAY (int64_t)(24 * SECS_PER_HOUR) 32#define SECS_PER_DAY (int64_t)(24 * SECS_PER_HOUR)
31 33
@@ -221,6 +223,20 @@ asn1_time_time_t_to_tm(const time_t *time, struct tm *out_tm)
221} 223}
222 224
223int 225int
226OPENSSL_timegm(const struct tm *tm, time_t *out) {
227 return asn1_time_tm_to_time_t(tm, out);
228}
229LCRYPTO_ALIAS(OPENSSL_timegm);
230
231struct tm *
232OPENSSL_gmtime(const time_t *time, struct tm *out_tm) {
233 if (!asn1_time_time_t_to_tm(time, out_tm))
234 return NULL;
235 return out_tm;
236}
237LCRYPTO_ALIAS(OPENSSL_gmtime);
238
239int
224OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec) 240OPENSSL_gmtime_adj(struct tm *tm, int off_day, long offset_sec)
225{ 241{
226 int64_t posix_time; 242 int64_t posix_time;