summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_time_tm.c
diff options
context:
space:
mode:
authorbeck <>2022-11-08 12:56:00 +0000
committerbeck <>2022-11-08 12:56:00 +0000
commit1b638f6021d5c11fb59141323a36e2cd02da5f36 (patch)
tree6afc424706c2c9c83e686d335838e684e3a74fa2 /src/lib/libcrypto/asn1/a_time_tm.c
parentce83cad5529fd47577d92c512f97ce77f2508fb0 (diff)
downloadopenbsd-1b638f6021d5c11fb59141323a36e2cd02da5f36.tar.gz
openbsd-1b638f6021d5c11fb59141323a36e2cd02da5f36.tar.bz2
openbsd-1b638f6021d5c11fb59141323a36e2cd02da5f36.zip
Replace the old OpenSSL julian date stuff with BoringSSL's
OpenSSL dealt with time conversion using a classical julian day scheme. BoringSSL got rid of it and uses only a julian style calculation for seconds since the POSIX time epoch. This changes libressl to use the seconds calculation exculusively instead of a mix of the julian day based conversions and the system time conversions to and from time_t to tm. ok tb@ jsing@
Diffstat (limited to 'src/lib/libcrypto/asn1/a_time_tm.c')
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index cb677ae93e..2ae8430a0d 100644
--- a/src/lib/libcrypto/asn1/a_time_tm.c
+++ b/src/lib/libcrypto/asn1/a_time_tm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: a_time_tm.c,v 1.24 2022/07/04 14:39:43 tb Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.25 2022/11/08 12:56:00 beck Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -25,7 +25,7 @@
25#include <openssl/err.h> 25#include <openssl/err.h>
26 26
27#include "bytestring.h" 27#include "bytestring.h"
28#include "o_time.h" 28#include "asn1_locl.h"
29 29
30#define RFC5280 0 30#define RFC5280 0
31#define GENTIME_LENGTH 15 31#define GENTIME_LENGTH 15
@@ -68,7 +68,7 @@ ASN1_time_tm_clamp_notafter(struct tm *tm)
68 struct tm broken_os_epoch_tm; 68 struct tm broken_os_epoch_tm;
69 time_t broken_os_epoch_time = INT_MAX; 69 time_t broken_os_epoch_time = INT_MAX;
70 70
71 if (gmtime_r(&broken_os_epoch_time, &broken_os_epoch_tm) == NULL) 71 if (!OPENSSL_gmtime(&broken_os_epoch_time, &broken_os_epoch_tm))
72 return 0; 72 return 0;
73 73
74 if (ASN1_time_tm_cmp(tm, &broken_os_epoch_tm) == 1) 74 if (ASN1_time_tm_cmp(tm, &broken_os_epoch_tm) == 1)
@@ -379,7 +379,7 @@ ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec,
379{ 379{
380 struct tm tm; 380 struct tm tm;
381 381
382 if (gmtime_r(&t, &tm) == NULL) 382 if (!asn1_time_time_t_to_tm(&t, &tm))
383 return (NULL); 383 return (NULL);
384 384
385 if (offset_day != 0 || offset_sec != 0) { 385 if (offset_day != 0 || offset_sec != 0) {
@@ -410,7 +410,7 @@ ASN1_TIME_set_tm(ASN1_TIME *s, struct tm *tm)
410{ 410{
411 time_t t; 411 time_t t;
412 412
413 if ((t = timegm(tm)) == -1) 413 if (!asn1_time_tm_to_time_t(tm, &t))
414 return NULL; 414 return NULL;
415 return (ASN1_TIME_adj(s, t, 0, 0)); 415 return (ASN1_TIME_adj(s, t, 0, 0));
416} 416}
@@ -475,7 +475,7 @@ ASN1_TIME_cmp_time_t_internal(const ASN1_TIME *s, time_t t2, int mode)
475 if (ASN1_time_parse(s->data, s->length, &tm1, mode) == -1) 475 if (ASN1_time_parse(s->data, s->length, &tm1, mode) == -1)
476 return -2; 476 return -2;
477 477
478 if (gmtime_r(&t2, &tm2) == NULL) 478 if (!asn1_time_time_t_to_tm(&t2, &tm2))
479 return -2; 479 return -2;
480 480
481 return ASN1_time_tm_cmp(&tm1, &tm2); 481 return ASN1_time_tm_cmp(&tm1, &tm2);