aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/asn1/asn1_time.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-13 12:49:40 -0400
committerJack Lloyd <[email protected]>2018-05-13 12:49:40 -0400
commit1fcf8c6ba3f8912c9c6cba0555597ab0083eaaa2 (patch)
tree07199fd3b677dd02828f73fa1d2dcda272ee7a1f /src/lib/asn1/asn1_time.cpp
parentbef5303b3ec1a17bc79ccce0eecdca4874639b56 (diff)
Add message to BOTAN_ARG_CHECK and use it more widely
Diffstat (limited to 'src/lib/asn1/asn1_time.cpp')
-rw-r--r--src/lib/asn1/asn1_time.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/asn1/asn1_time.cpp b/src/lib/asn1/asn1_time.cpp
index 863a064f0..43f94af6a 100644
--- a/src/lib/asn1/asn1_time.cpp
+++ b/src/lib/asn1/asn1_time.cpp
@@ -37,8 +37,8 @@ X509_Time::X509_Time(const std::string& t_spec, ASN1_Tag tag)
void X509_Time::encode_into(DER_Encoder& der) const
{
- if(m_tag != GENERALIZED_TIME && m_tag != UTC_TIME)
- throw Invalid_Argument("X509_Time: Bad encoding tag");
+ BOTAN_ARG_CHECK(m_tag == UTC_TIME || m_tag == GENERALIZED_TIME,
+ "X509_Time: Bad encoding tag");
der.add_object(m_tag, UNIVERSAL, to_string());
}
@@ -161,21 +161,17 @@ void X509_Time::set_to(const std::string& t_spec, ASN1_Tag spec_tag)
BOTAN_ASSERT(spec_tag == UTC_TIME || spec_tag == GENERALIZED_TIME, "Invalid tag.");
- if(t_spec.empty())
- throw Invalid_Argument("Time string must not be empty.");
+ BOTAN_ARG_CHECK(t_spec.size() > 0, "Time string must not be empty.");
- if(t_spec.back() != 'Z')
- throw Unsupported_Argument("Botan does not support times with timezones other than Z: " + t_spec);
+ BOTAN_ARG_CHECK(t_spec.back() == 'Z', "Botan does not support times with timezones other than Z");
if(spec_tag == GENERALIZED_TIME)
{
- if(t_spec.size() != 15)
- throw Invalid_Argument("Invalid GeneralizedTime string: '" + t_spec + "'");
+ BOTAN_ARG_CHECK(t_spec.size() == 15, "Invalid GeneralizedTime string");
}
else if(spec_tag == UTC_TIME)
{
- if(t_spec.size() != 13)
- throw Invalid_Argument("Invalid UTCTime string: '" + t_spec + "'");
+ BOTAN_ARG_CHECK(t_spec.size() == 13, "Invalid UTCTime string");
}
const size_t YEAR_SIZE = (spec_tag == UTC_TIME) ? 2 : 4;