]> git.ipfire.org Git - thirdparty/openssl.git/commit
Bring in posix time conversion functions, originally from BoringSSL
authorBob Beck <beck@openssl.org>
Fri, 3 Oct 2025 12:16:33 +0000 (06:16 -0600)
committerNeil Horman <nhorman@openssl.org>
Tue, 21 Oct 2025 16:18:56 +0000 (12:18 -0400)
commitca7fb4e77ed1a607669fa93cb650fc88f9e3978f
treec4086bceaf88a9387b4a06dccdd9ad4be6811e9f
parent94cc3b7995d82c23b3449708f03f7bff0ba98e92
Bring in posix time conversion functions, originally from BoringSSL

This is effectively a Julien date computation, but done as seconds since
the POSIX epoch, all checked for overflow and limited to dates from year
0000 to 9999.

This is advantageous as it removed the need to use the operating system provided
timegm() and gmtime() functions which are only semi-standardized in any case and
when they aren't there or don't work other nastiness needs to be tried to do
the same thing. Even when they are there, you need to worry about the size of
time_t and if the bad idea bears of unsigned time_t have visited this platform.

By simply doing the conversion ourselves, to and from and int64, this can be
done the same everywhere, and bounds checked when being put into a time_t.

This adds public API that is already added in libre and boring in
<openssl/posix_time.h>:

These are added in the forks due to noticing a fair bit of software needing
to perform similar error-prone conversions themselves when dealing with
ASN1 times (such as what we have to do in the tests). While I intend to
use some of this API for further simplification in a follow on changes in
several places (such as ocsp and X509) For now we only use it to simplify
the test helpers and clean that up a bunch

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28748)
crypto/asn1/a_time_posix.c [new file with mode: 0644]
crypto/asn1/asn1_local.h
crypto/asn1/build.info
crypto/build.info
crypto/o_time.c [deleted file]
doc/man3/OPENSSL_gmtime.pod
include/openssl/posix_time.h [new file with mode: 0644]
providers/fips.module.sources
util/libcrypto.num