diff options
author | Jack Lloyd <[email protected]> | 2018-08-08 18:48:56 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-13 11:13:01 -0400 |
commit | dc85761ef02c2ae5d5b676696d7de20c15d571c7 (patch) | |
tree | cfbdc7756e4b2415a85559a665f960306f267e80 /src/lib/asn1 | |
parent | b34fc175d8a5bef2ab148afef9e5aa4faf1d392f (diff) |
Add path validation to FFI
Diffstat (limited to 'src/lib/asn1')
-rw-r--r-- | src/lib/asn1/asn1_time.cpp | 6 | ||||
-rw-r--r-- | src/lib/asn1/asn1_time.h | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/asn1/asn1_time.cpp b/src/lib/asn1/asn1_time.cpp index 43f94af6a..8de42dfde 100644 --- a/src/lib/asn1/asn1_time.cpp +++ b/src/lib/asn1/asn1_time.cpp @@ -262,6 +262,12 @@ std::chrono::system_clock::time_point X509_Time::to_std_timepoint() const return calendar_point(m_year, m_month, m_day, m_hour, m_minute, m_second).to_std_timepoint(); } +uint64_t X509_Time::time_since_epoch() const + { + auto tp = this->to_std_timepoint(); + return std::chrono::duration_cast<std::chrono::seconds>(tp.time_since_epoch()).count(); + } + /* * Compare two X509_Times for in various ways */ diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h index 717c58a7d..83567e780 100644 --- a/src/lib/asn1/asn1_time.h +++ b/src/lib/asn1/asn1_time.h @@ -49,6 +49,9 @@ class BOTAN_PUBLIC_API(2,0) X509_Time final : public ASN1_Object /// Returns a STL timepoint object std::chrono::system_clock::time_point to_std_timepoint() const; + /// Return time since epoch + uint64_t time_since_epoch() const; + private: void set_to(const std::string& t_spec, ASN1_Tag); bool passes_sanity_check() const; |