aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli')
-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
10 files changed, 30 insertions, 32 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)
{