aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/cert/cvc
diff options
context:
space:
mode:
authorDaniel Neus <[email protected]>2016-01-09 12:37:13 +0100
committerDaniel Neus <[email protected]>2016-01-09 12:37:13 +0100
commitf391635f202cf6f83539bd69688975a30f5f874f (patch)
tree206459e94ab379ba18a8e8035b1855327aa02126 /src/lib/cert/cvc
parent52afcc69d97621e5a3880798d7814a474e71c03b (diff)
parent791b3dc9947a94d35e6d54b274b0512fb0ebd09c (diff)
Merge remote-tracking branch 'remotes/github/master' into noreturn
# Conflicts: # src/build-data/cc/gcc.txt
Diffstat (limited to 'src/lib/cert/cvc')
-rw-r--r--src/lib/cert/cvc/asn1_eac_str.cpp18
-rw-r--r--src/lib/cert/cvc/asn1_eac_tm.cpp76
-rw-r--r--src/lib/cert/cvc/cvc_ado.cpp8
-rw-r--r--src/lib/cert/cvc/cvc_cert.cpp10
-rw-r--r--src/lib/cert/cvc/cvc_gen_cert.h8
-rw-r--r--src/lib/cert/cvc/cvc_req.cpp8
-rw-r--r--src/lib/cert/cvc/cvc_self.h11
-rw-r--r--src/lib/cert/cvc/eac_asn_obj.h14
-rw-r--r--src/lib/cert/cvc/eac_obj.h4
-rw-r--r--src/lib/cert/cvc/signed_obj.cpp8
-rw-r--r--src/lib/cert/cvc/signed_obj.h8
11 files changed, 92 insertions, 81 deletions
diff --git a/src/lib/cert/cvc/asn1_eac_str.cpp b/src/lib/cert/cvc/asn1_eac_str.cpp
index 2472eee17..0134399d8 100644
--- a/src/lib/cert/cvc/asn1_eac_str.cpp
+++ b/src/lib/cert/cvc/asn1_eac_str.cpp
@@ -19,9 +19,9 @@ namespace Botan {
/*
* Create an ASN1_EAC_String
*/
-ASN1_EAC_String::ASN1_EAC_String(const std::string& str, ASN1_Tag t) : tag(t)
+ASN1_EAC_String::ASN1_EAC_String(const std::string& str, ASN1_Tag t) : m_tag(t)
{
- iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
+ m_iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
if(!sanity_check())
throw Invalid_Argument("ASN1_EAC_String contains illegal characters");
@@ -32,7 +32,7 @@ ASN1_EAC_String::ASN1_EAC_String(const std::string& str, ASN1_Tag t) : tag(t)
*/
std::string ASN1_EAC_String::iso_8859() const
{
- return iso_8859_str;
+ return m_iso_8859_str;
}
/*
@@ -40,7 +40,7 @@ std::string ASN1_EAC_String::iso_8859() const
*/
std::string ASN1_EAC_String::value() const
{
- return Charset::transcode(iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
+ return Charset::transcode(m_iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
}
/*
@@ -48,7 +48,7 @@ std::string ASN1_EAC_String::value() const
*/
ASN1_Tag ASN1_EAC_String::tagging() const
{
- return tag;
+ return m_tag;
}
/*
@@ -67,14 +67,14 @@ void ASN1_EAC_String::decode_from(BER_Decoder& source)
{
BER_Object obj = source.get_next_object();
- if(obj.type_tag != this->tag)
+ if(obj.type_tag != m_tag)
{
std::stringstream ss;
ss << "ASN1_EAC_String tag mismatch, tag was "
<< std::hex << obj.type_tag
<< " expected "
- << std::hex << this->tag;
+ << std::hex << m_tag;
throw Decoding_Error(ss.str());
}
@@ -99,8 +99,8 @@ void ASN1_EAC_String::decode_from(BER_Decoder& source)
// p. 43
bool ASN1_EAC_String::sanity_check() const
{
- const byte* rep = reinterpret_cast<const byte*>(iso_8859_str.data());
- const size_t rep_len = iso_8859_str.size();
+ const byte* rep = reinterpret_cast<const byte*>(m_iso_8859_str.data());
+ const size_t rep_len = m_iso_8859_str.size();
for(size_t i = 0; i != rep_len; ++i)
{
diff --git a/src/lib/cert/cvc/asn1_eac_tm.cpp b/src/lib/cert/cvc/asn1_eac_tm.cpp
index 83a6ef391..9c65fcf6a 100644
--- a/src/lib/cert/cvc/asn1_eac_tm.cpp
+++ b/src/lib/cert/cvc/asn1_eac_tm.cpp
@@ -54,19 +54,19 @@ u32bit dec_two_digit(byte b1, byte b2)
* Create an EAC_Time
*/
EAC_Time::EAC_Time(const std::chrono::system_clock::time_point& time,
- ASN1_Tag t) : tag(t)
+ ASN1_Tag t) : m_tag(t)
{
calendar_point cal = calendar_value(time);
- year = cal.year;
- month = cal.month;
- day = cal.day;
+ m_year = cal.year;
+ m_month = cal.month;
+ m_day = cal.day;
}
/*
* 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) : m_tag(t)
{
set_to(t_spec);
}
@@ -75,7 +75,7 @@ EAC_Time::EAC_Time(const std::string& t_spec, ASN1_Tag t) : tag(t)
* 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)
+ m_year(y), m_month(m), m_day(d), m_tag(t)
{
}
@@ -86,7 +86,7 @@ void EAC_Time::set_to(const std::string& time_str)
{
if(time_str == "")
{
- year = month = day = 0;
+ m_year = m_month = m_day = 0;
return;
}
@@ -110,9 +110,9 @@ void EAC_Time::set_to(const std::string& time_str)
if(params.size() != 3)
throw Invalid_Argument("Invalid time specification " + time_str);
- year = to_u32bit(params[0]);
- month = to_u32bit(params[1]);
- day = to_u32bit(params[2]);
+ m_year = to_u32bit(params[0]);
+ m_month = to_u32bit(params[1]);
+ m_day = to_u32bit(params[2]);
if(!passes_sanity_check())
throw Invalid_Argument("Invalid time specification " + time_str);
@@ -124,7 +124,7 @@ void EAC_Time::set_to(const std::string& time_str)
*/
void EAC_Time::encode_into(DER_Encoder& der) const
{
- der.add_object(tag, APPLICATION,
+ der.add_object(m_tag, APPLICATION,
encoded_eac_time());
}
@@ -136,7 +136,7 @@ std::string EAC_Time::as_string() const
if(time_is_set() == false)
throw Invalid_State("EAC_Time::as_string: No time set");
- return std::to_string(year * 10000 + month * 100 + day);
+ return std::to_string(m_year * 10000 + m_month * 100 + m_day);
}
/*
@@ -144,7 +144,7 @@ std::string EAC_Time::as_string() const
*/
bool EAC_Time::time_is_set() const
{
- return (year != 0);
+ return (m_year != 0);
}
/*
@@ -158,9 +158,9 @@ std::string EAC_Time::readable_string() const
// desired format: "%04d/%02d/%02d"
std::stringstream output;
output << std::setfill('0')
- << std::setw(4) << year << "/"
- << std::setw(2) << month << "/"
- << std::setw(2) << day;
+ << std::setw(4) << m_year << "/"
+ << std::setw(2) << m_month << "/"
+ << std::setw(2) << m_day;
return output.str();
}
@@ -169,11 +169,11 @@ std::string EAC_Time::readable_string() const
*/
bool EAC_Time::passes_sanity_check() const
{
- if(year < 2000 || year > 2099)
+ if(m_year < 2000 || m_year > 2099)
return false;
- if(month == 0 || month > 12)
+ if(m_month == 0 || m_month > 12)
return false;
- if(day == 0 || day > 31)
+ if(m_day == 0 || m_day > 31)
return false;
return true;
@@ -184,17 +184,17 @@ bool EAC_Time::passes_sanity_check() const
*/
void EAC_Time::add_years(u32bit years)
{
- year += years;
+ m_year += years;
}
void EAC_Time::add_months(u32bit months)
{
- year += months/12;
- month += months % 12;
- if(month > 12)
+ m_year += months/12;
+ m_month += months % 12;
+ if(m_month > 12)
{
- year += 1;
- month -= 12;
+ m_year += 1;
+ m_month -= 12;
}
}
@@ -208,12 +208,12 @@ s32bit EAC_Time::cmp(const EAC_Time& other) const
const s32bit EARLIER = -1, LATER = 1, SAME_TIME = 0;
- if(year < other.year) return EARLIER;
- if(year > other.year) return LATER;
- if(month < other.month) return EARLIER;
- if(month > other.month) return LATER;
- if(day < other.day) return EARLIER;
- if(day > other.day) return LATER;
+ if(m_year < other.m_year) return EARLIER;
+ if(m_year > other.m_year) return LATER;
+ if(m_month < other.m_month) return EARLIER;
+ if(m_month > other.m_month) return LATER;
+ if(m_day < other.m_day) return EARLIER;
+ if(m_day > other.m_day) return LATER;
return SAME_TIME;
}
@@ -258,7 +258,7 @@ void EAC_Time::decode_from(BER_Decoder& source)
{
BER_Object obj = source.get_next_object();
- if(obj.type_tag != this->tag)
+ if(obj.type_tag != m_tag)
throw BER_Decoding_Error("Tag mismatch when decoding");
if(obj.value.size() != 6)
@@ -271,9 +271,9 @@ void EAC_Time::decode_from(BER_Decoder& source)
u32bit tmp_year = dec_two_digit(obj.value[0], obj.value[1]);
u32bit tmp_mon = dec_two_digit(obj.value[2], obj.value[3]);
u32bit tmp_day = dec_two_digit(obj.value[4], obj.value[5]);
- year = tmp_year + 2000;
- month = tmp_mon;
- day = tmp_day;
+ m_year = tmp_year + 2000;
+ m_month = tmp_mon;
+ m_day = tmp_day;
}
catch (Invalid_Argument)
{
@@ -288,9 +288,9 @@ void EAC_Time::decode_from(BER_Decoder& source)
std::vector<byte> EAC_Time::encoded_eac_time() const
{
std::vector<byte> result;
- result += enc_two_digit(year);
- result += enc_two_digit(month);
- result += enc_two_digit(day);
+ result += enc_two_digit(m_year);
+ result += enc_two_digit(m_month);
+ result += enc_two_digit(m_day);
return result;
}
diff --git a/src/lib/cert/cvc/cvc_ado.cpp b/src/lib/cert/cvc/cvc_ado.cpp
index 21a345808..f803c6bf3 100644
--- a/src/lib/cert/cvc/cvc_ado.cpp
+++ b/src/lib/cert/cvc/cvc_ado.cpp
@@ -27,7 +27,7 @@ EAC1_1_ADO::EAC1_1_ADO(const std::string& in)
void EAC1_1_ADO::force_decode()
{
std::vector<byte> inner_cert;
- BER_Decoder(tbs_bits)
+ BER_Decoder(m_tbs_bits)
.start_cons(ASN1_Tag(33))
.raw_bytes(inner_cert)
.end_cons()
@@ -42,7 +42,7 @@ void EAC1_1_ADO::force_decode()
DataSource_Memory req_source(req_bits);
m_req = EAC1_1_Req(req_source);
- sig_algo = m_req.sig_algo;
+ m_sig_algo = m_req.m_sig_algo;
}
std::vector<byte> EAC1_1_ADO::make_signed(PK_Signer& signer,
@@ -101,7 +101,7 @@ void EAC1_1_ADO::encode(Pipe& out, X509_Encoding encoding) const
out.write(DER_Encoder()
.start_cons(ASN1_Tag(7), APPLICATION)
- .raw_bytes(tbs_bits)
+ .raw_bytes(m_tbs_bits)
.encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
.end_cons()
.get_contents());
@@ -109,7 +109,7 @@ void EAC1_1_ADO::encode(Pipe& out, X509_Encoding encoding) const
std::vector<byte> EAC1_1_ADO::tbs_data() const
{
- return tbs_bits;
+ return m_tbs_bits;
}
bool EAC1_1_ADO::operator==(EAC1_1_ADO const& rhs) const
diff --git a/src/lib/cert/cvc/cvc_cert.cpp b/src/lib/cert/cvc/cvc_cert.cpp
index cf6bc409a..280a8acda 100644
--- a/src/lib/cert/cvc/cvc_cert.cpp
+++ b/src/lib/cert/cvc/cvc_cert.cpp
@@ -36,7 +36,7 @@ void EAC1_1_CVC::force_decode()
std::vector<byte> enc_pk;
std::vector<byte> enc_chat_val;
size_t cpi;
- BER_Decoder tbs_cert(tbs_bits);
+ BER_Decoder tbs_cert(m_tbs_bits);
tbs_cert.decode(cpi, ASN1_Tag(41), APPLICATION)
.decode(m_car)
.start_cons(ASN1_Tag(73))
@@ -57,11 +57,11 @@ void EAC1_1_CVC::force_decode()
if(cpi != 0)
throw Decoding_Error("EAC1_1 certificate's cpi was not 0");
- m_pk = decode_eac1_1_key(enc_pk, sig_algo);
+ m_pk = decode_eac1_1_key(enc_pk, m_sig_algo);
m_chat_val = enc_chat_val[0];
- self_signed = (m_car.iso_8859() == m_chr.iso_8859());
+ m_self_signed = (m_car.iso_8859() == m_chr.iso_8859());
}
/*
@@ -70,7 +70,7 @@ void EAC1_1_CVC::force_decode()
EAC1_1_CVC::EAC1_1_CVC(DataSource& in)
{
init(in);
- self_signed = false;
+ m_self_signed = false;
do_decode();
}
@@ -78,7 +78,7 @@ EAC1_1_CVC::EAC1_1_CVC(const std::string& in)
{
DataSource_Stream stream(in, true);
init(stream);
- self_signed = false;
+ m_self_signed = false;
do_decode();
}
diff --git a/src/lib/cert/cvc/cvc_gen_cert.h b/src/lib/cert/cvc/cvc_gen_cert.h
index 6bdf116f3..2c3bca73d 100644
--- a/src/lib/cert/cvc/cvc_gen_cert.h
+++ b/src/lib/cert/cvc/cvc_gen_cert.h
@@ -85,7 +85,7 @@ class EAC1_1_gen_CVC : public EAC1_1_obj<Derived> // CRTP continuation from EAC1
protected:
ECDSA_PublicKey* m_pk;
ASN1_Chr m_chr;
- bool self_signed;
+ bool m_self_signed;
static void decode_info(DataSource& source,
std::vector<byte> & res_tbs_bits,
@@ -100,7 +100,7 @@ template<typename Derived> ASN1_Chr EAC1_1_gen_CVC<Derived>::get_chr() const
template<typename Derived> bool EAC1_1_gen_CVC<Derived>::is_self_signed() const
{
- return self_signed;
+ return m_self_signed;
}
template<typename Derived>
@@ -135,7 +135,7 @@ template<typename Derived> std::vector<byte> EAC1_1_gen_CVC<Derived>::build_cert
template<typename Derived> std::vector<byte> EAC1_1_gen_CVC<Derived>::tbs_data() const
{
- return build_cert_body(EAC1_1_obj<Derived>::tbs_bits);
+ return build_cert_body(EAC1_1_obj<Derived>::m_tbs_bits);
}
template<typename Derived> void EAC1_1_gen_CVC<Derived>::encode(Pipe& out, X509_Encoding encoding) const
@@ -144,7 +144,7 @@ template<typename Derived> void EAC1_1_gen_CVC<Derived>::encode(Pipe& out, X509_
std::vector<byte> der = DER_Encoder()
.start_cons(ASN1_Tag(33), APPLICATION)
.start_cons(ASN1_Tag(78), APPLICATION)
- .raw_bytes(EAC1_1_obj<Derived>::tbs_bits)
+ .raw_bytes(EAC1_1_obj<Derived>::m_tbs_bits)
.end_cons()
.encode(concat_sig, OCTET_STRING, ASN1_Tag(55), APPLICATION)
.end_cons()
diff --git a/src/lib/cert/cvc/cvc_req.cpp b/src/lib/cert/cvc/cvc_req.cpp
index e142a5ac6..1cb6b50ac 100644
--- a/src/lib/cert/cvc/cvc_req.cpp
+++ b/src/lib/cert/cvc/cvc_req.cpp
@@ -20,7 +20,7 @@ bool EAC1_1_Req::operator==(EAC1_1_Req const& rhs) const
void EAC1_1_Req::force_decode()
{
std::vector<byte> enc_pk;
- BER_Decoder tbs_cert(tbs_bits);
+ BER_Decoder tbs_cert(m_tbs_bits);
size_t cpi;
tbs_cert.decode(cpi, ASN1_Tag(41), APPLICATION)
.start_cons(ASN1_Tag(73))
@@ -32,13 +32,13 @@ void EAC1_1_Req::force_decode()
if(cpi != 0)
throw Decoding_Error("EAC1_1 requests cpi was not 0");
- m_pk = decode_eac1_1_key(enc_pk, sig_algo);
+ m_pk = decode_eac1_1_key(enc_pk, m_sig_algo);
}
EAC1_1_Req::EAC1_1_Req(DataSource& in)
{
init(in);
- self_signed = true;
+ m_self_signed = true;
do_decode();
}
@@ -46,7 +46,7 @@ EAC1_1_Req::EAC1_1_Req(const std::string& in)
{
DataSource_Stream stream(in, true);
init(stream);
- self_signed = true;
+ m_self_signed = true;
do_decode();
}
diff --git a/src/lib/cert/cvc/cvc_self.h b/src/lib/cert/cvc/cvc_self.h
index 005703636..d56e96c40 100644
--- a/src/lib/cert/cvc/cvc_self.h
+++ b/src/lib/cert/cvc/cvc_self.h
@@ -24,11 +24,22 @@ class BOTAN_DLL EAC1_1_CVC_Options
{
public:
+ // public member variable:
ASN1_Car car;
+
+ // public member variable:
ASN1_Chr chr;
+
+ // public member variable:
byte holder_auth_templ;
+
+ // public member variable:
ASN1_Ced ced;
+
+ // public member variable:
ASN1_Cex cex;
+
+ // public member variable:
std::string hash_alg;
};
diff --git a/src/lib/cert/cvc/eac_asn_obj.h b/src/lib/cert/cvc/eac_asn_obj.h
index e102c65fb..b4dcb6342 100644
--- a/src/lib/cert/cvc/eac_asn_obj.h
+++ b/src/lib/cert/cvc/eac_asn_obj.h
@@ -74,19 +74,19 @@ class BOTAN_DLL EAC_Time : public ASN1_Object
* Get the year value of this objects.
* @return year value
*/
- u32bit get_year() const { return year; }
+ u32bit get_year() const { return m_year; }
/**
* Get the month value of this objects.
* @return month value
*/
- u32bit get_month() const { return month; }
+ u32bit get_month() const { return m_month; }
/**
* Get the day value of this objects.
* @return day value
*/
- u32bit get_day() const { return day; }
+ u32bit get_day() const { return m_day; }
EAC_Time(const std::chrono::system_clock::time_point& time,
ASN1_Tag tag = ASN1_Tag(0));
@@ -101,8 +101,8 @@ class BOTAN_DLL EAC_Time : public ASN1_Object
private:
std::vector<byte> encoded_eac_time() const;
bool passes_sanity_check() const;
- u32bit year, month, day;
- ASN1_Tag tag;
+ u32bit m_year, m_month, m_day;
+ ASN1_Tag m_tag;
};
/**
@@ -188,8 +188,8 @@ class BOTAN_DLL ASN1_EAC_String: public ASN1_Object
protected:
bool sanity_check() const;
private:
- std::string iso_8859_str;
- ASN1_Tag tag;
+ std::string m_iso_8859_str;
+ ASN1_Tag m_tag;
};
/**
diff --git a/src/lib/cert/cvc/eac_obj.h b/src/lib/cert/cvc/eac_obj.h
index b1e353ddf..a6e676076 100644
--- a/src/lib/cert/cvc/eac_obj.h
+++ b/src/lib/cert/cvc/eac_obj.h
@@ -39,11 +39,11 @@ class EAC1_1_obj : public EAC_Signed_Object
{
try
{
- Derived::decode_info(in, tbs_bits, m_sig);
+ Derived::decode_info(in, m_tbs_bits, m_sig);
}
catch(Decoding_Error)
{
- throw Decoding_Error(PEM_label_pref + " decoding failed");
+ throw Decoding_Error(m_PEM_label_pref + " decoding failed");
}
}
diff --git a/src/lib/cert/cvc/signed_obj.cpp b/src/lib/cert/cvc/signed_obj.cpp
index 4a0f12008..1e3849663 100644
--- a/src/lib/cert/cvc/signed_obj.cpp
+++ b/src/lib/cert/cvc/signed_obj.cpp
@@ -41,7 +41,7 @@ std::string EAC_Signed_Object::PEM_encode() const
*/
AlgorithmIdentifier EAC_Signed_Object::signature_algorithm() const
{
- return sig_algo;
+ return m_sig_algo;
}
bool EAC_Signed_Object::check_signature(Public_Key& pub_key,
@@ -50,7 +50,7 @@ bool EAC_Signed_Object::check_signature(Public_Key& pub_key,
try
{
std::vector<std::string> sig_info =
- split_on(OIDS::lookup(sig_algo.oid), '/');
+ split_on(OIDS::lookup(m_sig_algo.oid), '/');
if(sig_info.size() != 2 || sig_info[0] != pub_key.algo_name())
{
@@ -83,12 +83,12 @@ void EAC_Signed_Object::do_decode()
catch(Decoding_Error& e)
{
const std::string what = e.what();
- throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
+ throw Decoding_Error(m_PEM_label_pref + " decoding failed (" + what + ")");
}
catch(Invalid_Argument& e)
{
const std::string what = e.what();
- throw Decoding_Error(PEM_label_pref + " decoding failed (" + what + ")");
+ throw Decoding_Error(m_PEM_label_pref + " decoding failed (" + what + ")");
}
}
diff --git a/src/lib/cert/cvc/signed_obj.h b/src/lib/cert/cvc/signed_obj.h
index aa6ace4b7..b3fe20f31 100644
--- a/src/lib/cert/cvc/signed_obj.h
+++ b/src/lib/cert/cvc/signed_obj.h
@@ -82,10 +82,10 @@ class BOTAN_DLL EAC_Signed_Object
void do_decode();
EAC_Signed_Object() {}
- AlgorithmIdentifier sig_algo;
- std::vector<byte> tbs_bits;
- std::string PEM_label_pref;
- std::vector<std::string> PEM_labels_allowed;
+ AlgorithmIdentifier m_sig_algo;
+ std::vector<byte> m_tbs_bits;
+ std::string m_PEM_label_pref;
+ std::vector<std::string> m_PEM_labels_allowed;
private:
virtual void force_decode() = 0;
};