diff options
Diffstat (limited to 'src/lib/libcrypto/x509')
| -rw-r--r-- | src/lib/libcrypto/x509/x509_internal.h | 5 | ||||
| -rw-r--r-- | src/lib/libcrypto/x509/x509_verify.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 26 |
3 files changed, 8 insertions, 27 deletions
diff --git a/src/lib/libcrypto/x509/x509_internal.h b/src/lib/libcrypto/x509/x509_internal.h index ced6b306e5..9d69055afa 100644 --- a/src/lib/libcrypto/x509/x509_internal.h +++ b/src/lib/libcrypto/x509/x509_internal.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_internal.h,v 1.2 2020/09/13 15:06:17 beck Exp $ */ | 1 | /* $OpenBSD: x509_internal.h,v 1.3 2020/09/15 11:55:14 beck Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -87,6 +87,9 @@ int x509_vfy_check_trust(X509_STORE_CTX *ctx); | |||
| 87 | int x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx); | 87 | int x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx); |
| 88 | void x509v3_cache_extensions(X509 *x); | 88 | void x509v3_cache_extensions(X509 *x); |
| 89 | 89 | ||
| 90 | int x509_verify_asn1_time_to_tm(const ASN1_TIME *atime, struct tm *tm, | ||
| 91 | int notafter); | ||
| 92 | |||
| 90 | struct x509_verify_ctx *x509_verify_ctx_new_from_xsc(X509_STORE_CTX *xsc, | 93 | struct x509_verify_ctx *x509_verify_ctx_new_from_xsc(X509_STORE_CTX *xsc, |
| 91 | STACK_OF(X509) *roots); | 94 | STACK_OF(X509) *roots); |
| 92 | 95 | ||
diff --git a/src/lib/libcrypto/x509/x509_verify.c b/src/lib/libcrypto/x509/x509_verify.c index 431f5ab1bc..c3280774f9 100644 --- a/src/lib/libcrypto/x509/x509_verify.c +++ b/src/lib/libcrypto/x509/x509_verify.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_verify.c,v 1.6 2020/09/14 12:33:51 beck Exp $ */ | 1 | /* $OpenBSD: x509_verify.c,v 1.7 2020/09/15 11:55:14 beck Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -484,7 +484,7 @@ x509_verify_set_check_time(struct x509_verify_ctx *ctx) { | |||
| 484 | return 1; | 484 | return 1; |
| 485 | } | 485 | } |
| 486 | 486 | ||
| 487 | static int | 487 | int |
| 488 | x509_verify_asn1_time_to_tm(const ASN1_TIME *atime, struct tm *tm, int notafter) | 488 | x509_verify_asn1_time_to_tm(const ASN1_TIME *atime, struct tm *tm, int notafter) |
| 489 | { | 489 | { |
| 490 | int type; | 490 | int type; |
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 8a616b6bc2..99a699f99e 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_vfy.c,v 1.78 2020/09/14 09:09:08 beck Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.79 2020/09/15 11:55:14 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 | * |
| @@ -2004,7 +2004,6 @@ X509_cmp_time_internal(const ASN1_TIME *ctm, time_t *cmp_time, int clamp_notafte | |||
| 2004 | time_t compare; | 2004 | time_t compare; |
| 2005 | struct tm tm1, tm2; | 2005 | struct tm tm1, tm2; |
| 2006 | int ret = 0; | 2006 | int ret = 0; |
| 2007 | int type; | ||
| 2008 | 2007 | ||
| 2009 | if (cmp_time == NULL) | 2008 | if (cmp_time == NULL) |
| 2010 | compare = time(NULL); | 2009 | compare = time(NULL); |
| @@ -2013,30 +2012,9 @@ X509_cmp_time_internal(const ASN1_TIME *ctm, time_t *cmp_time, int clamp_notafte | |||
| 2013 | 2012 | ||
| 2014 | memset(&tm1, 0, sizeof(tm1)); | 2013 | memset(&tm1, 0, sizeof(tm1)); |
| 2015 | 2014 | ||
| 2016 | type = ASN1_time_parse(ctm->data, ctm->length, &tm1, ctm->type); | 2015 | if (!x509_verify_asn1_time_to_tm(ctm, &tm1, clamp_notafter)) |
| 2017 | if (type == -1) | ||
| 2018 | goto out; /* invalid time */ | 2016 | goto out; /* invalid time */ |
| 2019 | 2017 | ||
| 2020 | /* RFC 5280 section 4.1.2.5 */ | ||
| 2021 | if (tm1.tm_year < 150 && type != V_ASN1_UTCTIME) | ||
| 2022 | goto out; | ||
| 2023 | if (tm1.tm_year >= 150 && type != V_ASN1_GENERALIZEDTIME) | ||
| 2024 | goto out; | ||
| 2025 | |||
| 2026 | if (clamp_notafter) { | ||
| 2027 | /* Allow for completely broken operating systems. */ | ||
| 2028 | if (!ASN1_time_tm_clamp_notafter(&tm1)) | ||
| 2029 | goto out; | ||
| 2030 | } | ||
| 2031 | |||
| 2032 | /* | ||
| 2033 | * Defensively fail if the time string is not representable as | ||
| 2034 | * a time_t. A time_t must be sane if you care about times after | ||
| 2035 | * Jan 19 2038. | ||
| 2036 | */ | ||
| 2037 | if (timegm(&tm1) == -1) | ||
| 2038 | goto out; | ||
| 2039 | |||
| 2040 | if (gmtime_r(&compare, &tm2) == NULL) | 2018 | if (gmtime_r(&compare, &tm2) == NULL) |
| 2041 | goto out; | 2019 | goto out; |
| 2042 | 2020 | ||
