Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

asn1_time.h
Go to the documentation of this file.
1 /*
2 * ASN.1 Time Representation
3 * (C) 1999-2007,2012 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7
8 #ifndef BOTAN_ASN1_TIME_H__
9 #define BOTAN_ASN1_TIME_H__
10
11 #include <botan/asn1_obj.h>
12 #include <chrono>
13
14 namespace Botan {
15
16 /**
17 * X.509 Time
18 */
19 class BOTAN_DLL X509_Time final : public ASN1_Object
20 {
21 public:
22 /// DER encode a X509_Time
23 void encode_into(DER_Encoder&) const override;
24
25 // Decode a BER encoded X509_Time
26 void decode_from(BER_Decoder&) override;
27
28 /// Return an internal string representation of the time
29 std::string to_string() const;
30
31 /// Returns a human friendly string replesentation of no particular formatting
32 std::string readable_string() const;
33
34 /// Return if the time has been set somehow
35 bool time_is_set() const;
36
37 /// Compare this time against another
38 int32_t cmp(const X509_Time& other) const;
39
40 /// Create an invalid X509_Time
41 X509_Time() = default;
42
43 /// Create a X509_Time from a time point
44 explicit X509_Time(const std::chrono::system_clock::time_point& time);
45
46 /// Create an X509_Time from string
47 X509_Time(const std::string& t_spec, ASN1_Tag tag);
48
49 /// Returns a STL timepoint object
50 std::chrono::system_clock::time_point to_std_timepoint() const;
51
52 private:
53 void set_to(const std::string& t_spec, ASN1_Tag);
54 bool passes_sanity_check() const;
55
56 uint32_t m_year = 0;
57 uint32_t m_month = 0;
58 uint32_t m_day = 0;
59 uint32_t m_hour = 0;
60 uint32_t m_minute = 0;
61 uint32_t m_second = 0;
62 ASN1_Tag m_tag = NO_OBJECT;
63 };
64
65 /*
66 * Comparison Operations
67 */
68 bool BOTAN_DLL operator==(const X509_Time&, const X509_Time&);
69 bool BOTAN_DLL operator!=(const X509_Time&, const X509_Time&);
70 bool BOTAN_DLL operator<=(const X509_Time&, const X509_Time&);
71 bool BOTAN_DLL operator>=(const X509_Time&, const X509_Time&);
72 bool BOTAN_DLL operator<(const X509_Time&, const X509_Time&);
73 bool BOTAN_DLL operator>(const X509_Time&, const X509_Time&);
74
75 }
76
77 #endif
Botan::operator>=
bool operator>=(const X509_Time &t1, const X509_Time &t2)
Definition: asn1_time.cpp:268
Botan::operator>
bool operator>(const X509_Time &t1, const X509_Time &t2)
Definition: asn1_time.cpp:273
Botan::ASN1_Object
Definition: asn1_obj.h:61
Botan::operator!=
bool operator!=(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
Definition: alg_id.cpp:82
Botan::operator==
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
Definition: alg_id.cpp:67
Botan::operator<
bool operator<(const OID &a, const OID &b)
Definition: asn1_oid.cpp:105
Botan::DER_Encoder
Definition: der_enc.h:22
Botan::ASN1_Tag
ASN1_Tag
Definition: asn1_obj.h:22
Botan
Definition: alg_id.cpp:13
Botan::to_string
std::string to_string(const secure_vector< uint8_t > &bytes)
Definition: stl_util.h:25
Botan::NO_OBJECT
Definition: asn1_obj.h:54
Botan::operator<=
bool operator<=(const X509_Time &t1, const X509_Time &t2)
Definition: asn1_time.cpp:266
Botan::BER_Decoder
Definition: ber_dec.h:19
Botan::X509_Time
Definition: asn1_time.h:19