diff options
author | beck <> | 2021-10-27 09:50:57 +0000 |
---|---|---|
committer | beck <> | 2021-10-27 09:50:57 +0000 |
commit | 5b11389ce53ed7fffc2ec4099109bd281776223b (patch) | |
tree | e390498509bc0c0f8cb6b474d56f38580879b460 /src/lib/libcrypto/asn1 | |
parent | 9708d91b72dd881ff18329e76e72608f97555822 (diff) | |
download | openbsd-5b11389ce53ed7fffc2ec4099109bd281776223b.tar.gz openbsd-5b11389ce53ed7fffc2ec4099109bd281776223b.tar.bz2 openbsd-5b11389ce53ed7fffc2ec4099109bd281776223b.zip |
Add ASN1_TIME_diff from OpenSSL.
The symbol is not yet exposed and will show up with tb@'s forthcoming bump
ok tb@ jsing@
Diffstat (limited to 'src/lib/libcrypto/asn1')
-rw-r--r-- | src/lib/libcrypto/asn1/a_time.c | 16 | ||||
-rw-r--r-- | src/lib/libcrypto/asn1/asn1.h | 7 |
2 files changed, 21 insertions, 2 deletions
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 @@ | |||
1 | /* $OpenBSD: a_time.c,v 1.27 2015/10/19 16:32:37 beck Exp $ */ | 1 | /* $OpenBSD: a_time.c,v 1.28 2021/10/27 09:50:57 beck Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -105,3 +105,17 @@ ASN1_TIME_free(ASN1_TIME *a) | |||
105 | { | 105 | { |
106 | ASN1_item_free((ASN1_VALUE *)a, &ASN1_TIME_it); | 106 | ASN1_item_free((ASN1_VALUE *)a, &ASN1_TIME_it); |
107 | } | 107 | } |
108 | |||
109 | int | ||
110 | ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, | ||
111 | const ASN1_TIME *to) | ||
112 | { | ||
113 | struct tm tm_from, tm_to; | ||
114 | |||
115 | if (ASN1_time_parse(from->data, from->length, &tm_from, 0) == -1) | ||
116 | return 0; | ||
117 | if (ASN1_time_parse(from->data, from->length, &tm_to, 0) == -1) | ||
118 | return 0; | ||
119 | |||
120 | return OPENSSL_gmtime_diff(pday, psec, &tm_from, &tm_to); | ||
121 | } | ||
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 @@ | |||
1 | /* $OpenBSD: asn1.h,v 1.54 2020/12/08 15:06:42 tb Exp $ */ | 1 | /* $OpenBSD: asn1.h,v 1.55 2021/10/27 09:50:57 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -773,6 +773,11 @@ ASN1_TIME *d2i_ASN1_TIME(ASN1_TIME **a, const unsigned char **in, long len); | |||
773 | int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **out); | 773 | int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **out); |
774 | extern const ASN1_ITEM ASN1_TIME_it; | 774 | extern const ASN1_ITEM ASN1_TIME_it; |
775 | 775 | ||
776 | #if defined(LIBRESSL_NEW_API) | ||
777 | int ASN1_TIME_diff(int *pday, int *psec, const ASN1_TIME *from, | ||
778 | const ASN1_TIME *to); | ||
779 | #endif | ||
780 | |||
776 | extern const ASN1_ITEM ASN1_OCTET_STRING_NDEF_it; | 781 | extern const ASN1_ITEM ASN1_OCTET_STRING_NDEF_it; |
777 | 782 | ||
778 | ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); | 783 | ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); |