aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/asn1/asn1_oid.cpp4
-rw-r--r--src/lib/asn1/oids.cpp2
-rw-r--r--src/lib/ffi/ffi.cpp2
-rw-r--r--src/lib/ffi/ffi_util.h2
-rw-r--r--src/lib/misc/roughtime/roughtime.cpp2
-rw-r--r--src/lib/misc/srp6/srp6.cpp2
-rw-r--r--src/lib/misc/zfec/zfec.cpp6
-rw-r--r--src/lib/misc/zfec/zfec.h6
-rw-r--r--src/lib/passhash/argon2fmt/argon2fmt.cpp2
-rw-r--r--src/lib/pk_pad/eme_oaep/oaep.cpp2
-rw-r--r--src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp2
-rw-r--r--src/lib/pk_pad/emsa.cpp3
-rw-r--r--src/lib/pk_pad/padding.cpp4
-rw-r--r--src/lib/pk_pad/padding.h5
-rw-r--r--src/lib/prov/pkcs11/p11_module.cpp2
-rw-r--r--src/lib/prov/pkcs11/p11_types.h2
-rw-r--r--src/lib/psk_db/psk_db.cpp2
-rw-r--r--src/lib/psk_db/psk_db_sql.cpp2
-rw-r--r--src/lib/pubkey/blinding.cpp4
-rw-r--r--src/lib/pubkey/ec_h2c/ec_h2c.cpp2
-rw-r--r--src/lib/pubkey/mce/mceliece.h9
-rw-r--r--src/lib/pubkey/mce/mceliece_key.cpp5
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.cpp19
-rw-r--r--src/lib/pubkey/mce/polyn_gf2m.h15
-rw-r--r--src/lib/pubkey/pk_algs.cpp2
-rw-r--r--src/lib/pubkey/pk_algs.h2
-rw-r--r--src/lib/pubkey/pkcs8.cpp8
-rw-r--r--src/lib/pubkey/pubkey.cpp2
-rw-r--r--src/lib/pubkey/pubkey.h18
-rw-r--r--src/lib/tls/msg_cert_status.cpp4
-rw-r--r--src/lib/tls/msg_server_hello.cpp2
-rw-r--r--src/lib/tls/sessions_sql/tls_session_manager_sql.cpp2
-rw-r--r--src/lib/tls/tls_messages.h6
-rw-r--r--src/lib/tls/tls_policy.cpp1
-rw-r--r--src/lib/tls/tls_record.cpp6
-rw-r--r--src/lib/tls/tls_record.h2
-rw-r--r--src/lib/tls/tls_server.cpp2
-rw-r--r--src/lib/tls/tls_text_policy.cpp4
-rw-r--r--src/lib/utils/http_util/http_util.cpp6
-rw-r--r--src/lib/utils/http_util/http_util.h2
-rw-r--r--src/lib/utils/os_utils.cpp2
-rw-r--r--src/lib/utils/os_utils.h2
-rw-r--r--src/lib/utils/read_cfg.cpp2
-rw-r--r--src/lib/utils/thread_utils/thread_pool.cpp2
-rw-r--r--src/lib/utils/thread_utils/thread_pool.h2
-rw-r--r--src/lib/x509/certstor.cpp2
-rw-r--r--src/lib/x509/certstor_flatfile/certstor_flatfile.cpp2
-rw-r--r--src/lib/x509/certstor_sql/certstor_sql.cpp10
-rw-r--r--src/lib/x509/pkcs10.cpp2
-rw-r--r--src/lib/x509/x509_crl.cpp4
-rw-r--r--src/lib/x509/x509_ext.cpp6
-rw-r--r--src/lib/x509/x509_obj.cpp2
-rw-r--r--src/lib/x509/x509cert.cpp6
-rw-r--r--src/lib/x509/x509path.cpp4
-rw-r--r--src/lib/x509/x509self.cpp4
55 files changed, 114 insertions, 113 deletions
diff --git a/src/lib/asn1/asn1_oid.cpp b/src/lib/asn1/asn1_oid.cpp
index a184f6698..460882777 100644
--- a/src/lib/asn1/asn1_oid.cpp
+++ b/src/lib/asn1/asn1_oid.cpp
@@ -63,7 +63,7 @@ OID OID::from_string(const std::string& str)
if(str.empty())
throw Invalid_Argument("OID::from_string argument must be non-empty");
- const OID o = OIDS::str2oid_or_empty(str);
+ OID o = OIDS::str2oid_or_empty(str);
if(o.has_value())
return o;
@@ -108,7 +108,7 @@ std::string OID::to_string() const
std::string OID::to_formatted_string() const
{
- const std::string s = OIDS::oid2str_or_empty(*this);
+ std::string s = OIDS::oid2str_or_empty(*this);
if(!s.empty())
return s;
return this->to_string();
diff --git a/src/lib/asn1/oids.cpp b/src/lib/asn1/oids.cpp
index 3ebe5c063..51838375d 100644
--- a/src/lib/asn1/oids.cpp
+++ b/src/lib/asn1/oids.cpp
@@ -114,7 +114,7 @@ OID OIDS::str2oid_or_empty(const std::string& name)
std::string OIDS::oid2str_or_throw(const OID& oid)
{
- const std::string s = OIDS::oid2str_or_empty(oid);
+ std::string s = OIDS::oid2str_or_empty(oid);
if(s.empty())
throw Lookup_Error("No name associated with OID " + oid.to_string());
return s;
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp
index 1a6ce5e55..9f21533c6 100644
--- a/src/lib/ffi/ffi.cpp
+++ b/src/lib/ffi/ffi.cpp
@@ -89,7 +89,7 @@ int ffi_map_error_type(Botan::ErrorType err)
}
-int ffi_guard_thunk(const char* func_name, std::function<int ()> thunk)
+int ffi_guard_thunk(const char* func_name, const std::function<int ()>& thunk)
{
g_last_exception_what.clear();
diff --git a/src/lib/ffi/ffi_util.h b/src/lib/ffi/ffi_util.h
index be35cb045..32851e9fc 100644
--- a/src/lib/ffi/ffi_util.h
+++ b/src/lib/ffi/ffi_util.h
@@ -75,7 +75,7 @@ T& safe_get(botan_struct<T,M>* p)
throw FFI_Error("Invalid object pointer", BOTAN_FFI_ERROR_INVALID_OBJECT);
}
-int ffi_guard_thunk(const char* func_name, std::function<int ()>);
+int ffi_guard_thunk(const char* func_name, const std::function<int ()>& thunk);
template<typename T, uint32_t M, typename F>
int apply_fn(botan_struct<T, M>* o, const char* func_name, F func)
diff --git a/src/lib/misc/roughtime/roughtime.cpp b/src/lib/misc/roughtime/roughtime.cpp
index 32453a9ad..21cdda2a2 100644
--- a/src/lib/misc/roughtime/roughtime.cpp
+++ b/src/lib/misc/roughtime/roughtime.cpp
@@ -457,7 +457,7 @@ std::vector<Server_Information> servers_from_str(const std::string& str)
throw Decoding_Error(ERROR_MESSAGE);
}
- servers.push_back({name, publicKey, std::move(addresses)});
+ servers.push_back({name, publicKey, addresses});
}
return servers;
}
diff --git a/src/lib/misc/srp6/srp6.cpp b/src/lib/misc/srp6/srp6.cpp
index 6a5e5f036..903371bb8 100644
--- a/src/lib/misc/srp6/srp6.cpp
+++ b/src/lib/misc/srp6/srp6.cpp
@@ -54,7 +54,7 @@ std::string srp6_group_identifier(const BigInt& N, const BigInt& g)
*/
try
{
- const std::string group_name = "modp/srp/" + std::to_string(N.bits());
+ std::string group_name = "modp/srp/" + std::to_string(N.bits());
DL_Group group(group_name);
diff --git a/src/lib/misc/zfec/zfec.cpp b/src/lib/misc/zfec/zfec.cpp
index 139ecb675..9e1a623a2 100644
--- a/src/lib/misc/zfec/zfec.cpp
+++ b/src/lib/misc/zfec/zfec.cpp
@@ -450,7 +450,7 @@ ZFEC::ZFEC(size_t K, size_t N) :
*/
void ZFEC::encode(
const uint8_t input[], size_t size,
- output_cb_t output_cb)
+ const output_cb_t& output_cb)
const
{
if(size % m_K != 0)
@@ -468,7 +468,7 @@ void ZFEC::encode(
void ZFEC::encode_shares(
const std::vector<const uint8_t*>& shares,
size_t share_size,
- output_cb_t output_cb)
+ const output_cb_t& output_cb)
const
{
if(shares.size() != m_K)
@@ -500,7 +500,7 @@ void ZFEC::encode_shares(
void ZFEC::decode_shares(
const std::map<size_t, const uint8_t*>& shares,
size_t share_size,
- output_cb_t output_cb) const
+ const output_cb_t& output_cb) const
{
/*
Todo:
diff --git a/src/lib/misc/zfec/zfec.h b/src/lib/misc/zfec/zfec.h
index 09ccb55c7..425354b24 100644
--- a/src/lib/misc/zfec/zfec.h
+++ b/src/lib/misc/zfec/zfec.h
@@ -51,7 +51,7 @@ class BOTAN_PUBLIC_API(3,0) ZFEC
*/
void encode(
const uint8_t input[], size_t size,
- output_cb_t output_cb)
+ const output_cb_t& output_cb)
const;
/**
@@ -62,7 +62,7 @@ class BOTAN_PUBLIC_API(3,0) ZFEC
void encode_shares(
const std::vector<const uint8_t*>& shares,
size_t share_size,
- output_cb_t output_cb)
+ const output_cb_t& output_cb)
const;
/**
@@ -73,7 +73,7 @@ class BOTAN_PUBLIC_API(3,0) ZFEC
void decode_shares(
const std::map<size_t, const uint8_t*>& shares,
size_t share_size,
- output_cb_t output_cb)
+ const output_cb_t& output_cb)
const;
private:
diff --git a/src/lib/passhash/argon2fmt/argon2fmt.cpp b/src/lib/passhash/argon2fmt/argon2fmt.cpp
index cfd3d4cbd..acad2f754 100644
--- a/src/lib/passhash/argon2fmt/argon2fmt.cpp
+++ b/src/lib/passhash/argon2fmt/argon2fmt.cpp
@@ -99,7 +99,7 @@ bool argon2_check_pwhash(const char* password, size_t password_len,
size_t M = 0, t = 0, p = 0;
- for(auto param_str : params)
+ for(const auto& param_str : params)
{
const std::vector<std::string> param = split_on(param_str, '=');
diff --git a/src/lib/pk_pad/eme_oaep/oaep.cpp b/src/lib/pk_pad/eme_oaep/oaep.cpp
index 8fb85617a..eb7ec850d 100644
--- a/src/lib/pk_pad/eme_oaep/oaep.cpp
+++ b/src/lib/pk_pad/eme_oaep/oaep.cpp
@@ -131,7 +131,7 @@ oaep_find_delim(uint8_t& valid_mask,
delim_idx += 1;
valid_mask = (~bad_input_m).unpoisoned_value();
- const secure_vector<uint8_t> output = CT::copy_output(bad_input_m, input, input_len, delim_idx);
+ auto output = CT::copy_output(bad_input_m, input, input_len, delim_idx);
CT::unpoison(input, input_len);
diff --git a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
index cac71abc0..aea41423d 100644
--- a/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
+++ b/src/lib/pk_pad/eme_pkcs1/eme_pkcs.cpp
@@ -88,7 +88,7 @@ secure_vector<uint8_t> EME_PKCS1v15::unpad(uint8_t& valid_mask,
bad_input_m |= CT::Mask<uint8_t>(CT::Mask<size_t>::is_lt(delim_idx, 11));
valid_mask = (~bad_input_m).unpoisoned_value();
- const secure_vector<uint8_t> output = CT::copy_output(bad_input_m, in, inlen, delim_idx);
+ auto output = CT::copy_output(bad_input_m, in, inlen, delim_idx);
CT::unpoison(in, inlen);
diff --git a/src/lib/pk_pad/emsa.cpp b/src/lib/pk_pad/emsa.cpp
index b9695cc72..982c30a13 100644
--- a/src/lib/pk_pad/emsa.cpp
+++ b/src/lib/pk_pad/emsa.cpp
@@ -200,8 +200,7 @@ std::string hash_for_emsa(const std::string& algo_spec)
if(emsa_name.arg_count() > 0)
{
- const std::string pos_hash = emsa_name.arg(0);
- return pos_hash;
+ return emsa_name.arg(0);
}
// If we don't understand what this is return a safe default
diff --git a/src/lib/pk_pad/padding.cpp b/src/lib/pk_pad/padding.cpp
index bac3fcd7e..cb1e406ac 100644
--- a/src/lib/pk_pad/padding.cpp
+++ b/src/lib/pk_pad/padding.cpp
@@ -29,14 +29,14 @@ const std::map<const std::string, std::vector<std::string>> allowed_signature_pa
{ "RSA", {"EMSA4", "EMSA3"} },
};
-const std::vector<std::string> get_sig_paddings(const std::string algo)
+const std::vector<std::string> get_sig_paddings(const std::string& algo)
{
if(allowed_signature_paddings.count(algo) > 0)
return allowed_signature_paddings.at(algo);
return {};
}
-bool sig_algo_and_pad_ok(const std::string algo, const std::string padding)
+bool sig_algo_and_pad_ok(const std::string& algo, const std::string& padding)
{
std::vector<std::string> pads = get_sig_paddings(algo);
return std::find(pads.begin(), pads.end(), padding) != pads.end();
diff --git a/src/lib/pk_pad/padding.h b/src/lib/pk_pad/padding.h
index ed05ec381..349e1c0f8 100644
--- a/src/lib/pk_pad/padding.h
+++ b/src/lib/pk_pad/padding.h
@@ -20,7 +20,7 @@ namespace Botan {
* @param algo the algorithm for which to look up supported padding schemes
* @return a vector of supported padding schemes
*/
-BOTAN_TEST_API const std::vector<std::string> get_sig_paddings(const std::string algo);
+BOTAN_TEST_API const std::vector<std::string> get_sig_paddings(const std::string& algo);
/**
* Returns true iff the given padding scheme is valid for the given
@@ -29,7 +29,8 @@ BOTAN_TEST_API const std::vector<std::string> get_sig_paddings(const std::string
* @param algo the signature algorithm to be used
* @param padding the padding scheme to be used
*/
-bool sig_algo_and_pad_ok(const std::string algo, const std::string padding);
+bool sig_algo_and_pad_ok(const std::string& algo,
+ const std::string& padding);
}
diff --git a/src/lib/prov/pkcs11/p11_module.cpp b/src/lib/prov/pkcs11/p11_module.cpp
index 1d1e31c91..1b209bac3 100644
--- a/src/lib/prov/pkcs11/p11_module.cpp
+++ b/src/lib/prov/pkcs11/p11_module.cpp
@@ -13,8 +13,6 @@ namespace Botan {
namespace PKCS11 {
-Module::Module(Module&&) = default;
-
Module::Module(const std::string& file_path, C_InitializeArgs init_args)
: m_file_path(file_path)
{
diff --git a/src/lib/prov/pkcs11/p11_types.h b/src/lib/prov/pkcs11/p11_types.h
index bd445da3c..1a24ad4eb 100644
--- a/src/lib/prov/pkcs11/p11_types.h
+++ b/src/lib/prov/pkcs11/p11_types.h
@@ -35,7 +35,7 @@ class BOTAN_PUBLIC_API(2,0) Module final
*/
Module(const std::string& file_path, C_InitializeArgs init_args = { nullptr, nullptr, nullptr, nullptr, static_cast< CK_FLAGS >(Flag::OsLockingOk), nullptr });
- Module(Module&& other);
+ Module(Module&& other) noexcept = default;
Module& operator=(Module&& other) = delete;
// Dtor calls C_Finalize(). A copy could be deleted while the origin still exists
diff --git a/src/lib/psk_db/psk_db.cpp b/src/lib/psk_db/psk_db.cpp
index 21f3a099e..0597cca15 100644
--- a/src/lib/psk_db/psk_db.cpp
+++ b/src/lib/psk_db/psk_db.cpp
@@ -34,7 +34,7 @@ std::set<std::string> Encrypted_PSK_Database::list_names() const
std::set<std::string> names;
- for(std::string enc_name : encrypted_names)
+ for(const std::string& enc_name : encrypted_names)
{
try
{
diff --git a/src/lib/psk_db/psk_db_sql.cpp b/src/lib/psk_db/psk_db_sql.cpp
index 92dcb5f1d..8d63d3c49 100644
--- a/src/lib/psk_db/psk_db_sql.cpp
+++ b/src/lib/psk_db/psk_db_sql.cpp
@@ -13,7 +13,7 @@ Encrypted_PSK_Database_SQL::Encrypted_PSK_Database_SQL(const secure_vector<uint8
std::shared_ptr<SQL_Database> db,
const std::string& table_name) :
Encrypted_PSK_Database(master_key),
- m_db(db),
+ m_db(std::move(db)),
m_table_name(table_name)
{
m_db->create_table(
diff --git a/src/lib/pubkey/blinding.cpp b/src/lib/pubkey/blinding.cpp
index 4dba697b2..47a0ea0a4 100644
--- a/src/lib/pubkey/blinding.cpp
+++ b/src/lib/pubkey/blinding.cpp
@@ -15,8 +15,8 @@ Blinder::Blinder(const BigInt& modulus,
std::function<BigInt (const BigInt&)> inv) :
m_reducer(modulus),
m_rng(rng),
- m_fwd_fn(fwd),
- m_inv_fn(inv),
+ m_fwd_fn(std::move(fwd)),
+ m_inv_fn(std::move(inv)),
m_modulus_bits(modulus.bits()),
m_e{},
m_d{},
diff --git a/src/lib/pubkey/ec_h2c/ec_h2c.cpp b/src/lib/pubkey/ec_h2c/ec_h2c.cpp
index 4a1d69fdd..d2e79a316 100644
--- a/src/lib/pubkey/ec_h2c/ec_h2c.cpp
+++ b/src/lib/pubkey/ec_h2c/ec_h2c.cpp
@@ -107,7 +107,7 @@ hash_to_field(const EC_Group& group,
BigInt sswu_z(const EC_Group& group)
{
const BigInt& p = group.get_p();
- const OID oid = group.get_curve_oid();
+ const OID& oid = group.get_curve_oid();
if(oid == OID{1,2,840,10045,3,1,7}) // secp256r1
return p - 10;
diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h
index 3ac48aeb4..c7e0ab65e 100644
--- a/src/lib/pubkey/mce/mceliece.h
+++ b/src/lib/pubkey/mce/mceliece.h
@@ -98,10 +98,11 @@ class BOTAN_PUBLIC_API(2,0) McEliece_PrivateKey final : public virtual McEliece_
~McEliece_PrivateKey();
- McEliece_PrivateKey(const McEliece_PrivateKey&);
- McEliece_PrivateKey(McEliece_PrivateKey&&);
- McEliece_PrivateKey& operator=(const McEliece_PrivateKey&);
- McEliece_PrivateKey& operator=(McEliece_PrivateKey&&);
+ McEliece_PrivateKey(const McEliece_PrivateKey&) = default;
+ McEliece_PrivateKey& operator=(const McEliece_PrivateKey&) = default;
+
+ McEliece_PrivateKey(McEliece_PrivateKey&&) noexcept = default;
+ McEliece_PrivateKey& operator=(McEliece_PrivateKey&&) noexcept = default;
bool check_key(RandomNumberGenerator& rng, bool strong) const override;
diff --git a/src/lib/pubkey/mce/mceliece_key.cpp b/src/lib/pubkey/mce/mceliece_key.cpp
index 8c23bf659..22a9c62ad 100644
--- a/src/lib/pubkey/mce/mceliece_key.cpp
+++ b/src/lib/pubkey/mce/mceliece_key.cpp
@@ -23,11 +23,6 @@
namespace Botan {
-McEliece_PrivateKey::McEliece_PrivateKey(const McEliece_PrivateKey&) = default;
-McEliece_PrivateKey::McEliece_PrivateKey(McEliece_PrivateKey&&) = default;
-McEliece_PrivateKey& McEliece_PrivateKey::operator=(const McEliece_PrivateKey&) = default;
-McEliece_PrivateKey& McEliece_PrivateKey::operator=(McEliece_PrivateKey&&) = default;
-
McEliece_PrivateKey::McEliece_PrivateKey(polyn_gf2m const& goppa_polyn,
std::vector<uint32_t> const& parity_check_matrix_coeffs,
std::vector<polyn_gf2m> const& square_root_matrix,
diff --git a/src/lib/pubkey/mce/polyn_gf2m.cpp b/src/lib/pubkey/mce/polyn_gf2m.cpp
index 75381b36b..508c7c6e5 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.cpp
+++ b/src/lib/pubkey/mce/polyn_gf2m.cpp
@@ -94,10 +94,10 @@ polyn_gf2m::polyn_gf2m(polyn_gf2m const& other)
m_sp_field(other.m_sp_field)
{ }
-polyn_gf2m::polyn_gf2m(int d, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(int d, const std::shared_ptr<GF2m_Field>& sp_field)
:m_deg(-1),
coeff(d+1),
- m_sp_field(sp_field)
+ m_sp_field(std::move(sp_field))
{
}
@@ -123,7 +123,7 @@ void polyn_gf2m::realloc(uint32_t new_size)
this->coeff = secure_vector<gf2m>(new_size);
}
-polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field) :
+polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, const std::shared_ptr<GF2m_Field>& sp_field) :
m_deg(-1), m_sp_field(sp_field)
{
if(mem_len % sizeof(gf2m))
@@ -150,11 +150,11 @@ polyn_gf2m::polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2
}
-polyn_gf2m::polyn_gf2m( std::shared_ptr<GF2m_Field> sp_field) :
+polyn_gf2m::polyn_gf2m(const std::shared_ptr<GF2m_Field>& sp_field) :
m_deg(-1), coeff(1), m_sp_field(sp_field)
{}
-polyn_gf2m::polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, const std::shared_ptr<GF2m_Field>& sp_field)
:m_sp_field(sp_field)
{
uint32_t j, k, l;
@@ -235,7 +235,7 @@ int polyn_gf2m::get_degree() const
}
-static gf2m eval_aux(const gf2m * /*restrict*/ coeff, gf2m a, int d, std::shared_ptr<GF2m_Field> sp_field)
+static gf2m eval_aux(const gf2m * /*restrict*/ coeff, gf2m a, int d, const std::shared_ptr<GF2m_Field>& sp_field)
{
gf2m b;
b = coeff[d--];
@@ -636,7 +636,7 @@ std::pair<polyn_gf2m, polyn_gf2m> polyn_gf2m::eea_with_coefficients( const polyn
return std::make_pair(u1,r1); // coefficients u,v
}
-polyn_gf2m::polyn_gf2m(size_t t, RandomNumberGenerator& rng, std::shared_ptr<GF2m_Field> sp_field)
+polyn_gf2m::polyn_gf2m(size_t t, RandomNumberGenerator& rng, const std::shared_ptr<GF2m_Field>& sp_field)
:m_deg(static_cast<int>(t)),
coeff(t+1),
m_sp_field(sp_field)
@@ -751,8 +751,9 @@ std::vector<polyn_gf2m> syndrome_init(polyn_gf2m const& generator, std::vector<g
return result;
}
-polyn_gf2m::polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field )
- :m_sp_field(sp_field)
+polyn_gf2m::polyn_gf2m(const secure_vector<uint8_t>& encoded,
+ const std::shared_ptr<GF2m_Field>& sp_field) :
+ m_sp_field(sp_field)
{
if(encoded.size() % 2)
{
diff --git a/src/lib/pubkey/mce/polyn_gf2m.h b/src/lib/pubkey/mce/polyn_gf2m.h
index 5c8b3e75c..29ea8009f 100644
--- a/src/lib/pubkey/mce/polyn_gf2m.h
+++ b/src/lib/pubkey/mce/polyn_gf2m.h
@@ -30,33 +30,36 @@ class polyn_gf2m
/**
* create a zero polynomial:
*/
- explicit polyn_gf2m(std::shared_ptr<GF2m_Field> sp_field);
+ explicit polyn_gf2m(const std::shared_ptr<GF2m_Field>& sp_field);
polyn_gf2m() : m_deg(-1) {}
- polyn_gf2m(const secure_vector<uint8_t>& encoded, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(const secure_vector<uint8_t>& encoded,
+ const std::shared_ptr<GF2m_Field>& sp_field);
polyn_gf2m& operator=(const polyn_gf2m&) = default;
/**
* create zero polynomial with reservation of space for a degree d polynomial
*/
- polyn_gf2m(int d, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(int d, const std::shared_ptr<GF2m_Field>& sp_field);
polyn_gf2m(polyn_gf2m const& other);
/**
* random irreducible polynomial of degree t
*/
- polyn_gf2m(size_t t, RandomNumberGenerator& rng, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(size_t t, RandomNumberGenerator& rng,
+ const std::shared_ptr<GF2m_Field>& sp_field);
/** decode a polynomial from memory: **/
- polyn_gf2m(const uint8_t* mem, uint32_t mem_len, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(const uint8_t* mem, uint32_t mem_len, const std::shared_ptr<GF2m_Field>& sp_field);
/**
* create a polynomial from memory area (encoded)
*/
- polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len, std::shared_ptr<GF2m_Field> sp_field);
+ polyn_gf2m(int degree, const uint8_t* mem, size_t mem_byte_len,
+ const std::shared_ptr<GF2m_Field>& sp_field);
bool operator==(const polyn_gf2m & other) const ;
diff --git a/src/lib/pubkey/pk_algs.cpp b/src/lib/pubkey/pk_algs.cpp
index eec6a147c..b52ca97e0 100644
--- a/src/lib/pubkey/pk_algs.cpp
+++ b/src/lib/pubkey/pk_algs.cpp
@@ -398,7 +398,7 @@ create_private_key(const std::string& alg_name,
std::vector<std::string>
probe_provider_private_key(const std::string& alg_name,
- const std::vector<std::string> possible)
+ const std::vector<std::string>& possible)
{
std::vector<std::string> providers;
diff --git a/src/lib/pubkey/pk_algs.h b/src/lib/pubkey/pk_algs.h
index 09a03eed4..d17264137 100644
--- a/src/lib/pubkey/pk_algs.h
+++ b/src/lib/pubkey/pk_algs.h
@@ -50,7 +50,7 @@ create_ec_private_key(const std::string& algo_name,
BOTAN_PUBLIC_API(2,2)
std::vector<std::string>
probe_provider_private_key(const std::string& algo_name,
- const std::vector<std::string> possible);
+ const std::vector<std::string>& possible);
}
diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp
index a81e561d8..e910d79ee 100644
--- a/src/lib/pubkey/pkcs8.cpp
+++ b/src/lib/pubkey/pkcs8.cpp
@@ -47,7 +47,7 @@ secure_vector<uint8_t> PKCS8_extract(DataSource& source,
*/
secure_vector<uint8_t> PKCS8_decode(
DataSource& source,
- std::function<std::string ()> get_passphrase,
+ const std::function<std::string ()>& get_passphrase,
AlgorithmIdentifier& pk_alg_id,
bool is_encrypted)
{
@@ -339,7 +339,7 @@ load_key(DataSource& source,
bool is_encrypted)
{
AlgorithmIdentifier alg_id;
- secure_vector<uint8_t> pkcs8_key = PKCS8_decode(source, get_pass, alg_id, is_encrypted);
+ secure_vector<uint8_t> pkcs8_key = PKCS8_decode(source, std::move(get_pass), alg_id, is_encrypted);
const std::string alg_name = OIDS::oid2str_or_empty(alg_id.get_oid());
if(alg_name.empty())
@@ -357,7 +357,7 @@ load_key(DataSource& source,
std::unique_ptr<Private_Key> load_key(DataSource& source,
std::function<std::string ()> get_pass)
{
- return load_key(source, get_pass, true);
+ return load_key(source, std::move(get_pass), true);
}
/*
@@ -368,7 +368,7 @@ std::unique_ptr<Private_Key> load_key(DataSource& source,
{
// We need to use bind rather than a lambda capturing `pass` here in order to avoid a Clang 8 bug.
// See https://github.com/randombit/botan/issues/2255.
- return load_key(source, std::bind([](const std::string p) { return p; }, pass), true);
+ return load_key(source, std::bind([](const std::string& p) { return p; }, pass), true);
}
/*
diff --git a/src/lib/pubkey/pubkey.cpp b/src/lib/pubkey/pubkey.cpp
index bfda7e4a6..17532f939 100644
--- a/src/lib/pubkey/pubkey.cpp
+++ b/src/lib/pubkey/pubkey.cpp
@@ -185,7 +185,7 @@ secure_vector<uint8_t> PK_KEM_Decryptor::decrypt(const uint8_t encap_key[],
salt, salt_len);
}
-PK_Key_Agreement::PK_Key_Agreement(PK_Key_Agreement&&) = default;
+PK_Key_Agreement::PK_Key_Agreement(PK_Key_Agreement&&) noexcept = default;
PK_Key_Agreement::PK_Key_Agreement(const Private_Key& key,
RandomNumberGenerator& rng,
diff --git a/src/lib/pubkey/pubkey.h b/src/lib/pubkey/pubkey.h
index 22b0693af..734a4ba2c 100644
--- a/src/lib/pubkey/pubkey.h
+++ b/src/lib/pubkey/pubkey.h
@@ -66,9 +66,9 @@ class BOTAN_PUBLIC_API(2,0) PK_Encryptor
virtual ~PK_Encryptor() = default;
PK_Encryptor(const PK_Encryptor&) = delete;
- PK_Encryptor(PK_Encryptor&&) = delete;
+ PK_Encryptor(PK_Encryptor&&) noexcept = delete;
PK_Encryptor& operator=(const PK_Encryptor&) = delete;
- PK_Encryptor& operator=(PK_Encryptor&&) = delete;
+ PK_Encryptor& operator=(PK_Encryptor&&) noexcept = delete;
private:
virtual std::vector<uint8_t> enc(const uint8_t[], size_t,
@@ -148,9 +148,9 @@ class BOTAN_PUBLIC_API(2,0) PK_Decryptor
virtual ~PK_Decryptor() = default;
PK_Decryptor(const PK_Decryptor&) = delete;
- PK_Decryptor(PK_Decryptor&&) = delete;
+ PK_Decryptor(PK_Decryptor&&) noexcept = delete;
PK_Decryptor& operator=(const PK_Decryptor&) = delete;
- PK_Decryptor& operator=(PK_Decryptor&&) = delete;
+ PK_Decryptor& operator=(PK_Decryptor&&) noexcept = delete;
private:
virtual secure_vector<uint8_t> do_decrypt(uint8_t& valid_mask,
@@ -184,9 +184,9 @@ class BOTAN_PUBLIC_API(2,0) PK_Signer final
~PK_Signer();
PK_Signer(const PK_Signer&) = delete;
- PK_Signer(PK_Signer&&) = delete;
+ PK_Signer(PK_Signer&&) noexcept = delete;
PK_Signer& operator=(const PK_Signer&) = delete;
- PK_Signer& operator=(PK_Signer&&) = delete;
+ PK_Signer& operator=(PK_Signer&&) noexcept = delete;
/**
* Sign a message all in one go
@@ -297,9 +297,9 @@ class BOTAN_PUBLIC_API(2,0) PK_Verifier final
~PK_Verifier();
PK_Verifier(const PK_Verifier&) = delete;
- PK_Verifier(PK_Verifier&&) = delete;
+ PK_Verifier(PK_Verifier&&) noexcept = delete;
PK_Verifier& operator=(const PK_Verifier&) = delete;
- PK_Verifier& operator=(PK_Verifier&&) = delete;
+ PK_Verifier& operator=(PK_Verifier&&) noexcept = delete;
/**
* Verify a signature.
@@ -419,7 +419,7 @@ class BOTAN_PUBLIC_API(2,0) PK_Key_Agreement final
PK_Key_Agreement& operator=(PK_Key_Agreement&&) = delete;
// For ECIES
- PK_Key_Agreement(PK_Key_Agreement&&);
+ PK_Key_Agreement(PK_Key_Agreement&&) noexcept;
/**
* Perform Key Agreement Operation
diff --git a/src/lib/tls/msg_cert_status.cpp b/src/lib/tls/msg_cert_status.cpp
index bccfa02da..4fafd10ad 100644
--- a/src/lib/tls/msg_cert_status.cpp
+++ b/src/lib/tls/msg_cert_status.cpp
@@ -36,8 +36,8 @@ Certificate_Status::Certificate_Status(const std::vector<uint8_t>& buf)
Certificate_Status::Certificate_Status(Handshake_IO& io,
Handshake_Hash& hash,
- std::shared_ptr<const OCSP::Response> ocsp) :
- m_response(ocsp->raw_bits())
+ const OCSP::Response& ocsp) :
+ m_response(ocsp.raw_bits())
{
hash.update(io.send(*this));
}
diff --git a/src/lib/tls/msg_server_hello.cpp b/src/lib/tls/msg_server_hello.cpp
index a6ded657b..9122ce523 100644
--- a/src/lib/tls/msg_server_hello.cpp
+++ b/src/lib/tls/msg_server_hello.cpp
@@ -46,7 +46,7 @@ Server_Hello::Server_Hello(Handshake_IO& io,
const std::vector<uint8_t>& reneg_info,
const Client_Hello& client_hello,
const Server_Hello::Settings& server_settings,
- const std::string next_protocol) :
+ const std::string& next_protocol) :
m_version(server_settings.protocol_version()),
m_session_id(server_settings.session_id()),
m_random(make_server_hello_random(rng, m_version, policy)),
diff --git a/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp b/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp
index 4045011db..48c34db56 100644
--- a/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp
+++ b/src/lib/tls/sessions_sql/tls_session_manager_sql.cpp
@@ -22,7 +22,7 @@ Session_Manager_SQL::Session_Manager_SQL(std::shared_ptr<SQL_Database> db,
RandomNumberGenerator& rng,
size_t max_sessions,
std::chrono::seconds session_lifetime) :
- m_db(db),
+ m_db(std::move(db)),
m_rng(rng),
m_max_sessions(max_sessions),
m_session_lifetime(session_lifetime)
diff --git a/src/lib/tls/tls_messages.h b/src/lib/tls/tls_messages.h
index 08c3682f7..237ac1cc5 100644
--- a/src/lib/tls/tls_messages.h
+++ b/src/lib/tls/tls_messages.h
@@ -296,7 +296,7 @@ class BOTAN_UNSTABLE_API Server_Hello final : public Handshake_Message
const std::vector<uint8_t>& secure_reneg_info,
const Client_Hello& client_hello,
const Server_Hello::Settings& settings,
- const std::string next_protocol);
+ const std::string& next_protocol);
Server_Hello(Handshake_IO& io,
Handshake_Hash& hash,
@@ -394,14 +394,14 @@ class BOTAN_UNSTABLE_API Certificate_Status final : public Handshake_Message
Certificate_Status(Handshake_IO& io,
Handshake_Hash& hash,
- std::shared_ptr<const OCSP::Response> response);
+ const OCSP::Response& response);
/*
* Create a Certificate_Status message using an already DER encoded OCSP response.
*/
Certificate_Status(Handshake_IO& io,
Handshake_Hash& hash,
- std::vector<uint8_t> const& raw_response_bytes );
+ const std::vector<uint8_t>& raw_response_bytes);
private:
std::vector<uint8_t> serialize() const override;
diff --git a/src/lib/tls/tls_policy.cpp b/src/lib/tls/tls_policy.cpp
index d3fbf78c5..38c91c069 100644
--- a/src/lib/tls/tls_policy.cpp
+++ b/src/lib/tls/tls_policy.cpp
@@ -460,6 +460,7 @@ std::vector<uint16_t> Policy::ciphersuite_list(Protocol_Version version) const
std::sort(ciphersuites.begin(), ciphersuites.end(), order);
std::vector<uint16_t> ciphersuite_codes;
+ ciphersuite_codes.reserve(ciphersuites.size());
for(auto i : ciphersuites)
ciphersuite_codes.push_back(i.ciphersuite_code());
return ciphersuite_codes;
diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp
index 0150431c4..fbf8879a4 100644
--- a/src/lib/tls/tls_record.cpp
+++ b/src/lib/tls/tls_record.cpp
@@ -328,7 +328,7 @@ Record_Header read_tls_record(secure_vector<uint8_t>& readbuf,
size_t& consumed,
secure_vector<uint8_t>& recbuf,
Connection_Sequence_Numbers* sequence_numbers,
- get_cipherstate_fn get_cipherstate)
+ const get_cipherstate_fn& get_cipherstate)
{
if(readbuf.size() < TLS_HEADER_SIZE) // header incomplete?
{
@@ -462,7 +462,7 @@ Record_Header read_dtls_record(secure_vector<uint8_t>& readbuf,
size_t& consumed,
secure_vector<uint8_t>& recbuf,
Connection_Sequence_Numbers* sequence_numbers,
- get_cipherstate_fn get_cipherstate,
+ const get_cipherstate_fn& get_cipherstate,
bool allow_epoch0_restart)
{
if(readbuf.size() < DTLS_HEADER_SIZE) // header incomplete?
@@ -563,7 +563,7 @@ Record_Header read_record(bool is_datagram,
size_t& consumed,
secure_vector<uint8_t>& recbuf,
Connection_Sequence_Numbers* sequence_numbers,
- get_cipherstate_fn get_cipherstate,
+ const get_cipherstate_fn& get_cipherstate,
bool allow_epoch0_restart)
{
if(is_datagram)
diff --git a/src/lib/tls/tls_record.h b/src/lib/tls/tls_record.h
index 8af4e5c05..08ad14784 100644
--- a/src/lib/tls/tls_record.h
+++ b/src/lib/tls/tls_record.h
@@ -178,7 +178,7 @@ Record_Header read_record(bool is_datagram,
size_t& consumed,
secure_vector<uint8_t>& record_buf,
Connection_Sequence_Numbers* sequence_numbers,
- get_cipherstate_fn get_cipherstate,
+ const get_cipherstate_fn& get_cipherstate,
bool allow_epoch0_restart);
}
diff --git a/src/lib/tls/tls_server.cpp b/src/lib/tls/tls_server.cpp
index 7a9605b3b..6dc1ba9f2 100644
--- a/src/lib/tls/tls_server.cpp
+++ b/src/lib/tls/tls_server.cpp
@@ -153,7 +153,7 @@ uint16_t choose_ciphersuite(
const Client_Hello& client_hello)
{
const bool our_choice = policy.server_uses_own_ciphersuite_preferences();
- const std::vector<uint16_t> client_suites = client_hello.ciphersuites();
+ const std::vector<uint16_t>& client_suites = client_hello.ciphersuites();
const std::vector<uint16_t> server_suites = policy.ciphersuite_list(version);
if(server_suites.empty())
diff --git a/src/lib/tls/tls_text_policy.cpp b/src/lib/tls/tls_text_policy.cpp
index 1a072433b..2be8c369b 100644
--- a/src/lib/tls/tls_text_policy.cpp
+++ b/src/lib/tls/tls_text_policy.cpp
@@ -111,7 +111,7 @@ std::vector<Group_Params> Text_Policy::key_exchange_groups() const
}
std::vector<Group_Params> groups;
- for(std::string group_name : split_on(group_str, ' '))
+ for(const std::string& group_name : split_on(group_str, ' '))
{
Group_Params group_id = group_param_from_string(group_name);
@@ -207,7 +207,7 @@ uint32_t Text_Policy::session_ticket_lifetime() const
std::vector<uint16_t> Text_Policy::srtp_profiles() const
{
std::vector<uint16_t> r;
- for(std::string p : get_list("srtp_profiles", std::vector<std::string>()))
+ for(const std::string& p : get_list("srtp_profiles", std::vector<std::string>()))
{
r.push_back(to_uint16(p));
}
diff --git a/src/lib/utils/http_util/http_util.cpp b/src/lib/utils/http_util/http_util.cpp
index 3d56c22bb..01a23ab0e 100644
--- a/src/lib/utils/http_util/http_util.cpp
+++ b/src/lib/utils/http_util/http_util.cpp
@@ -95,14 +95,14 @@ std::string url_encode(const std::string& in)
std::ostream& operator<<(std::ostream& o, const Response& resp)
{
o << "HTTP " << resp.status_code() << " " << resp.status_message() << "\n";
- for(auto h : resp.headers())
+ for(const auto& h : resp.headers())
o << "Header '" << h.first << "' = '" << h.second << "'\n";
o << "Body " << std::to_string(resp.body().size()) << " bytes:\n";
o.write(cast_uint8_ptr_to_char(resp.body().data()), resp.body().size());
return o;
}
-Response http_sync(http_exch_fn http_transact,
+Response http_sync(const http_exch_fn& http_transact,
const std::string& verb,
const std::string& url,
const std::string& content_type,
@@ -131,7 +131,7 @@ Response http_sync(http_exch_fn http_transact,
loc = url.substr(host_loc_sep, std::string::npos);
}
- const auto port_sep = hostname.find(":");
+ const auto port_sep = hostname.find(':');
if(port_sep == std::string::npos)
{
service = "http";
diff --git a/src/lib/utils/http_util/http_util.h b/src/lib/utils/http_util/http_util.h
index abbed085e..8918b871b 100644
--- a/src/lib/utils/http_util/http_util.h
+++ b/src/lib/utils/http_util/http_util.h
@@ -72,7 +72,7 @@ BOTAN_TEST_API std::ostream& operator<<(std::ostream& o, const Response& resp);
typedef std::function<std::string (const std::string&, const std::string&, const std::string&)> http_exch_fn;
-Response http_sync(http_exch_fn fn,
+Response http_sync(const http_exch_fn& fn,
const std::string& verb,
const std::string& url,
const std::string& content_type,
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index 74894f04f..607f228a6 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -670,7 +670,7 @@ void botan_sigill_handler(int)
#endif
-int OS::run_cpu_instruction_probe(std::function<int ()> probe_fn)
+int OS::run_cpu_instruction_probe(const std::function<int ()>& probe_fn)
{
volatile int probe_result = -3;
diff --git a/src/lib/utils/os_utils.h b/src/lib/utils/os_utils.h
index 6fe3efe77..a70ce2ee1 100644
--- a/src/lib/utils/os_utils.h
+++ b/src/lib/utils/os_utils.h
@@ -171,7 +171,7 @@ void page_allow_access(void* page);
* Return codes:
* -1 illegal instruction detected
*/
-int BOTAN_TEST_API run_cpu_instruction_probe(std::function<int ()> probe_fn);
+int BOTAN_TEST_API run_cpu_instruction_probe(const std::function<int ()>& probe_fn);
/**
* Represents a terminal state
diff --git a/src/lib/utils/read_cfg.cpp b/src/lib/utils/read_cfg.cpp
index 6efee8efe..ec8a2b5a5 100644
--- a/src/lib/utils/read_cfg.cpp
+++ b/src/lib/utils/read_cfg.cpp
@@ -46,7 +46,7 @@ std::map<std::string, std::string> read_cfg(std::istream& is)
if(s.empty())
continue;
- auto eq = s.find("=");
+ auto eq = s.find('=');
if(eq == std::string::npos || eq == 0 || eq == s.size() - 1)
throw Decoding_Error("Bad read_cfg input '" + s + "' on line " + std::to_string(line));
diff --git a/src/lib/utils/thread_utils/thread_pool.cpp b/src/lib/utils/thread_utils/thread_pool.cpp
index ce326fdc0..9d262cff6 100644
--- a/src/lib/utils/thread_utils/thread_pool.cpp
+++ b/src/lib/utils/thread_utils/thread_pool.cpp
@@ -92,7 +92,7 @@ void Thread_Pool::shutdown()
m_workers.clear();
}
-void Thread_Pool::queue_thunk(std::function<void ()> fn)
+void Thread_Pool::queue_thunk(const std::function<void ()>& fn)
{
std::unique_lock<std::mutex> lock(m_mutex);
diff --git a/src/lib/utils/thread_utils/thread_pool.h b/src/lib/utils/thread_utils/thread_pool.h
index d94a0e75f..a1404ac2a 100644
--- a/src/lib/utils/thread_utils/thread_pool.h
+++ b/src/lib/utils/thread_utils/thread_pool.h
@@ -63,7 +63,7 @@ class BOTAN_TEST_API Thread_Pool
/*
* Enqueue some work
*/
- void queue_thunk(std::function<void ()>);
+ void queue_thunk(const std::function<void ()>&);
template<class F, class... Args>
auto run(F&& f, Args&&... args) -> std::future<typename std::invoke_result<F, Args...>::type>
diff --git a/src/lib/x509/certstor.cpp b/src/lib/x509/certstor.cpp
index 9bec24f64..7108575e2 100644
--- a/src/lib/x509/certstor.cpp
+++ b/src/lib/x509/certstor.cpp
@@ -133,7 +133,7 @@ Certificate_Store_In_Memory::find_cert_by_raw_subject_dn_sha256(const std::vecto
void Certificate_Store_In_Memory::add_crl(const X509_CRL& crl)
{
- X509_DN crl_issuer = crl.issuer_dn();
+ const X509_DN& crl_issuer = crl.issuer_dn();
for(auto& c : m_crls)
{
diff --git a/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp b/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp
index 74837cd1e..20e5b536a 100644
--- a/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp
+++ b/src/lib/x509/certstor_flatfile/certstor_flatfile.cpp
@@ -90,7 +90,7 @@ std::vector<X509_Certificate> Flatfile_Certificate_Store::find_all_certs(
{
const auto certs = m_dn_to_cert.at(subject_dn);
- for(auto cert : certs)
+ for(const auto& cert : certs)
{
if(key_id.empty() || key_id == cert.subject_key_id())
{
diff --git a/src/lib/x509/certstor_sql/certstor_sql.cpp b/src/lib/x509/certstor_sql/certstor_sql.cpp
index 72fdc59fc..af3a31ad8 100644
--- a/src/lib/x509/certstor_sql/certstor_sql.cpp
+++ b/src/lib/x509/certstor_sql/certstor_sql.cpp
@@ -20,7 +20,7 @@ Certificate_Store_In_SQL::Certificate_Store_In_SQL(std::shared_ptr<SQL_Database>
RandomNumberGenerator& rng,
const std::string& table_prefix) :
m_rng(rng),
- m_database(db),
+ m_database(std::move(db)),
m_prefix(table_prefix),
m_password(passwd)
{
@@ -319,12 +319,14 @@ std::vector<X509_CRL> Certificate_Store_In_SQL::generate_crls() const
}
}
- std::vector<X509_CRL> ret;
X509_Time t(std::chrono::system_clock::now());
- for(auto p: crls)
+ std::vector<X509_CRL> ret;
+ ret.reserve(crls.size());
+
+ for(const auto& p: crls)
{
- ret.push_back(X509_CRL(p.first,t,t,p.second));
+ ret.push_back(X509_CRL(p.first, t, t, p.second));
}
return ret;
diff --git a/src/lib/x509/pkcs10.cpp b/src/lib/x509/pkcs10.cpp
index 936653e33..73ec42147 100644
--- a/src/lib/x509/pkcs10.cpp
+++ b/src/lib/x509/pkcs10.cpp
@@ -167,7 +167,7 @@ std::unique_ptr<PKCS10_Data> decode_pkcs10(const std::vector<uint8_t>& body)
data->m_alt_name = ext->get_alt_name();
}
- for(std::string email : pkcs9_email)
+ for(const std::string& email : pkcs9_email)
{
data->m_alt_name.add_attribute("RFC882", email);
}
diff --git a/src/lib/x509/x509_crl.cpp b/src/lib/x509/x509_crl.cpp
index 3dcdeb108..3632940c2 100644
--- a/src/lib/x509/x509_crl.cpp
+++ b/src/lib/x509/x509_crl.cpp
@@ -83,7 +83,7 @@ bool X509_CRL::is_revoked(const X509_Certificate& cert) const
return false;
std::vector<uint8_t> crl_akid = authority_key_id();
- std::vector<uint8_t> cert_akid = cert.authority_key_id();
+ const std::vector<uint8_t>& cert_akid = cert.authority_key_id();
if(!crl_akid.empty() && !cert_akid.empty())
{
@@ -91,7 +91,7 @@ bool X509_CRL::is_revoked(const X509_Certificate& cert) const
return false;
}
- std::vector<uint8_t> cert_serial = cert.serial_number();
+ const std::vector<uint8_t>& cert_serial = cert.serial_number();
bool is_revoked = false;
diff --git a/src/lib/x509/x509_ext.cpp b/src/lib/x509/x509_ext.cpp
index c811ba6c9..967bb4dea 100644
--- a/src/lib/x509/x509_ext.cpp
+++ b/src/lib/x509/x509_ext.cpp
@@ -238,7 +238,7 @@ std::map<OID, std::pair<std::vector<uint8_t>, bool>> Extensions::extensions_raw(
*/
void Extensions::encode_into(DER_Encoder& to_object) const
{
- for(auto ext_info : m_extension_info)
+ for(const auto& ext_info : m_extension_info)
{
const OID& oid = ext_info.first;
const bool should_encode = ext_info.second.obj().should_encode();
@@ -569,7 +569,7 @@ void Name_Constraints::validate(const X509_Certificate& subject, const X509_Cert
bool permitted = m_name_constraints.permitted().empty();
bool failed = false;
- for(auto c: m_name_constraints.permitted())
+ for(const auto& c: m_name_constraints.permitted())
{
switch(c.base().matches(cert_path.at(j)))
{
@@ -586,7 +586,7 @@ void Name_Constraints::validate(const X509_Certificate& subject, const X509_Cert
}
}
- for(auto c: m_name_constraints.excluded())
+ for(const auto& c: m_name_constraints.excluded())
{
switch(c.base().matches(cert_path.at(j)))
{
diff --git a/src/lib/x509/x509_obj.cpp b/src/lib/x509/x509_obj.cpp
index 1ac7f8279..c0268306f 100644
--- a/src/lib/x509/x509_obj.cpp
+++ b/src/lib/x509/x509_obj.cpp
@@ -65,7 +65,7 @@ void X509_Object::load_data(DataSource& in)
if(got_label != PEM_label())
{
bool is_alternate = false;
- for(std::string alt_label : alternate_PEM_labels())
+ for(const std::string& alt_label : alternate_PEM_labels())
{
if(got_label == alt_label)
{
diff --git a/src/lib/x509/x509cert.cpp b/src/lib/x509/x509cert.cpp
index c742a688f..05ac29150 100644
--- a/src/lib/x509/x509cert.cpp
+++ b/src/lib/x509/x509cert.cpp
@@ -798,7 +798,7 @@ std::string X509_Certificate::to_string() const
if(!policies.empty())
{
out << "Policies: " << "\n";
- for(auto oid : policies)
+ for(const auto& oid : policies)
out << " " << oid.to_string() << "\n";
}
@@ -821,7 +821,7 @@ std::string X509_Certificate::to_string() const
if(!name_constraints.permitted().empty())
{
out << " Permit";
- for(auto st: name_constraints.permitted())
+ for(const auto& st: name_constraints.permitted())
{
out << " " << st.base();
}
@@ -831,7 +831,7 @@ std::string X509_Certificate::to_string() const
if(!name_constraints.excluded().empty())
{
out << " Exclude";
- for(auto st: name_constraints.excluded())
+ for(const auto& st: name_constraints.excluded())
{
out << " " << st.base();
}
diff --git a/src/lib/x509/x509path.cpp b/src/lib/x509/x509path.cpp
index 7a5ff35b1..f71266d56 100644
--- a/src/lib/x509/x509path.cpp
+++ b/src/lib/x509/x509path.cpp
@@ -1012,7 +1012,7 @@ CertificatePathStatusCodes find_warnings(const CertificatePathStatusCodes& all_s
Path_Validation_Result::Path_Validation_Result(CertificatePathStatusCodes status,
std::vector<X509_Certificate>&& cert_chain) :
- m_all_status(status),
+ m_all_status(std::move(status)),
m_warnings(find_warnings(m_all_status)),
m_cert_path(cert_chain),
m_overall(PKIX::overall_status(m_all_status))
@@ -1046,7 +1046,7 @@ bool Path_Validation_Result::successful_validation() const
bool Path_Validation_Result::no_warnings() const
{
- for(auto status_set_i : m_warnings)
+ for(const auto& status_set_i : m_warnings)
if(!status_set_i.empty())
return false;
return true;
diff --git a/src/lib/x509/x509self.cpp b/src/lib/x509/x509self.cpp
index ad43055c4..0cd77d367 100644
--- a/src/lib/x509/x509self.cpp
+++ b/src/lib/x509/x509self.cpp
@@ -29,7 +29,7 @@ void load_info(const X509_Cert_Options& opts, X509_DN& subject_dn,
subject_dn.add_attribute("X520.Locality", opts.locality);
subject_dn.add_attribute("X520.Organization", opts.organization);
subject_dn.add_attribute("X520.OrganizationalUnit", opts.org_unit);
- for(auto extra_ou : opts.more_org_units) {
+ for(const auto& extra_ou : opts.more_org_units) {
subject_dn.add_attribute("X520.OrganizationalUnit", extra_ou);
}
@@ -38,7 +38,7 @@ void load_info(const X509_Cert_Options& opts, X509_DN& subject_dn,
subject_alt.add_othername(OID::from_string("PKIX.XMPPAddr"),
opts.xmpp, ASN1_Type::Utf8String);
- for(auto dns : opts.more_dns)
+ for(const auto& dns : opts.more_dns)
subject_alt.add_attribute("DNS", dns);
}
}