From db7308de87ea138e7bbcbbb00dfc9b841774ba2f Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Fri, 26 Jan 2024 09:39:08 -0700 Subject: [PATCH] Rename to There's a desire to upstream this in a compatible way to other projects so they can use the same public API as us, however for some C based build systems having an include file potentially on the include path that can end up being picked up when you include is problematic and annoying, so let's just avoid the unnecessary pain. Update-Note: has moved to Change-Id: I7c6aa92e95a10ff65275851fcf596b06e4848789 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/65847 Commit-Queue: Bob Beck Auto-Submit: Bob Beck Reviewed-by: David Benjamin --- crypto/asn1/a_gentm.c | 2 +- crypto/asn1/a_time.c | 2 +- crypto/asn1/a_utctm.c | 2 +- crypto/asn1/asn1_test.cc | 2 +- crypto/asn1/posix_time.c | 2 +- include/openssl/posix_time.h | 45 ++++++++++++++++++++++++++++++++++++ include/openssl/time.h | 29 +++-------------------- pki/encode_values.cc | 2 +- util/doc.config | 4 ++-- 9 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 include/openssl/posix_time.h diff --git a/crypto/asn1/a_gentm.c b/crypto/asn1/a_gentm.c index 64cb1b562..f6f9c4634 100644 --- a/crypto/asn1/a_gentm.c +++ b/crypto/asn1/a_gentm.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index d8ec85f7c..d2c672c02 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c @@ -55,7 +55,7 @@ * [including the GNU Public Licence.] */ #include -#include +#include #include #include diff --git a/crypto/asn1/a_utctm.c b/crypto/asn1/a_utctm.c index 2963bbe7a..f21435d8b 100644 --- a/crypto/asn1/a_utctm.c +++ b/crypto/asn1/a_utctm.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc index c2e5f5b4d..76d6889e2 100644 --- a/crypto/asn1/asn1_test.cc +++ b/crypto/asn1/asn1_test.cc @@ -29,8 +29,8 @@ #include #include #include +#include #include -#include #include #include "../test/test_util.h" diff --git a/crypto/asn1/posix_time.c b/crypto/asn1/posix_time.c index 31d184c08..5ac4eeb24 100644 --- a/crypto/asn1/posix_time.c +++ b/crypto/asn1/posix_time.c @@ -15,7 +15,7 @@ // Time conversion to/from POSIX time_t and struct tm, with no support // for time zones other than UTC -#include +#include #include #include diff --git a/include/openssl/posix_time.h b/include/openssl/posix_time.h new file mode 100644 index 000000000..7910e3424 --- /dev/null +++ b/include/openssl/posix_time.h @@ -0,0 +1,45 @@ +/* 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_POSIX_TIME_H +#define OPENSSL_HEADER_POSIX_TIME_H + +#include + +#include + +#if defined(__cplusplus) +extern "C" { +#endif + + +// Time functions. + + +// 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_POSIX_TIME_H diff --git a/include/openssl/time.h b/include/openssl/time.h index 50db22d32..690959470 100644 --- a/include/openssl/time.h +++ b/include/openssl/time.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2022, Google Inc. +/* Copyright (c) 2024, 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 @@ -15,31 +15,8 @@ #ifndef OPENSSL_HEADER_TIME_H #define OPENSSL_HEADER_TIME_H -#include +// Compatibility header, to be deprecated. use instead. -#include - -#if defined(__cplusplus) -extern "C" { -#endif - - -// Time functions. - - -// 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 +#include #endif // OPENSSL_HEADER_TIME_H diff --git a/pki/encode_values.cc b/pki/encode_values.cc index 25dc677b8..0054fa28f 100644 --- a/pki/encode_values.cc +++ b/pki/encode_values.cc @@ -6,7 +6,7 @@ #include "parse_values.h" -#include +#include namespace bssl::der { diff --git a/util/doc.config b/util/doc.config index 29bba6701..d2bc5003a 100644 --- a/util/doc.config +++ b/util/doc.config @@ -14,9 +14,9 @@ "include/openssl/mem.h", "include/openssl/obj.h", "include/openssl/pool.h", + "include/openssl/posix_time.h", "include/openssl/rand.h", - "include/openssl/stack.h", - "include/openssl/time.h" + "include/openssl/stack.h" ] },{ "Name": "Low-level crypto primitives",