aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/cli.cpp8
-rw-r--r--src/cli/cli.h6
-rw-r--r--src/cli/entropy.cpp2
-rw-r--r--src/cli/pubkey.cpp2
-rw-r--r--src/cli/speed.cpp16
-rw-r--r--src/cli/timing_tests.cpp12
-rw-r--r--src/cli/tss.cpp2
-rw-r--r--src/cli/utils.cpp2
-rw-r--r--src/cli/x509.cpp8
-rw-r--r--src/cli/zfec.cpp4
-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
-rwxr-xr-xsrc/scripts/run_clang_tidy.py4
-rw-r--r--src/tests/test_bigint.cpp2
-rw-r--r--src/tests/test_certstor_utils.cpp2
-rw-r--r--src/tests/test_certstor_utils.h2
-rw-r--r--src/tests/test_dl_group.cpp2
-rw-r--r--src/tests/test_ec_group.cpp8
-rw-r--r--src/tests/test_ecdsa.cpp2
-rw-r--r--src/tests/test_ffi.cpp7
-rw-r--r--src/tests/test_gost_3410.cpp4
-rw-r--r--src/tests/test_hash_id.cpp2
-rw-r--r--src/tests/test_ocsp.cpp2
-rw-r--r--src/tests/test_octetstring.cpp4
-rw-r--r--src/tests/test_pbkdf.cpp2
-rw-r--r--src/tests/test_pk_pad.cpp6
-rw-r--r--src/tests/test_pkcs11_high_level.cpp2
-rw-r--r--src/tests/test_psk_db.cpp2
-rw-r--r--src/tests/test_runner.cpp6
-rw-r--r--src/tests/test_tls.cpp2
-rw-r--r--src/tests/test_tss.cpp1
-rw-r--r--src/tests/test_utils.cpp3
-rw-r--r--src/tests/tests.cpp14
-rw-r--r--src/tests/tests.h10
-rw-r--r--src/tests/unit_x509.cpp10
88 files changed, 195 insertions, 193 deletions
diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp
index cdfe6226c..a6191eaeb 100644
--- a/src/cli/cli.cpp
+++ b/src/cli/cli.cpp
@@ -197,7 +197,7 @@ std::string Command::slurp_file_as_str(const std::string& input_file,
}
void Command::read_file(const std::string& input_file,
- std::function<void (uint8_t[], size_t)> consumer_fn,
+ const std::function<void (uint8_t[], size_t)>& consumer_fn,
size_t buf_size) const
{
if(input_file == "-")
@@ -216,7 +216,7 @@ void Command::read_file(const std::string& input_file,
}
void Command::do_read_file(std::istream& in,
- std::function<void (uint8_t[], size_t)> consumer_fn,
+ const std::function<void (uint8_t[], size_t)>& consumer_fn,
size_t buf_size) const
{
// Avoid an infinite loop on --buf-size=0
@@ -242,7 +242,7 @@ Botan::RandomNumberGenerator& Command::rng()
std::string Command::get_passphrase_arg(const std::string& prompt, const std::string& opt_name)
{
- const std::string s = get_arg(opt_name);
+ std::string s = get_arg(opt_name);
if(s != "-")
return s;
return get_passphrase(prompt);
@@ -308,7 +308,7 @@ std::string Command::format_blob(const std::string& format,
// Registration code
-Command::Registration::Registration(const std::string& name, Command::cmd_maker_fn maker_fn)
+Command::Registration::Registration(const std::string& name, const Command::cmd_maker_fn& maker_fn)
{
std::map<std::string, Command::cmd_maker_fn>& reg = Command::global_registry();
diff --git a/src/cli/cli.h b/src/cli/cli.h
index c8aac22e3..c7e5163e2 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -167,12 +167,12 @@ class Command
* Read a file calling consumer_fn() with the inputs
*/
void read_file(const std::string& input_file,
- std::function<void (uint8_t[], size_t)> consumer_fn,
+ const std::function<void (uint8_t[], size_t)>& consumer_fn,
size_t buf_size = 0) const;
void do_read_file(std::istream& in,
- std::function<void (uint8_t[], size_t)> consumer_fn,
+ const std::function<void (uint8_t[], size_t)>& consumer_fn,
size_t buf_size = 0) const;
template<typename Alloc>
@@ -207,7 +207,7 @@ class Command
class Registration final
{
public:
- Registration(const std::string& name, cmd_maker_fn maker_fn);
+ Registration(const std::string& name, const cmd_maker_fn& maker_fn);
};
};
diff --git a/src/cli/entropy.cpp b/src/cli/entropy.cpp
index 472765704..6cace2b08 100644
--- a/src/cli/entropy.cpp
+++ b/src/cli/entropy.cpp
@@ -43,7 +43,7 @@ class Entropy final : public Command
else
sources.push_back(req_source);
- for(std::string source : sources)
+ for(const std::string& source : sources)
{
Botan_Tests::SeedCapturing_RNG rng;
const size_t entropy_estimate = entropy_sources.poll_just(rng, source);
diff --git a/src/cli/pubkey.cpp b/src/cli/pubkey.cpp
index 53dad7128..8b31327ec 100644
--- a/src/cli/pubkey.cpp
+++ b/src/cli/pubkey.cpp
@@ -157,7 +157,7 @@ class PK_Fingerprint final : public Command
const std::string hash_algo = get_arg("algo");
const bool no_fsname = flag_set("no-fsname");
- for(std::string key_file : get_arg_list("keys"))
+ for(const std::string& key_file : get_arg_list("keys"))
{
std::unique_ptr<Botan::Public_Key> key(
key_file == "-"
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index 8de6bf5a3..a0b940135 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -292,7 +292,7 @@ std::vector<size_t> unique_buffer_sizes(const std::string& cmdline_arg)
const size_t MAX_BUF_SIZE = 64*1024*1024;
std::set<size_t> buf;
- for(std::string size_str : Command::split_on(cmdline_arg, ','))
+ for(const std::string& size_str : Command::split_on(cmdline_arg, ','))
{
size_t x = 0;
try
@@ -474,7 +474,7 @@ class Speed final : public Command
const std::vector<size_t> buf_sizes = unique_buffer_sizes(get_arg("buf-size"));
- for(std::string cpuid_to_clear : Command::split_on(get_arg("clear-cpuid"), ','))
+ for(const std::string& cpuid_to_clear : Command::split_on(get_arg("clear-cpuid"), ','))
{
auto bits = Botan::CPUID::bit_from_string(cpuid_to_clear);
if(bits.empty())
@@ -500,7 +500,7 @@ class Speed final : public Command
algos = default_benchmark_list();
}
- for(auto algo : algos)
+ for(const auto& algo : algos)
{
using namespace std::placeholders;
@@ -1131,7 +1131,7 @@ class Speed final : public Command
#if defined(BOTAN_HAS_ECC_GROUP)
void bench_ecc_ops(const std::vector<std::string>& groups, const std::chrono::milliseconds runtime)
{
- for(std::string group_name : groups)
+ for(const std::string& group_name : groups)
{
const Botan::EC_Group ec_group(group_name);
@@ -1179,7 +1179,7 @@ class Speed final : public Command
void bench_ecc_mult(const std::vector<std::string>& groups, const std::chrono::milliseconds runtime)
{
- for(std::string group_name : groups)
+ for(const std::string& group_name : groups)
{
const Botan::EC_Group ec_group(group_name);
@@ -1217,7 +1217,7 @@ class Speed final : public Command
void bench_os2ecp(const std::vector<std::string>& groups, const std::chrono::milliseconds runtime)
{
- for(std::string group_name : groups)
+ for(const std::string& group_name : groups)
{
auto uncmp_timer = make_timer("OS2ECP uncompressed " + group_name);
auto cmp_timer = make_timer("OS2ECP compressed " + group_name);
@@ -1963,7 +1963,7 @@ class Speed final : public Command
const std::string&,
std::chrono::milliseconds msec)
{
- for(std::string group_name : groups)
+ for(const std::string& group_name : groups)
{
Botan::EC_Group group(group_name);
auto recovery_timer = make_timer("ECDSA recovery " + group_name);
@@ -2110,7 +2110,7 @@ class Speed final : public Command
const std::string& provider,
std::chrono::milliseconds msec)
{
- for(std::string grp : groups)
+ for(const std::string& grp : groups)
{
bench_pk_ka("ECDH", "ECDH-" + grp, grp, provider, msec);
}
diff --git a/src/cli/timing_tests.cpp b/src/cli/timing_tests.cpp
index e3c28a633..d1ebc79c3 100644
--- a/src/cli/timing_tests.cpp
+++ b/src/cli/timing_tests.cpp
@@ -118,8 +118,7 @@ class Bleichenbacker_Timing_Test final : public Timing_Test
std::vector<uint8_t> prepare_input(const std::string& input) override
{
const std::vector<uint8_t> input_vector = Botan::hex_decode(input);
- const std::vector<uint8_t> encrypted = m_enc.encrypt(input_vector, timing_test_rng());
- return encrypted;
+ return m_enc.encrypt(input_vector, timing_test_rng());
}
ticks measure_critical_function(const std::vector<uint8_t>& input) override
@@ -162,8 +161,7 @@ class Manger_Timing_Test final : public Timing_Test
std::vector<uint8_t> prepare_input(const std::string& input) override
{
const std::vector<uint8_t> input_vector = Botan::hex_decode(input);
- const std::vector<uint8_t> encrypted = m_enc.encrypt(input_vector, timing_test_rng());
- return encrypted;
+ return m_enc.encrypt(input_vector, timing_test_rng());
}
ticks measure_critical_function(const std::vector<uint8_t>& input) override
@@ -262,7 +260,7 @@ ticks Lucky13_Timing_Test::measure_critical_function(const std::vector<uint8_t>&
class ECDSA_Timing_Test final : public Timing_Test
{
public:
- ECDSA_Timing_Test(std::string ecgroup);
+ ECDSA_Timing_Test(const std::string& ecgroup);
ticks measure_critical_function(const std::vector<uint8_t>& input) override;
@@ -274,7 +272,7 @@ class ECDSA_Timing_Test final : public Timing_Test
Botan::BigInt m_b, m_b_inv;
};
-ECDSA_Timing_Test::ECDSA_Timing_Test(std::string ecgroup)
+ECDSA_Timing_Test::ECDSA_Timing_Test(const std::string& ecgroup)
: m_group(ecgroup)
, m_privkey(timing_test_rng(), m_group)
, m_x(m_privkey.private_value())
@@ -317,7 +315,7 @@ ticks ECDSA_Timing_Test::measure_critical_function(const std::vector<uint8_t>& i
class ECC_Mul_Timing_Test final : public Timing_Test
{
public:
- ECC_Mul_Timing_Test(std::string ecgroup) :
+ ECC_Mul_Timing_Test(const std::string& ecgroup) :
m_group(ecgroup)
{}
diff --git a/src/cli/tss.cpp b/src/cli/tss.cpp
index 0756616b2..4f11fc0a3 100644
--- a/src/cli/tss.cpp
+++ b/src/cli/tss.cpp
@@ -118,7 +118,7 @@ class TSS_Recover final : public Command
std::vector<Botan::RTSS_Share> shares;
- for(std::string share_fsname : get_arg_list("shares"))
+ for(const std::string& share_fsname : get_arg_list("shares"))
{
auto v = slurp_file(share_fsname);
shares.push_back(Botan::RTSS_Share(v.data(), v.size()));
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp
index 9b800cf76..03f3169b0 100644
--- a/src/cli/utils.cpp
+++ b/src/cli/utils.cpp
@@ -125,7 +125,7 @@ class Has_Command final : public Command
const std::string cmd = get_arg("cmd");
bool exists = false;
- for(auto registered_cmd : Command::registered_cmds())
+ for(const auto& registered_cmd : Command::registered_cmds())
{
if(cmd == registered_cmd)
{
diff --git a/src/cli/x509.cpp b/src/cli/x509.cpp
index a11411dfd..52874ce50 100644
--- a/src/cli/x509.cpp
+++ b/src/cli/x509.cpp
@@ -53,15 +53,15 @@ class Trust_Root_Info final : public Command
if(flag_set("dn-only"))
{
- for(auto dn : dn_list)
+ for(const auto& dn : dn_list)
output() << dn << "\n";
}
else
{
- for(auto dn : dn_list)
+ for(const auto& dn : dn_list)
{
// Some certstores have more than one cert with a particular DN
- for(auto cert : trust_roots.find_all_certs(dn, std::vector<uint8_t>()))
+ for(const auto& cert : trust_roots.find_all_certs(dn, std::vector<uint8_t>()))
{
if(flag_set("dn"))
output() << "# " << dn << "\n";
@@ -396,7 +396,7 @@ class Generate_PKCS10 final : public Command
opts.CA_key(get_arg_sz("path-limit"));
}
- for(std::string ext_ku : Command::split_on(get_arg("ext-ku"), ','))
+ for(const std::string& ext_ku : Command::split_on(get_arg("ext-ku"), ','))
{
opts.add_ex_constraint(ext_ku);
}
diff --git a/src/cli/zfec.cpp b/src/cli/zfec.cpp
index ac31bc731..ad37d95d0 100644
--- a/src/cli/zfec.cpp
+++ b/src/cli/zfec.cpp
@@ -219,7 +219,7 @@ class FEC_Decode final : public Command
std::vector<FEC_Share> shares;
- for(auto share_fsname: get_arg_list("shares"))
+ for(const auto& share_fsname: get_arg_list("shares"))
{
const auto share_bits = slurp_file(share_fsname);
@@ -249,7 +249,7 @@ class FEC_Decode final : public Command
size_t padding = 0;
size_t share_size = 0;
- for(auto share: shares)
+ for(const auto& share: shares)
{
if(k == 0 && n == 0 && padding == 0)
{
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);
}
}
diff --git a/src/scripts/run_clang_tidy.py b/src/scripts/run_clang_tidy.py
index 0652f8651..3b882d78d 100755
--- a/src/scripts/run_clang_tidy.py
+++ b/src/scripts/run_clang_tidy.py
@@ -11,7 +11,7 @@ from multiprocessing.pool import ThreadPool
enabled_checks = [
'clang-analyzer-*',
- #'performance-*',
+ 'performance-*',
#'bugprone-*',
#'cert-*',
#'cppcoreguidelines-*',
@@ -34,6 +34,8 @@ disabled_checks = [
'modernize-pass-by-value',
'modernize-use-trailing-return-type',
'readability-function-cognitive-complexity', # bogus
+ 'performance-inefficient-string-concatenation',
+ 'performance-no-int-to-ptr',
]
def create_check_option(enabled, disabled):
diff --git a/src/tests/test_bigint.cpp b/src/tests/test_bigint.cpp
index fc04ce3fa..232cba648 100644
--- a/src/tests/test_bigint.cpp
+++ b/src/tests/test_bigint.cpp
@@ -190,7 +190,7 @@ class BigInt_Unit_Tests final : public Test
{ "4294967297", Botan::BigInt(2147483648) * 2 + 1 }
};
- for(auto vec : str_to_val)
+ for(const auto& vec : str_to_val)
{
Botan::BigInt n;
std::istringstream iss;
diff --git a/src/tests/test_certstor_utils.cpp b/src/tests/test_certstor_utils.cpp
index 8221addd9..f97ae703b 100644
--- a/src/tests/test_certstor_utils.cpp
+++ b/src/tests/test_certstor_utils.cpp
@@ -14,7 +14,7 @@
namespace Botan_Tests {
-Botan::X509_DN read_dn(const std::string hex)
+Botan::X509_DN read_dn(const std::string& hex)
{
Botan::X509_DN dn;
Botan::BER_Decoder decoder(Botan::hex_decode(hex));
diff --git a/src/tests/test_certstor_utils.h b/src/tests/test_certstor_utils.h
index 1db9edf17..d96319af5 100644
--- a/src/tests/test_certstor_utils.h
+++ b/src/tests/test_certstor_utils.h
@@ -19,7 +19,7 @@
namespace Botan_Tests {
-Botan::X509_DN read_dn(const std::string hex);
+Botan::X509_DN read_dn(const std::string& hex);
Botan::X509_DN get_dn();
diff --git a/src/tests/test_dl_group.cpp b/src/tests/test_dl_group.cpp
index 4e4faa2dd..dd29372d1 100644
--- a/src/tests/test_dl_group.cpp
+++ b/src/tests/test_dl_group.cpp
@@ -196,7 +196,7 @@ class DL_Named_Group_Tests final : public Test
Test::Result result("DL_Group named");
result.start_timer();
- for(std::string name : dl_named)
+ for(const std::string& name : dl_named)
{
// Confirm we can load every group we expect
Botan::DL_Group group(name);
diff --git a/src/tests/test_ec_group.cpp b/src/tests/test_ec_group.cpp
index f0e7a8e0f..800012e98 100644
--- a/src/tests/test_ec_group.cpp
+++ b/src/tests/test_ec_group.cpp
@@ -27,7 +27,7 @@ namespace {
#if defined(BOTAN_HAS_ECC_GROUP)
-Botan::BigInt test_integer(Botan::RandomNumberGenerator& rng, size_t bits, BigInt max)
+Botan::BigInt test_integer(Botan::RandomNumberGenerator& rng, size_t bits, const BigInt& max)
{
/*
Produces integers with long runs of ones and zeros, for testing for
@@ -223,7 +223,7 @@ class NIST_Curve_Reduction_Tests final : public Test
Test::Result random_redc_test(const std::string& prime_name,
const Botan::BigInt& p,
- reducer_fn redc_fn)
+ const reducer_fn& redc_fn)
{
const Botan::BigInt p2 = p * p;
const size_t p_bits = p.bits();
@@ -523,7 +523,7 @@ Test::Result test_mult_point()
Botan::EC_Group secp160r1("secp160r1");
const Botan::PointGFp& p_G = secp160r1.get_base_point();
- Botan::PointGFp p0 = p_G;
+ const Botan::PointGFp& p0 = p_G;
Botan::PointGFp p1 = p_G * 2;
p1 *= p0.get_affine_x();
@@ -559,7 +559,7 @@ Test::Result test_basic_operations()
Botan::EC_Group secp160r1("secp160r1");
const Botan::PointGFp& p_G = secp160r1.get_base_point();
- const Botan::PointGFp p0 = p_G;
+ const Botan::PointGFp& p0 = p_G;
const Botan::PointGFp p1 = p_G * 2;
result.test_eq("p1 affine x", p1.get_affine_x(), Botan::BigInt("16984103820118642236896513183038186009872590470"));
diff --git a/src/tests/test_ecdsa.cpp b/src/tests/test_ecdsa.cpp
index be005db5b..f7f5afc12 100644
--- a/src/tests/test_ecdsa.cpp
+++ b/src/tests/test_ecdsa.cpp
@@ -121,7 +121,7 @@ class ECDSA_Signature_KAT_Tests final : public PK_Signature_Generation_Test
std::string default_padding(const VarMap& vars) const override
{
- const std::string hash = vars.get_req_str("Hash");
+ std::string hash = vars.get_req_str("Hash");
if(hash.substr(0,3) == "Raw")
return hash;
return "EMSA1(" + hash + ")";
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp
index 143371cb5..85938670e 100644
--- a/src/tests/test_ffi.cpp
+++ b/src/tests/test_ffi.cpp
@@ -168,11 +168,10 @@ class FFI_Unit_Tests final : public Test
result.test_is_eq("FFI doesn't support bogus version", botan_ffi_supports_api(20160229), -1);
const std::vector<uint8_t> mem1 = { 0xFF, 0xAA, 0xFF };
- const std::vector<uint8_t> mem2 = mem1;
- const std::vector<uint8_t> mem3 = { 0xFF, 0xA9, 0xFF };
+ const std::vector<uint8_t> mem2 = { 0xFF, 0xA9, 0xFF };
- TEST_FFI_RC(0, botan_same_mem, (mem1.data(), mem2.data(), mem1.size()));
- TEST_FFI_RC(-1, botan_same_mem, (mem1.data(), mem3.data(), mem1.size()));
+ TEST_FFI_RC(0, botan_same_mem, (mem1.data(), mem1.data(), mem1.size()));
+ TEST_FFI_RC(-1, botan_same_mem, (mem1.data(), mem2.data(), mem1.size()));
std::vector<uint8_t> to_zero = { 0xFF, 0xA0 };
TEST_FFI_OK(botan_scrub_mem, (to_zero.data(), to_zero.size()));
diff --git a/src/tests/test_gost_3410.cpp b/src/tests/test_gost_3410.cpp
index 1b8b46e44..5fd2726c1 100644
--- a/src/tests/test_gost_3410.cpp
+++ b/src/tests/test_gost_3410.cpp
@@ -48,7 +48,7 @@ class GOST_3410_2001_Verification_Tests final : public PK_Signature_Verification
std::string default_padding(const VarMap& vars) const override
{
- const std::string hash = vars.get_req_str("Hash");
+ auto hash = vars.get_req_str("Hash");
if(hash == "Raw")
return hash;
return "EMSA1(" + hash + ")";
@@ -83,7 +83,7 @@ class GOST_3410_2001_Signature_Tests final : public PK_Signature_Generation_Test
std::string default_padding(const VarMap& vars) const override
{
- const std::string hash = vars.get_req_str("Hash");
+ auto hash = vars.get_req_str("Hash");
if(hash == "Raw")
return hash;
return "EMSA1(" + hash + ")";
diff --git a/src/tests/test_hash_id.cpp b/src/tests/test_hash_id.cpp
index ac0bae1a5..d392e844b 100644
--- a/src/tests/test_hash_id.cpp
+++ b/src/tests/test_hash_id.cpp
@@ -39,7 +39,7 @@ class PKCS_HashID_Test final : public Test
std::vector<Test::Result> results;
- for(auto hash_info : hash_id_fns)
+ for(const auto& hash_info : hash_id_fns)
{
const std::string hash_fn = hash_info.first;
const size_t hash_len = hash_info.second;
diff --git a/src/tests/test_ocsp.cpp b/src/tests/test_ocsp.cpp
index ac8b1f94c..a507045f5 100644
--- a/src/tests/test_ocsp.cpp
+++ b/src/tests/test_ocsp.cpp
@@ -43,7 +43,7 @@ class OCSP_Tests final : public Test
"x509/ocsp/resp3.der"
};
- for(std::string ocsp_input_path : ocsp_input_paths)
+ for(const std::string& ocsp_input_path : ocsp_input_paths)
{
try
{
diff --git a/src/tests/test_octetstring.cpp b/src/tests/test_octetstring.cpp
index 81789762d..b032608b0 100644
--- a/src/tests/test_octetstring.cpp
+++ b/src/tests/test_octetstring.cpp
@@ -102,9 +102,9 @@ Test::Result test_equality()
Test::Result result("OctetString");
const Botan::OctetString os1("0000000000000000");
- const Botan::OctetString os1_copy = os1;
+ const Botan::OctetString& os1_copy = os1;
const Botan::OctetString os2("FFFFFFFFFFFFFFFF");
- const Botan::OctetString os2_copy = os2;
+ const Botan::OctetString& os2_copy = os2;
result.confirm("OctetString equality operations works as expected", os1 == os1_copy);
result.confirm("OctetString equality operations works as expected", os2 == os2_copy);
diff --git a/src/tests/test_pbkdf.cpp b/src/tests/test_pbkdf.cpp
index 541aefac4..bad598da9 100644
--- a/src/tests/test_pbkdf.cpp
+++ b/src/tests/test_pbkdf.cpp
@@ -90,7 +90,7 @@ class Pwdhash_Tests : public Test
"Bcrypt-PBKDF"
};
- for(std::string pwdhash : all_pwdhash)
+ for(const std::string& pwdhash : all_pwdhash)
{
Test::Result result("Pwdhash " + pwdhash);
auto pwdhash_fam = Botan::PasswordHashFamily::create(pwdhash);
diff --git a/src/tests/test_pk_pad.cpp b/src/tests/test_pk_pad.cpp
index f809562ff..ae89e9453 100644
--- a/src/tests/test_pk_pad.cpp
+++ b/src/tests/test_pk_pad.cpp
@@ -111,7 +111,7 @@ class EMSA_unit_tests final : public Test
#endif
};
- for(auto pad : pads_need_hash)
+ for(const auto& pad : pads_need_hash)
{
try
{
@@ -131,7 +131,7 @@ class EMSA_unit_tests final : public Test
}
}
- for(auto pad : pads_need_hash)
+ for(const auto& pad : pads_need_hash)
{
std::string algo_name = pad + "(YYZ)";
try
@@ -152,7 +152,7 @@ class EMSA_unit_tests final : public Test
}
}
- for(auto pad : pads_no_hash)
+ for(const auto& pad : pads_no_hash)
{
try
{
diff --git a/src/tests/test_pkcs11_high_level.cpp b/src/tests/test_pkcs11_high_level.cpp
index e3fec64e1..54fd5a707 100644
--- a/src/tests/test_pkcs11_high_level.cpp
+++ b/src/tests/test_pkcs11_high_level.cpp
@@ -1122,7 +1122,7 @@ Test::Result test_ecdsa_generate_keypair()
return result;
}
-Test::Result test_ecdsa_sign_verify_core(EC_Group_Encoding ec_dompar_enc, std::string test_name)
+Test::Result test_ecdsa_sign_verify_core(EC_Group_Encoding ec_dompar_enc, const std::string& test_name)
{
Test::Result result(test_name);
TestSession test_session(true);
diff --git a/src/tests/test_psk_db.cpp b/src/tests/test_psk_db.cpp
index fc2501fa3..2ec1b66b2 100644
--- a/src/tests/test_psk_db.cpp
+++ b/src/tests/test_psk_db.cpp
@@ -66,7 +66,7 @@ class Test_Map_PSK_Db : public Botan::Encrypted_PSK_Database
{
std::set<std::string> names;
- for(auto kv : m_vals)
+ for(const auto& kv : m_vals)
{
names.insert(kv.first);
}
diff --git a/src/tests/test_runner.cpp b/src/tests/test_runner.cpp
index 46a34a822..74bd2028c 100644
--- a/src/tests/test_runner.cpp
+++ b/src/tests/test_runner.cpp
@@ -81,7 +81,7 @@ class Testsuite_RNG final : public Botan::RandomNumberGenerator
int Test_Runner::run(const Test_Options& opts)
{
std::vector<std::string> req = opts.requested_tests();
- const std::set<std::string> to_skip = opts.skip_tests();
+ const std::set<std::string>& to_skip = opts.skip_tests();
if(req.empty())
{
@@ -96,7 +96,7 @@ int Test_Runner::run(const Test_Options& opts)
"modes", "kdf", "pbkdf", "hmac_drbg", "util"
};
- for(auto s : default_first)
+ for(const auto& s : default_first)
{
if(to_skip.count(s) == 0)
req.push_back(s);
@@ -120,7 +120,7 @@ int Test_Runner::run(const Test_Options& opts)
}
}
- for(auto f : req)
+ for(const auto& f : req)
{
all_others.erase(f);
}
diff --git a/src/tests/test_tls.cpp b/src/tests/test_tls.cpp
index daaacbe7f..d22b118a2 100644
--- a/src/tests/test_tls.cpp
+++ b/src/tests/test_tls.cpp
@@ -321,7 +321,7 @@ class Test_TLS_Policy_Text : public Test
const std::vector<std::string> policies = { "default", "suiteb_128", "suiteb_192", "strict", "datagram", "bsi" };
- for(std::string policy : policies)
+ for(const std::string& policy : policies)
{
const std::string from_policy_obj = tls_policy_string(policy);
std::string from_file = read_tls_policy(policy);
diff --git a/src/tests/test_tss.cpp b/src/tests/test_tss.cpp
index ffb6d7b31..99dc4f0b5 100644
--- a/src/tests/test_tss.cpp
+++ b/src/tests/test_tss.cpp
@@ -34,6 +34,7 @@ class TSS_Recovery_Tests final : public Text_Based_Test
try
{
std::vector<Botan::RTSS_Share> shares;
+ shares.reserve(expected_shares.size());
for(auto&& v : expected_shares)
{
diff --git a/src/tests/test_utils.cpp b/src/tests/test_utils.cpp
index d080566e7..0923c1b0c 100644
--- a/src/tests/test_utils.cpp
+++ b/src/tests/test_utils.cpp
@@ -447,7 +447,8 @@ class Date_Format_Tests final : public Text_Based_Test
}
std::vector<uint32_t> u32s;
- for(auto const& sub : parts)
+ u32s.reserve(parts.size());
+ for(const auto& sub : parts)
{
u32s.push_back(Botan::to_u32bit(sub));
}
diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp
index f8a70e6a1..68e315adb 100644
--- a/src/tests/tests.cpp
+++ b/src/tests/tests.cpp
@@ -85,7 +85,7 @@ void Test::Result::note_missing(const std::string& whatever)
}
}
-bool Test::Result::test_throws(const std::string& what, std::function<void ()> fn)
+bool Test::Result::test_throws(const std::string& what, const std::function<void ()>& fn)
{
try
{
@@ -102,7 +102,7 @@ bool Test::Result::test_throws(const std::string& what, std::function<void ()> f
}
}
-bool Test::Result::test_throws(const std::string& what, const std::string& expected, std::function<void ()> fn)
+bool Test::Result::test_throws(const std::string& what, const std::string& expected, const std::function<void ()>& fn)
{
try
{
@@ -246,8 +246,8 @@ bool Test::Result::test_eq_sz(const std::string& what, size_t produced, size_t e
}
bool Test::Result::test_eq(const std::string& what,
- Botan::OctetString produced,
- Botan::OctetString expected)
+ const Botan::OctetString& produced,
+ const Botan::OctetString& expected)
{
std::ostringstream out;
out << m_who << " " << what;
@@ -482,7 +482,7 @@ std::map<std::string, std::function<std::unique_ptr<Test> ()>>& Test::global_reg
//static
void Test::register_test(const std::string& category,
const std::string& name,
- std::function<std::unique_ptr<Test> ()> maker_fn)
+ const std::function<std::unique_ptr<Test> ()>& maker_fn)
{
BOTAN_UNUSED(category);
if(Test::global_registry().count(name) != 0)
@@ -1102,7 +1102,7 @@ std::vector<Test::Result> Text_Based_Test::run()
oss << header << " ";
oss << "failed ";
- for(auto k: m_required_keys)
+ for(const auto& k: m_required_keys)
oss << k << "=" << vars.get_req_str(k) << " ";
result.test_note(oss.str());
@@ -1116,7 +1116,7 @@ std::vector<Test::Result> Text_Based_Test::run()
if(!header.empty())
oss << header << " ";
- for(auto k: m_required_keys)
+ for(const auto& k: m_required_keys)
oss << k << "=" << vars.get_req_str(k) << " ";
oss << "failed with exception '" << e.what() << "'";
diff --git a/src/tests/tests.h b/src/tests/tests.h
index d05e22d4f..fc6d330a4 100644
--- a/src/tests/tests.h
+++ b/src/tests/tests.h
@@ -295,8 +295,8 @@ class Test
bool test_eq_sz(const std::string& what, size_t produced, size_t expected);
bool test_eq(const std::string& what,
- Botan::OctetString produced,
- Botan::OctetString expected);
+ const Botan::OctetString& produced,
+ const Botan::OctetString& expected);
template<typename I1, typename I2>
bool test_int_eq(I1 x, I2 y, const char* what)
@@ -415,10 +415,10 @@ class Test
expected.data(), expected.size());
}
- bool test_throws(const std::string& what, std::function<void ()> fn);
+ bool test_throws(const std::string& what, const std::function<void ()>& fn);
bool test_throws(const std::string& what, const std::string& expected,
- std::function<void ()> fn);
+ const std::function<void ()>& fn);
void set_ns_consumed(uint64_t ns)
{
@@ -444,7 +444,7 @@ class Test
static void register_test(const std::string& category,
const std::string& name,
- std::function<std::unique_ptr<Test> ()> maker_fn);
+ const std::function<std::unique_ptr<Test> ()>& maker_fn);
static std::map<std::string, std::function<std::unique_ptr<Test> ()>>& global_registry();
diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp
index 3c9c810d1..acfd5c154 100644
--- a/src/tests/unit_x509.cpp
+++ b/src/tests/unit_x509.cpp
@@ -485,7 +485,7 @@ Test::Result test_rsa_oaep()
auto public_key = cert.load_subject_public_key();
result.test_not_null("Decoding RSA-OAEP worked", public_key.get());
- auto pk_info = cert.subject_public_key_algo();
+ const auto& pk_info = cert.subject_public_key_algo();
result.test_eq("RSA-OAEP OID", pk_info.get_oid().to_string(), Botan::OID::from_string("RSA/OAEP").to_string());
#endif
@@ -1447,7 +1447,7 @@ Test::Result test_custom_dn_attr(const Botan::Private_Key& ca_key,
Test::rng(),
sig_padding);
- Botan::X509_DN req_dn = req.subject_dn();
+ const Botan::X509_DN& req_dn = req.subject_dn();
result.test_eq("Expected number of DN entries", req_dn.dn_info().size(), 2);
@@ -1463,7 +1463,7 @@ Test::Result test_custom_dn_attr(const Botan::Private_Key& ca_key,
auto cert = ca.sign_request(req, Test::rng(), not_before, not_after);
- Botan::X509_DN cert_dn = cert.subject_dn();
+ const Botan::X509_DN& cert_dn = cert.subject_dn();
result.test_eq("Expected number of DN entries", cert_dn.dn_info().size(), 2);
@@ -1663,7 +1663,7 @@ class X509_Cert_Unit_Tests final : public Test
}
results.push_back(usage_result);
- for(auto padding_scheme : Botan::get_sig_paddings(algo))
+ for(const auto& padding_scheme : Botan::get_sig_paddings(algo))
{
Test::Result cert_result("X509 Unit");
try
@@ -1728,7 +1728,7 @@ class X509_Cert_Unit_Tests final : public Test
*/
const std::vector<std::string> enc_algos = { "DH", "ECDH", "ElGamal" };
- for(std::string algo : enc_algos)
+ for(const std::string& algo : enc_algos)
{
std::unique_ptr<Botan::Private_Key> key = make_a_private_key(algo);