aboutsummaryrefslogtreecommitdiffstats
path: root/src/cert
diff options
context:
space:
mode:
authorlloyd <[email protected]>2011-02-09 14:27:03 +0000
committerlloyd <[email protected]>2011-02-09 14:27:03 +0000
commit3495b0bbe0779845800fe34ea93acffffc8c2785 (patch)
treeeb48a607a1ca2d6d6227cf7a71efdf52178b5a04 /src/cert
parent02ed4e271a6287a0c23b137e826e62d2be752b82 (diff)
Some cleanups, and add an <ios> include for Sun Studio 12
Diffstat (limited to 'src/cert')
-rw-r--r--src/cert/cvc/asn1_eac_str.cpp39
-rw-r--r--src/cert/cvc/asn1_eac_tm.cpp48
2 files changed, 47 insertions, 40 deletions
diff --git a/src/cert/cvc/asn1_eac_str.cpp b/src/cert/cvc/asn1_eac_str.cpp
index e617ba81f..37a601e4e 100644
--- a/src/cert/cvc/asn1_eac_str.cpp
+++ b/src/cert/cvc/asn1_eac_str.cpp
@@ -1,7 +1,7 @@
/*
* Simple ASN.1 String Types
* (C) 2007 FlexSecure GmbH
-* 2008 Jack Lloyd
+* 2008-2011 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/
@@ -12,6 +12,7 @@
#include <botan/charset.h>
#include <botan/parsing.h>
#include <sstream>
+#include <ios>
namespace Botan {
@@ -21,10 +22,9 @@ namespace Botan {
ASN1_EAC_String::ASN1_EAC_String(const std::string& str, ASN1_Tag t) : tag(t)
{
iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
- if (!sanity_check())
- {
- throw Invalid_Argument("attempted to construct ASN1_EAC_String with illegal characters");
- }
+
+ if(!sanity_check())
+ throw Invalid_Argument("ASN1_EAC_String contains illegal characters");
}
/*
@@ -66,23 +66,19 @@ void ASN1_EAC_String::encode_into(DER_Encoder& encoder) const
void ASN1_EAC_String::decode_from(BER_Decoder& source)
{
BER_Object obj = source.get_next_object();
- if (obj.type_tag != this->tag)
- {
- std::string message("decoding type mismatch for ASN1_EAC_String, tag is ");
+ if(obj.type_tag != this->tag)
+ {
std::stringstream ss;
- std::string str_is;
- ss << std::hex << obj.type_tag;
- ss >> str_is;
- message.append(str_is);
- message.append(", while it should be ");
- std::stringstream ss2;
- std::string str_should;
- ss2 << std::hex << this->tag;
- ss2 >> str_should;
- message.append(str_should);
- throw Decoding_Error(message);
+
+ ss << "ASN1_EAC_String tag mismatch, tag was "
+ << std::hex << obj.type_tag
+ << " expected "
+ << std::hex << this->tag;
+
+ throw Decoding_Error(ss.str());
}
+
Character_Set charset_is;
charset_is = LATIN1_CHARSET;
@@ -92,9 +88,10 @@ void ASN1_EAC_String::decode_from(BER_Decoder& source)
Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET),
obj.type_tag);
}
- catch (Invalid_Argument inv_arg)
+ catch(Invalid_Argument inv_arg)
{
- throw Decoding_Error(std::string("error while decoding ASN1_EAC_String: ") + std::string(inv_arg.what()));
+ throw Decoding_Error(std::string("ASN1_EAC_String decoding failed: ") +
+ inv_arg.what());
}
}
diff --git a/src/cert/cvc/asn1_eac_tm.cpp b/src/cert/cvc/asn1_eac_tm.cpp
index 0eaca49d6..db5d2fbaf 100644
--- a/src/cert/cvc/asn1_eac_tm.cpp
+++ b/src/cert/cvc/asn1_eac_tm.cpp
@@ -45,6 +45,7 @@ u32bit dec_two_digit(byte b1, byte b2)
return upper*10 + lower;
}
+
}
/*
@@ -62,19 +63,15 @@ EAC_Time::EAC_Time(u64bit timer, ASN1_Tag t) : tag(t)
/*
* Create an EAC_Time
*/
-EAC_Time::EAC_Time(const std::string& t_spec, ASN1_Tag t)
- :tag(t)
+EAC_Time::EAC_Time(const std::string& t_spec, ASN1_Tag t) : tag(t)
{
set_to(t_spec);
}
/*
* Create an EAC_Time
*/
-EAC_Time::EAC_Time(u32bit y, u32bit m, u32bit d, ASN1_Tag t)
- : year(y),
- month(m),
- day(d),
- tag(t)
+EAC_Time::EAC_Time(u32bit y, u32bit m, u32bit d, ASN1_Tag t) :
+ year(y), month(m), day(d), tag(t)
{
}
@@ -229,22 +226,27 @@ bool operator==(const EAC_Time& t1, const EAC_Time& t2)
{
return (t1.cmp(t2) == 0);
}
+
bool operator!=(const EAC_Time& t1, const EAC_Time& t2)
{
return (t1.cmp(t2) != 0);
}
+
bool operator<=(const EAC_Time& t1, const EAC_Time& t2)
{
return (t1.cmp(t2) <= 0);
}
+
bool operator>=(const EAC_Time& t1, const EAC_Time& t2)
{
return (t1.cmp(t2) >= 0);
}
+
bool operator>(const EAC_Time& t1, const EAC_Time& t2)
{
return (t1.cmp(t2) > 0);
}
+
bool operator<(const EAC_Time& t1, const EAC_Time& t2)
{
return (t1.cmp(t2) < 0);
@@ -285,10 +287,12 @@ u32bit EAC_Time::get_year() const
{
return year;
}
+
u32bit EAC_Time::get_month() const
{
return month;
}
+
u32bit EAC_Time::get_day() const
{
return day;
@@ -306,28 +310,34 @@ SecureVector<byte> EAC_Time::encoded_eac_time() const
return result;
}
-ASN1_Ced::ASN1_Ced(std::string const& str)
- : EAC_Time(str, ASN1_Tag(37))
+ASN1_Ced::ASN1_Ced(std::string const& str) :
+ EAC_Time(str, ASN1_Tag(37))
{}
-ASN1_Ced::ASN1_Ced(u64bit val)
- : EAC_Time(val, ASN1_Tag(37))
+ASN1_Ced::ASN1_Ced(u64bit val) :
+ EAC_Time(val, ASN1_Tag(37))
{}
-ASN1_Ced::ASN1_Ced(EAC_Time const& other)
- : EAC_Time(other.get_year(), other.get_month(), other.get_day(), ASN1_Tag(37))
+ASN1_Ced::ASN1_Ced(EAC_Time const& other) :
+ EAC_Time(other.get_year(),
+ other.get_month(),
+ other.get_day(),
+ ASN1_Tag(37))
{}
-ASN1_Cex::ASN1_Cex(std::string const& str)
- : EAC_Time(str, ASN1_Tag(36))
+ASN1_Cex::ASN1_Cex(std::string const& str) :
+ EAC_Time(str, ASN1_Tag(36))
{}
-ASN1_Cex::ASN1_Cex(u64bit val)
- : EAC_Time(val, ASN1_Tag(36))
+ASN1_Cex::ASN1_Cex(u64bit val) :
+ EAC_Time(val, ASN1_Tag(36))
{}
-ASN1_Cex::ASN1_Cex(EAC_Time const& other)
- : EAC_Time(other.get_year(), other.get_month(), other.get_day(), ASN1_Tag(36))
+ASN1_Cex::ASN1_Cex(EAC_Time const& other) :
+ EAC_Time(other.get_year(),
+ other.get_month(),
+ other.get_day(),
+ ASN1_Tag(36))
{}
}