diff options
Diffstat (limited to 'src/lib/asn1')
-rw-r--r-- | src/lib/asn1/alg_id.cpp | 22 | ||||
-rw-r--r-- | src/lib/asn1/asn1_attribute.cpp | 14 | ||||
-rw-r--r-- | src/lib/asn1/asn1_obj.h | 2 | ||||
-rw-r--r-- | src/lib/asn1/asn1_str.cpp | 12 | ||||
-rw-r--r-- | src/lib/asn1/asn1_str.h | 2 | ||||
-rw-r--r-- | src/lib/asn1/asn1_time.h | 2 | ||||
-rw-r--r-- | src/lib/asn1/ber_dec.h | 6 | ||||
-rw-r--r-- | src/lib/asn1/oid_lookup/oids.cpp | 4 | ||||
-rw-r--r-- | src/lib/asn1/x509_dn.h | 4 |
9 files changed, 24 insertions, 44 deletions
diff --git a/src/lib/asn1/alg_id.cpp b/src/lib/asn1/alg_id.cpp index 7d476a225..75ea78c18 100644 --- a/src/lib/asn1/alg_id.cpp +++ b/src/lib/asn1/alg_id.cpp @@ -16,32 +16,24 @@ namespace Botan { * Create an AlgorithmIdentifier */ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, - const std::vector<byte>& param) - { - oid = alg_id; - parameters = param; - } + const std::vector<byte>& param) : oid(alg_id), parameters(param) + {} /* * Create an AlgorithmIdentifier */ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, - const std::vector<byte>& param) - { - oid = OIDS::lookup(alg_id); - parameters = param; - } + const std::vector<byte>& param) : oid(OIDS::lookup(alg_id)), parameters(param) + {} /* * Create an AlgorithmIdentifier */ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, - Encoding_Option option) + Encoding_Option option) : oid(alg_id), parameters() { const byte DER_NULL[] = { 0x05, 0x00 }; - oid = alg_id; - if(option == USE_NULL_PARAM) parameters += std::pair<const byte*, size_t>(DER_NULL, sizeof(DER_NULL)); } @@ -50,12 +42,10 @@ AlgorithmIdentifier::AlgorithmIdentifier(const OID& alg_id, * Create an AlgorithmIdentifier */ AlgorithmIdentifier::AlgorithmIdentifier(const std::string& alg_id, - Encoding_Option option) + Encoding_Option option) : oid(OIDS::lookup(alg_id)), parameters() { const byte DER_NULL[] = { 0x05, 0x00 }; - oid = OIDS::lookup(alg_id); - if(option == USE_NULL_PARAM) parameters += std::pair<const byte*, size_t>(DER_NULL, sizeof(DER_NULL)); } diff --git a/src/lib/asn1/asn1_attribute.cpp b/src/lib/asn1/asn1_attribute.cpp index 406a57d9a..bd7e5bf11 100644 --- a/src/lib/asn1/asn1_attribute.cpp +++ b/src/lib/asn1/asn1_attribute.cpp @@ -15,21 +15,15 @@ namespace Botan { /* * Create an Attribute */ -Attribute::Attribute(const OID& attr_oid, const std::vector<byte>& attr_value) - { - oid = attr_oid; - parameters = attr_value; - } +Attribute::Attribute(const OID& attr_oid, const std::vector<byte>& attr_value) : oid(attr_oid), parameters(attr_value) + {} /* * Create an Attribute */ Attribute::Attribute(const std::string& attr_oid, - const std::vector<byte>& attr_value) - { - oid = OIDS::lookup(attr_oid); - parameters = attr_value; - } + const std::vector<byte>& attr_value) : oid(OIDS::lookup(attr_oid)), parameters(attr_value) + {} /* * DER encode a Attribute diff --git a/src/lib/asn1/asn1_obj.h b/src/lib/asn1/asn1_obj.h index 2bd2b1ed5..3e119dc01 100644 --- a/src/lib/asn1/asn1_obj.h +++ b/src/lib/asn1/asn1_obj.h @@ -114,7 +114,7 @@ bool maybe_BER(DataSource& src); */ struct BOTAN_DLL BER_Decoding_Error : public Decoding_Error { - BER_Decoding_Error(const std::string&); + explicit BER_Decoding_Error(const std::string&); }; /** diff --git a/src/lib/asn1/asn1_str.cpp b/src/lib/asn1/asn1_str.cpp index 809448888..c378d5dfe 100644 --- a/src/lib/asn1/asn1_str.cpp +++ b/src/lib/asn1/asn1_str.cpp @@ -62,9 +62,8 @@ ASN1_Tag choose_encoding(const std::string& str, /* * Create an ASN1_String */ -ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : m_tag(t) +ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : m_iso_8859_str(Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET)), m_tag(t) { - m_iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET); if(m_tag == DIRECTORY_STRING) m_tag = choose_encoding(m_iso_8859_str, "latin1"); @@ -83,11 +82,8 @@ ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : m_tag(t) /* * Create an ASN1_String */ -ASN1_String::ASN1_String(const std::string& str) - { - m_iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET); - m_tag = choose_encoding(m_iso_8859_str, "latin1"); - } +ASN1_String::ASN1_String(const std::string& str) : m_iso_8859_str(Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET)), m_tag(choose_encoding(m_iso_8859_str, "latin1")) + {} /* * Return this string in ISO 8859-1 encoding @@ -141,7 +137,7 @@ void ASN1_String::decode_from(BER_Decoder& source) charset_is = LATIN1_CHARSET; *this = ASN1_String( - Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET), + Charset::transcode(ASN1::to_string(obj), LOCAL_CHARSET, charset_is), obj.type_tag); } diff --git a/src/lib/asn1/asn1_str.h b/src/lib/asn1/asn1_str.h index 269b821b8..1d75ec519 100644 --- a/src/lib/asn1/asn1_str.h +++ b/src/lib/asn1/asn1_str.h @@ -26,7 +26,7 @@ class BOTAN_DLL ASN1_String final : public ASN1_Object ASN1_Tag tagging() const; - ASN1_String(const std::string& = ""); + explicit ASN1_String(const std::string& = ""); ASN1_String(const std::string&, ASN1_Tag); private: std::string m_iso_8859_str; diff --git a/src/lib/asn1/asn1_time.h b/src/lib/asn1/asn1_time.h index 269cc7983..ba5b84838 100644 --- a/src/lib/asn1/asn1_time.h +++ b/src/lib/asn1/asn1_time.h @@ -41,7 +41,7 @@ class BOTAN_DLL X509_Time final : public ASN1_Object X509_Time() {} /// Create a X509_Time from a time point - X509_Time(const std::chrono::system_clock::time_point& time); + explicit X509_Time(const std::chrono::system_clock::time_point& time); /// Create an X509_Time from string X509_Time(const std::string& t_spec, ASN1_Tag tag); diff --git a/src/lib/asn1/ber_dec.h b/src/lib/asn1/ber_dec.h index b755251c5..8a5c9ca45 100644 --- a/src/lib/asn1/ber_dec.h +++ b/src/lib/asn1/ber_dec.h @@ -157,13 +157,13 @@ class BOTAN_DLL BER_Decoder BER_Decoder& operator=(const BER_Decoder&) = delete; - BER_Decoder(DataSource&); + explicit BER_Decoder(DataSource&); BER_Decoder(const byte[], size_t); - BER_Decoder(const secure_vector<byte>&); + explicit BER_Decoder(const secure_vector<byte>&); - BER_Decoder(const std::vector<byte>& vec); + explicit BER_Decoder(const std::vector<byte>& vec); BER_Decoder(const BER_Decoder&); ~BER_Decoder(); diff --git a/src/lib/asn1/oid_lookup/oids.cpp b/src/lib/asn1/oid_lookup/oids.cpp index 0d1ab58ff..cdb863494 100644 --- a/src/lib/asn1/oid_lookup/oids.cpp +++ b/src/lib/asn1/oid_lookup/oids.cpp @@ -125,8 +125,8 @@ void OID_Map::read_cfg(std::istream& cfg, const std::string& source) const std::string oid = clean_ws(s.substr(0, eq)); const std::string name = clean_ws(s.substr(eq + 1, std::string::npos)); - m_str2oid.insert(std::make_pair(name, oid)); - m_oid2str.insert(std::make_pair(oid, name)); + m_str2oid.insert(std::make_pair(name, OID(oid))); + m_oid2str.insert(std::make_pair(OID(oid), name)); } } diff --git a/src/lib/asn1/x509_dn.h b/src/lib/asn1/x509_dn.h index a86cc6417..12553a1a0 100644 --- a/src/lib/asn1/x509_dn.h +++ b/src/lib/asn1/x509_dn.h @@ -38,8 +38,8 @@ class BOTAN_DLL X509_DN final : public ASN1_Object std::vector<byte> get_bits() const; X509_DN(); - X509_DN(const std::multimap<OID, std::string>&); - X509_DN(const std::multimap<std::string, std::string>&); + explicit X509_DN(const std::multimap<OID, std::string>&); + explicit X509_DN(const std::multimap<std::string, std::string>&); private: std::multimap<OID, ASN1_String> m_dn_info; std::vector<byte> m_dn_bits; |