9#include <botan/eac_asn_obj.h>
10#include <botan/der_enc.h>
11#include <botan/ber_dec.h>
12#include <botan/charset.h>
13#include <botan/parsing.h>
14#include <botan/internal/rounding.h>
15#include <botan/time.h>
30 result.push_back(
static_cast<byte>(y_first_pos));
33 u32bit y_sec_pos = in % 10;
34 result.push_back(
static_cast<byte>(y_sec_pos));
38u32bit dec_two_digit(
byte b1,
byte b2)
43 if(upper > 9 || lower > 9)
46 return upper*10 + lower;
74 year(y), month(m), day(d), tag(t)
85 year = month = day = 0;
89 std::vector<std::string> params;
92 for (
u32bit j = 0; j != time_str.size(); ++j)
95 current += time_str[j];
99 params.push_back(current);
104 params.push_back(current);
106 if (params.size() != 3)
113 if (!passes_sanity_check())
157 throw Invalid_State(
"EAC_Time::readable_string: No time set");
159 std::string readable;
170bool EAC_Time::passes_sanity_check()
const
172 if (year < 2000 || year > 2099)
174 if (month == 0 || month > 12)
176 if (day == 0 || day > 31)
193 month += months % 12;
210 const s32bit EARLIER = -1, LATER = 1, SAME_TIME = 0;
212 if (year < other.year)
return EARLIER;
213 if (year > other.year)
return LATER;
214 if (month < other.month)
return EARLIER;
215 if (month > other.month)
return LATER;
216 if (day < other.day)
return EARLIER;
217 if (day > other.day)
return LATER;
227 return (t1.
cmp(t2) == 0);
232 return (t1.
cmp(t2) != 0);
237 return (t1.
cmp(t2) <= 0);
242 return (t1.
cmp(t2) >= 0);
247 return (t1.
cmp(t2) > 0);
252 return (t1.
cmp(t2) < 0);
275 year = tmp_year + 2000;
307 result += enc_two_digit(year);
308 result += enc_two_digit(month);
309 result += enc_two_digit(day);
ASN1_Ced(std::string const &str="")
ASN1_Cex(std::string const &str="")
BER_Object get_next_object()
SecureVector< byte > value
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const byte rep[], size_t length)
void add_years(u32bit years)
void decode_from(class BER_Decoder &)
EAC_Time(u64bit, ASN1_Tag t=ASN1_Tag(0))
std::string readable_string() const
void set_to(const std::string &str)
s32bit cmp(const EAC_Time &other) const
void encode_into(class DER_Encoder &) const
std::string as_string() const
void add_months(u32bit months)
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 &)
unsigned long long u64bit
std::string to_string(u64bit n, size_t min_len)
calendar_point calendar_value(u64bit a_time_t)
T round_down(T n, T align_to)
u32bit to_u32bit(const std::string &number)
std::invalid_argument Invalid_Argument
bool operator!=(const OctetString &s1, const OctetString &s2)
bool BOTAN_DLL operator<=(const X509_Time &, const X509_Time &)
bool operator==(const OctetString &s1, const OctetString &s2)
BER_Decoding_Error(const std::string &)
Decoding_Error(const std::string &name)
Invalid_State(const std::string &err)