|
Botan 3.13.0
Crypto and TLS for C&
|
#include <asn1_time.h>
Public Member Functions | |
| ASN1_Time ()=default | |
| Create an invalid ASN1_Time. | |
| ASN1_Time (const std::chrono::system_clock::time_point &time) | |
| Create a ASN1_Time from a time point. | |
| BOTAN_FUTURE_EXPLICIT | ASN1_Time (std::string_view t_spec) |
| Create an ASN1_Time from string. | |
| ASN1_Time (std::string_view t_spec, ASN1_Type tag) | |
| Create an ASN1_Time from string and a specified tagging (Utc or Generalized). | |
| std::vector< uint8_t > | BER_encode () const |
| int32_t | cmp (const ASN1_Time &other) const |
| Compare this time against another. | |
| void | decode_from (BER_Decoder &from) override |
| void | encode_into (DER_Encoder &to) const override |
| DER encode a ASN1_Time. | |
| std::string | readable_string () const |
| Returns a human friendly string representation of no particular formatting. | |
| ASN1_Type | tagging () const |
| Return the tag (UtcTime or GeneralizedTime) this time was encoded with. | |
| bool | time_is_set () const |
| Return if the time has been set somehow. | |
| uint64_t | time_since_epoch () const |
| Return time since epoch. | |
| std::chrono::system_clock::time_point | to_std_timepoint () const |
| Returns a STL timepoint object. | |
| std::string | to_string () const |
| Return an internal string representation of the time. | |
Static Public Member Functions | |
| static ASN1_Time | from_seconds_since_epoch (uint64_t seconds) |
| Create an ASN1_Time from seconds since epoch. | |
| static ASN1_Time | from_string (std::string_view t_spec) |
| static ASN1_Time | from_string (std::string_view t_spec, ASN1_Type tag) |
| static ASN1_Time | from_time_point (const std::chrono::system_clock::time_point &time) |
| Create a ASN1_Time from a time point. | |
Time (GeneralizedTime/UniversalTime)
Definition at line 18 of file asn1_time.h.
|
default |
Create an invalid ASN1_Time.
References ASN1_Time(), from_seconds_since_epoch(), from_string(), and from_time_point().
Referenced by ASN1_Time(), cmp(), from_seconds_since_epoch(), from_string(), from_string(), and from_time_point().
|
inlineexplicit |
Create a ASN1_Time from a time point.
Definition at line 64 of file asn1_time.h.
References from_time_point().
|
inline |
Create an ASN1_Time from string.
Definition at line 69 of file asn1_time.h.
References BOTAN_FUTURE_EXPLICIT, and from_string().
|
inline |
Create an ASN1_Time from string and a specified tagging (Utc or Generalized).
Definition at line 72 of file asn1_time.h.
References from_string().
|
inherited |
Return the encoding of this object. This is a convenience method when just one object needs to be serialized. Use DER_Encoder for complicated encodings.
Definition at line 21 of file asn1_obj.cpp.
References encode_into().
Referenced by decode_from(), Botan::PKCS12::export_to(), Botan::Certificate_Store_In_SQL::find_all_certs(), Botan::Certificate_Store_In_SQL::find_cert(), Botan::X509_Certificate::fingerprint(), Botan::Certificate_Store_In_SQL::insert_cert(), Botan::X509_Object::PEM_encode(), and Botan::PSS_Params::PSS_Params().
| int32_t Botan::ASN1_Time::cmp | ( | const ASN1_Time & | other | ) | const |
Compare this time against another.
Definition at line 237 of file asn1_time.cpp.
References ASN1_Time(), and time_is_set().
Referenced by Botan::operator!=(), Botan::operator<(), Botan::operator<=(), Botan::operator==(), Botan::operator>(), and Botan::operator>=().
|
overridevirtual |
Decode whatever this object is from from
| from | the BER_Decoder that will be read from |
Implements Botan::ASN1_Object.
Definition at line 168 of file asn1_time.cpp.
References Botan::fmt(), from_string(), Botan::GeneralizedTime, Botan::BER_Object::get_class(), Botan::BER_Decoder::get_next_object(), Botan::ASN1::to_string(), Botan::BER_Object::type(), Botan::Universal, Botan::UtcTime, and Botan::Exception::what().
|
overridevirtual |
DER encode a ASN1_Time.
Implements Botan::ASN1_Object.
Definition at line 162 of file asn1_time.cpp.
References Botan::DER_Encoder::add_object(), BOTAN_ARG_CHECK, Botan::GeneralizedTime, to_string(), Botan::Universal, and Botan::UtcTime.
|
static |
Create an ASN1_Time from seconds since epoch.
Definition at line 37 of file asn1_time.cpp.
References ASN1_Time(), from_time_point(), and time_since_epoch().
Referenced by ASN1_Time().
|
static |
Create a ASN1_Time from a string
Only the fixed 13 or 15 char RFC 5280 format (eg [YY]YYMMDDHHMMSSZ) is accepted, tag is set based on the use of 2 or 4 digit year, 2-digit years use the 1950 breakeven point (see RFC 5280 Section 4.1.2.5.1)
Definition at line 152 of file asn1_time.cpp.
References ASN1_Time(), from_string(), Botan::GeneralizedTime, and Botan::UtcTime.
Referenced by ASN1_Time(), ASN1_Time(), ASN1_Time(), decode_from(), and from_string().
Create a ASN1_Time from a string
Only the fixed 13 or 15 char RFC 5280 format (eg [YY]YYMMDDHHMMSSZ) is accepted, based on the provided tag (which must be UtcTime or GeneralizedTime)
Definition at line 109 of file asn1_time.cpp.
References ASN1_Time(), BOTAN_ARG_CHECK, Botan::GeneralizedTime, Botan::to_u32bit(), and Botan::UtcTime.
|
static |
Create a ASN1_Time from a time point.
Definition at line 94 of file asn1_time.cpp.
References ASN1_Time(), Botan::calendar_point::day(), Botan::GeneralizedTime, Botan::calendar_point::hour(), Botan::calendar_point::minutes(), Botan::calendar_point::month(), Botan::calendar_point::seconds(), Botan::UtcTime, and Botan::calendar_point::year().
Referenced by ASN1_Time(), ASN1_Time(), and from_seconds_since_epoch().
| std::string Botan::ASN1_Time::readable_string | ( | ) | const |
Returns a human friendly string representation of no particular formatting.
Definition at line 218 of file asn1_time.cpp.
References time_is_set().
Referenced by to_string(), and Botan::X509_Certificate::to_string().
|
inline |
Return the tag (UtcTime or GeneralizedTime) this time was encoded with.
Definition at line 36 of file asn1_time.h.
| bool Botan::ASN1_Time::time_is_set | ( | ) | const |
Return if the time has been set somehow.
Definition at line 233 of file asn1_time.cpp.
Referenced by cmp(), readable_string(), Botan::Certificate_Store_In_SQL::revoke_cert(), and to_string().
| uint64_t Botan::ASN1_Time::time_since_epoch | ( | ) | const |
Return time since epoch.
Definition at line 290 of file asn1_time.cpp.
References Botan::calendar_point::seconds_since_epoch().
Referenced by botan_x509_crl_entry_revocation_date(), and from_seconds_since_epoch().
| std::chrono::system_clock::time_point Botan::ASN1_Time::to_std_timepoint | ( | ) | const |
Returns a STL timepoint object.
Definition at line 286 of file asn1_time.cpp.
References Botan::calendar_point::to_std_timepoint().
Referenced by Botan::Certificate_Store_In_SQL::revoke_cert().
| std::string Botan::ASN1_Time::to_string | ( | ) | const |
Return an internal string representation of the time.
Definition at line 187 of file asn1_time.cpp.
References BOTAN_ASSERT_NOMSG, Botan::fmt(), readable_string(), time_is_set(), and Botan::UtcTime.
Referenced by encode_into().