0002-Add-functions-to-retrieve-certificate-validity-perio.patch (1857B)
1 From 89dfcdd084486a728c347e14ec619cd46c430ffd Mon Sep 17 00:00:00 2001 2 From: Michael Forney <mforney@mforney.org> 3 Date: Thu, 26 Mar 2020 14:17:19 -0700 4 Subject: [PATCH] Add functions to retrieve certificate validity period from 5 br_x509_decoder. 6 7 --- 8 inc/bearssl_x509.h | 36 ++++++++++++++++++++++++++++++++++++ 9 1 file changed, 36 insertions(+) 10 11 diff --git a/inc/bearssl_x509.h b/inc/bearssl_x509.h 12 index 7668e1d..a50b8fe 100644 13 --- a/inc/bearssl_x509.h 14 +++ b/inc/bearssl_x509.h 15 @@ -1122,6 +1122,42 @@ br_x509_decoder_last_error(br_x509_decoder_context *ctx) 16 return 0; 17 } 18 19 +/** 20 + * \brief Get the time when the certificate becomes valid. 21 + * 22 + * The time is represented the same as in `br_x509_minimal_set_time()`. 23 + * These values should not be read before decoding completed successfully. 24 + * 25 + * \param ctx X.509 decoder context. 26 + * \param days receives the days since January 1st, 0 AD. 27 + * \param seconds receives the seconds since midnight (0 to 86400). 28 + */ 29 +static inline void 30 +br_x509_decoder_get_notbefore(br_x509_decoder_context *ctx, 31 + uint32_t *days, uint32_t *seconds) 32 +{ 33 + *days = ctx->notbefore_days; 34 + *seconds = ctx->notbefore_seconds; 35 +} 36 + 37 +/** 38 + * \brief Get the time when the certificate is no longer valid. 39 + * 40 + * The time is represented the same as in `br_x509_minimal_set_time()`. 41 + * These values should not be read before decoding completed successfully. 42 + * 43 + * \param ctx X.509 decoder context. 44 + * \param days receives the days since January 1st, 0 AD. 45 + * \param seconds receives the seconds since midnight (0 to 86400). 46 + */ 47 +static inline void 48 +br_x509_decoder_get_notafter(br_x509_decoder_context *ctx, 49 + uint32_t *days, uint32_t *seconds) 50 +{ 51 + *days = ctx->notafter_days; 52 + *seconds = ctx->notafter_seconds; 53 +} 54 + 55 /** 56 * \brief Get the "isCA" flag from an X.509 decoder context. 57 * 58 -- 59 2.35.1 60