Make OPENSSL_tm_to_posix and OPENSSL_posix_to_tm public API I have a use for these in the chrome verifier conversions, we could choose to make them hidden again after a future move to boringssl.. Change-Id: If059debbdf482d64577ad04c1ec4f9c82724de1e Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55305 Reviewed-by: Adam Langley <agl@google.com> Commit-Queue: Bob Beck <bbe@google.com>
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 5082969..39b54a6 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c
@@ -55,6 +55,7 @@ * [including the GNU Public Licence.] */ #include <openssl/asn1.h> +#include <openssl/time.h> #include <string.h> #include <time.h>
diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc index fc489f7..3182a85 100644 --- a/crypto/asn1/asn1_test.cc +++ b/crypto/asn1/asn1_test.cc
@@ -29,6 +29,7 @@ #include <openssl/mem.h> #include <openssl/obj.h> #include <openssl/span.h> +#include <openssl/time.h> #include <openssl/x509v3.h> #include "../test/test_util.h"
diff --git a/crypto/asn1/internal.h b/crypto/asn1/internal.h index a934bfb..21619c9 100644 --- a/crypto/asn1/internal.h +++ b/crypto/asn1/internal.h
@@ -71,16 +71,6 @@ // Wrapper functions for time functions. -// OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time| whuch must -// be in the range of year 0000 to 9999 to a broken out time value in |tm|. It -// returns one on success and zero on error. -OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm); - -// OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in -// |tm| to a POSIX time value in |out|. One is returned on success, zero is -// returned on failure. It is a failure if the tm contains out of range values. -OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out); - // OPENSSL_gmtime converts a time_t value in |time| which must be in the range // of year 0000 to 9999 to a broken out time value in |tm|. On success |tm| is // returned. On failure NULL is returned.
diff --git a/crypto/asn1/posix_time.c b/crypto/asn1/posix_time.c index 7dd9e5b..31d184c 100644 --- a/crypto/asn1/posix_time.c +++ b/crypto/asn1/posix_time.c
@@ -15,6 +15,8 @@ // Time conversion to/from POSIX time_t and struct tm, with no support // for time zones other than UTC +#include <openssl/time.h> + #include <assert.h> #include <inttypes.h> #include <limits.h>
diff --git a/include/openssl/time.h b/include/openssl/time.h new file mode 100644 index 0000000..723ce10 --- /dev/null +++ b/include/openssl/time.h
@@ -0,0 +1,41 @@ +/* Copyright (c) 2022, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_TIME_H +#define OPENSSL_HEADER_TIME_H + +#include <openssl/base.h> + +#include <time.h> + +#if defined(__cplusplus) +extern "C" { +#endif + +// OPENSSL_posix_to_tm converts a int64_t POSIX time value in |time|, which must +// be in the range of year 0000 to 9999, to a broken out time value in |tm|. It +// returns one on success and zero on error. +OPENSSL_EXPORT int OPENSSL_posix_to_tm(int64_t time, struct tm *out_tm); + +// OPENSSL_tm_to_posix converts a time value between the years 0 and 9999 in +// |tm| to a POSIX time value in |out|. One is returned on success, zero is +// returned on failure. It is a failure if |tm| contains out of range values. +OPENSSL_EXPORT int OPENSSL_tm_to_posix(const struct tm *tm, int64_t *out); + + +#if defined(__cplusplus) +} // extern C +#endif + +#endif // OPENSSL_HEADER_TIME_H
diff --git a/util/doc.config b/util/doc.config index 8de5f1d..dc05a2b 100644 --- a/util/doc.config +++ b/util/doc.config
@@ -54,7 +54,8 @@ },{ "Name": "Legacy ASN.1 and X.509 implementation (documentation in progress)", "Headers": [ - "include/openssl/asn1.h" + "include/openssl/asn1.h", + "include/openssl/time.h" ] },{ "Name": "SSL implementation",