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>
fips-20230428
Bob Beck 2 years ago committed by Boringssl LUCI CQ
parent 31dcfcd080
commit 6cda656e4a
  1. 1
      crypto/asn1/a_time.c
  2. 1
      crypto/asn1/asn1_test.cc
  3. 10
      crypto/asn1/internal.h
  4. 2
      crypto/asn1/posix_time.c
  5. 41
      include/openssl/time.h
  6. 3
      util/doc.config

@ -55,6 +55,7 @@
* [including the GNU Public Licence.] */
#include <openssl/asn1.h>
#include <openssl/time.h>
#include <string.h>
#include <time.h>

@ -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"

@ -71,16 +71,6 @@ extern "C" {
// 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.

@ -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>

@ -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

@ -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",

Loading…
Cancel
Save