aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/asn1/asn1_time.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/asn1/asn1_time.h')
-rw-r--r--src/lib/asn1/asn1_time.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h
new file mode 100644
index 000000000..95baacd86
--- /dev/null
+++ b/src/lib/asn1/asn1_time.h
@@ -0,0 +1,57 @@
+/*
+* ASN.1 Time Representation
+* (C) 1999-2007,2012 Jack Lloyd
+*
+* Distributed under the terms of the Botan license
+*/
+
+#ifndef BOTAN_ASN1_TIME_H__
+#define BOTAN_ASN1_TIME_H__
+
+#include <botan/asn1_obj.h>
+#include <chrono>
+
+namespace Botan {
+
+/**
+* X.509 Time
+*/
+class BOTAN_DLL X509_Time : public ASN1_Object
+ {
+ public:
+ void encode_into(class DER_Encoder&) const;
+ void decode_from(class BER_Decoder&);
+
+ std::string as_string() const;
+ std::string readable_string() const;
+ bool time_is_set() const;
+
+ std::string to_string() const { return readable_string(); }
+
+ s32bit cmp(const X509_Time&) const;
+
+ void set_to(const std::string&);
+ void set_to(const std::string&, ASN1_Tag);
+
+ X509_Time(const std::chrono::system_clock::time_point& time);
+ X509_Time(const std::string& = "");
+ X509_Time(const std::string&, ASN1_Tag);
+ private:
+ bool passes_sanity_check() const;
+ u32bit year, month, day, hour, minute, second;
+ ASN1_Tag tag;
+ };
+
+/*
+* Comparison Operations
+*/
+bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&);
+bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&);
+bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&);
+bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&);
+bool BOTAN_DLL operator<(const X509_Time&, const X509_Time&);
+bool BOTAN_DLL operator>(const X509_Time&, const X509_Time&);
+
+}
+
+#endif