logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

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. inc/bearssl_x509.h | 36 ++++++++++++++++++++++++++++++++++++
  8. 1 file changed, 36 insertions(+)
  9. diff --git a/inc/bearssl_x509.h b/inc/bearssl_x509.h
  10. index 7668e1d..a50b8fe 100644
  11. --- a/inc/bearssl_x509.h
  12. +++ b/inc/bearssl_x509.h
  13. @@ -1122,6 +1122,42 @@ br_x509_decoder_last_error(br_x509_decoder_context *ctx)
  14. return 0;
  15. }
  16. +/**
  17. + * \brief Get the time when the certificate becomes valid.
  18. + *
  19. + * The time is represented the same as in `br_x509_minimal_set_time()`.
  20. + * These values should not be read before decoding completed successfully.
  21. + *
  22. + * \param ctx X.509 decoder context.
  23. + * \param days receives the days since January 1st, 0 AD.
  24. + * \param seconds receives the seconds since midnight (0 to 86400).
  25. + */
  26. +static inline void
  27. +br_x509_decoder_get_notbefore(br_x509_decoder_context *ctx,
  28. + uint32_t *days, uint32_t *seconds)
  29. +{
  30. + *days = ctx->notbefore_days;
  31. + *seconds = ctx->notbefore_seconds;
  32. +}
  33. +
  34. +/**
  35. + * \brief Get the time when the certificate is no longer valid.
  36. + *
  37. + * The time is represented the same as in `br_x509_minimal_set_time()`.
  38. + * These values should not be read before decoding completed successfully.
  39. + *
  40. + * \param ctx X.509 decoder context.
  41. + * \param days receives the days since January 1st, 0 AD.
  42. + * \param seconds receives the seconds since midnight (0 to 86400).
  43. + */
  44. +static inline void
  45. +br_x509_decoder_get_notafter(br_x509_decoder_context *ctx,
  46. + uint32_t *days, uint32_t *seconds)
  47. +{
  48. + *days = ctx->notafter_days;
  49. + *seconds = ctx->notafter_seconds;
  50. +}
  51. +
  52. /**
  53. * \brief Get the "isCA" flag from an X.509 decoder context.
  54. *
  55. --
  56. 2.35.1