From 5b11389ce53ed7fffc2ec4099109bd281776223b Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 27 Oct 2021 09:50:57 +0000 Subject: Add ASN1_TIME_diff from OpenSSL. The symbol is not yet exposed and will show up with tb@'s forthcoming bump ok tb@ jsing@ --- src/lib/libcrypto/asn1/a_time.c | 16 +++++++++++++++- src/lib/libcrypto/asn1/asn1.h | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/lib/libcrypto/asn1') diff --git a/src/lib/libcrypto/asn1/a_time.c b/src/lib/libcrypto/asn1/a_time.c index 7a3742fd70..9cb41cf885 100644 --- a/src/lib/libcrypto/asn1/a_time.c +++ b/src/lib/libcrypto/asn1/a_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_time.c,v 1.27 2015/10/19 16:32:37 beck Exp $ */ +/* $OpenBSD: a_time.c,v 1.28 2021/10/27 09:50:57 beck Exp $ */ /* ==================================================================== * Copyright (c) 1999 The OpenSSL Project. All rights reserved. * @@ -105,3 +105,17 @@ ASN1_TIME_free(ASN1_TIME *a) { ASN1_item_free((ASN1_VALUE *)a, &ASN1_TIME_it); } + +int +ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, + const ASN1_TIME *to) +{ + struct tm tm_from, tm_to; + + if (ASN1_time_parse(from->data, from->length, &tm_from, 0) == -1) + return 0; + if (ASN1_time_parse(from->data, from->length, &tm_to, 0) == -1) + return 0; + + return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to); +} diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h index 76c294ada8..43b038adaa 100644 --- a/src/lib/libcrypto/asn1/asn1.h +++ b/src/lib/libcrypto/asn1/asn1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1.h,v 1.54 2020/12/08 15:06:42 tb Exp $ */ +/* $OpenBSD: asn1.h,v 1.55 2021/10/27 09:50:57 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -773,6 +773,11 @@ ASN1_TIME *d2i_ASN1_TIME(ASN1_TIME **a, const unsigned char **in, long len); int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **out); extern const ASN1_ITEM ASN1_TIME_it; +#if defined(LIBRESSL_NEW_API) +int ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, + const ASN1_TIME *to); +#endif + extern const ASN1_ITEM ASN1_OCTET_STRING_NDEF_it; ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); -- cgit v1.2.3-55-g6feb