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>
21 SecureVector<byte> enc_two_digit(
u32bit in)
23 SecureVector<byte> result;
26 result.push_back(0x00);
29 u32bit y_first_pos = round_down<u32bit>(in, 10) / 10;
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));
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;
170 bool 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);
void encode_into(class DER_Encoder &) const
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)
ASN1_Cex(std::string const &str="")
EAC_Time(u64bit, ASN1_Tag t=ASN1_Tag(0))
std::invalid_argument Invalid_Argument
void decode_from(class BER_Decoder &)
calendar_point calendar_value(u64bit a_time_t)
void add_years(u32bit years)
unsigned long long u64bit
void add_months(u32bit months)
bool BOTAN_DLL operator>(const X509_Time &, const X509_Time &)
std::string readable_string() const
s32bit cmp(const EAC_Time &other) const
ASN1_Ced(std::string const &str="")
std::string as_string() const
SecureVector< byte > value
BER_Object get_next_object()
bool BOTAN_DLL operator<(const X509_Time &, const X509_Time &)
std::string to_string(u64bit n, size_t min_len)
bool BOTAN_DLL operator<=(const X509_Time &, const X509_Time &)
u32bit to_u32bit(const std::string &number)
DER_Encoder & add_object(ASN1_Tag type_tag, ASN1_Tag class_tag, const byte rep[], size_t length)
void set_to(const std::string &str)