aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/tls
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2022-02-04 18:21:11 -0500
committerJack Lloyd <[email protected]>2022-02-06 08:52:17 -0500
commitbfa36e60338538a3563f542e0ac76d21b6ad7019 (patch)
treeeab4f996e829a6f9cbf0b65936a457d7c7dd538c /src/lib/tls
parentfbb7c5fba1bcde2460dda48c1423a23b3b3062bf (diff)
Fix clang-tidy readability-container-size-empty warnings
Diffstat (limited to 'src/lib/tls')
-rw-r--r--src/lib/tls/msg_cert_req.cpp2
-rw-r--r--src/lib/tls/msg_certificate.cpp2
-rw-r--r--src/lib/tls/msg_client_hello.cpp8
-rw-r--r--src/lib/tls/msg_client_kex.cpp2
-rw-r--r--src/lib/tls/msg_server_hello.cpp2
-rw-r--r--src/lib/tls/msg_server_kex.cpp2
-rw-r--r--src/lib/tls/tls_channel.cpp2
-rw-r--r--src/lib/tls/tls_ciphersuite.cpp6
-rw-r--r--src/lib/tls/tls_client.cpp2
-rw-r--r--src/lib/tls/tls_extensions.cpp4
-rw-r--r--src/lib/tls/tls_handshake_io.cpp4
-rw-r--r--src/lib/tls/tls_record.cpp4
-rw-r--r--src/lib/tls/tls_server.cpp10
13 files changed, 25 insertions, 25 deletions
diff --git a/src/lib/tls/msg_cert_req.cpp b/src/lib/tls/msg_cert_req.cpp
index ea9ae3711..a621c9c39 100644
--- a/src/lib/tls/msg_cert_req.cpp
+++ b/src/lib/tls/msg_cert_req.cpp
@@ -124,7 +124,7 @@ std::vector<uint8_t> Certificate_Req::serialize() const
append_tls_length_value(buf, cert_types, 1);
- if(m_schemes.size() > 0)
+ if(!m_schemes.empty())
buf += Signature_Algorithms(m_schemes).serialize(Connection_Side::SERVER);
std::vector<uint8_t> encoded_names;
diff --git a/src/lib/tls/msg_certificate.cpp b/src/lib/tls/msg_certificate.cpp
index b49ffeb3d..3815c981a 100644
--- a/src/lib/tls/msg_certificate.cpp
+++ b/src/lib/tls/msg_certificate.cpp
@@ -72,7 +72,7 @@ Certificate::Certificate(const std::vector<uint8_t>& buf, const Policy& policy)
* the intermediates are outside of the control of the server.
* But, require that the leaf certificate be v3
*/
- if(m_certs.size() > 0 && m_certs[0].x509_version() != 3)
+ if(!m_certs.empty() && m_certs[0].x509_version() != 3)
{
throw TLS_Exception(Alert::BAD_CERTIFICATE,
"The leaf certificate must be v3");
diff --git a/src/lib/tls/msg_client_hello.cpp b/src/lib/tls/msg_client_hello.cpp
index f04b80989..9d7b09f61 100644
--- a/src/lib/tls/msg_client_hello.cpp
+++ b/src/lib/tls/msg_client_hello.cpp
@@ -63,7 +63,7 @@ Hello_Request::Hello_Request(Handshake_IO& io)
*/
Hello_Request::Hello_Request(const std::vector<uint8_t>& buf)
{
- if(buf.size())
+ if(!buf.empty())
throw Decoding_Error("Bad Hello_Request, has non-zero size");
}
@@ -109,7 +109,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
m_extensions.add(new Supported_Versions(m_version, policy));
- if(client_settings.hostname() != "")
+ if(!client_settings.hostname().empty())
m_extensions.add(new Server_Name_Indicator(client_settings.hostname()));
if(policy.support_cert_status_message())
@@ -125,7 +125,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
auto supported_groups = std::make_unique<Supported_Groups>(policy.key_exchange_groups());
- if(supported_groups->ec_groups().size() > 0)
+ if(!supported_groups->ec_groups().empty())
{
m_extensions.add(new Supported_Point_Formats(policy.use_ecc_point_compression()));
}
@@ -177,7 +177,7 @@ Client_Hello::Client_Hello(Handshake_IO& io,
auto supported_groups = std::make_unique<Supported_Groups>(policy.key_exchange_groups());
- if(supported_groups->ec_groups().size() > 0)
+ if(!supported_groups->ec_groups().empty())
{
m_extensions.add(new Supported_Point_Formats(policy.use_ecc_point_compression()));
}
diff --git a/src/lib/tls/msg_client_kex.cpp b/src/lib/tls/msg_client_kex.cpp
index 469463bf1..f768e48b6 100644
--- a/src/lib/tls/msg_client_kex.cpp
+++ b/src/lib/tls/msg_client_kex.cpp
@@ -120,7 +120,7 @@ Client_Key_Exchange::Client_Key_Exchange(Handshake_IO& io,
const std::string curve_name = state.callbacks().tls_decode_group_param(curve_id);
- if(curve_name == "")
+ if(curve_name.empty())
throw Decoding_Error("Server sent unknown named curve " +
std::to_string(static_cast<uint16_t>(curve_id)));
diff --git a/src/lib/tls/msg_server_hello.cpp b/src/lib/tls/msg_server_hello.cpp
index 9122ce523..a6e9c600e 100644
--- a/src/lib/tls/msg_server_hello.cpp
+++ b/src/lib/tls/msg_server_hello.cpp
@@ -222,7 +222,7 @@ Server_Hello_Done::Server_Hello_Done(Handshake_IO& io,
*/
Server_Hello_Done::Server_Hello_Done(const std::vector<uint8_t>& buf)
{
- if(buf.size())
+ if(!buf.empty())
throw Decoding_Error("Server_Hello_Done: Must be empty, and is not");
}
diff --git a/src/lib/tls/msg_server_kex.cpp b/src/lib/tls/msg_server_kex.cpp
index f022d953d..bf3b2da8b 100644
--- a/src/lib/tls/msg_server_kex.cpp
+++ b/src/lib/tls/msg_server_kex.cpp
@@ -232,7 +232,7 @@ std::vector<uint8_t> Server_Key_Exchange::serialize() const
{
std::vector<uint8_t> buf = params();
- if(m_signature.size())
+ if(!m_signature.empty())
{
if(m_scheme != Signature_Scheme::NONE)
{
diff --git a/src/lib/tls/tls_channel.cpp b/src/lib/tls/tls_channel.cpp
index bdf124767..c96ee8916 100644
--- a/src/lib/tls/tls_channel.cpp
+++ b/src/lib/tls/tls_channel.cpp
@@ -706,7 +706,7 @@ SymmetricKey Channel::key_material_export(const std::string& label,
salt += active->client_hello()->random();
salt += active->server_hello()->random();
- if(context != "")
+ if(!context.empty())
{
size_t context_size = context.length();
if(context_size > 0xFFFF)
diff --git a/src/lib/tls/tls_ciphersuite.cpp b/src/lib/tls/tls_ciphersuite.cpp
index 4adec977e..0a6426a1d 100644
--- a/src/lib/tls/tls_ciphersuite.cpp
+++ b/src/lib/tls/tls_ciphersuite.cpp
@@ -118,13 +118,13 @@ namespace {
bool have_hash(const std::string& prf)
{
- return (HashFunction::providers(prf).size() > 0);
+ return (!HashFunction::providers(prf).empty());
}
bool have_cipher(const std::string& cipher)
{
- return (BlockCipher::providers(cipher).size() > 0) ||
- (StreamCipher::providers(cipher).size() > 0);
+ return (!BlockCipher::providers(cipher).empty()) ||
+ (!StreamCipher::providers(cipher).empty());
}
}
diff --git a/src/lib/tls/tls_client.cpp b/src/lib/tls/tls_client.cpp
index 479bfd5c5..fa3ee3e1c 100644
--- a/src/lib/tls/tls_client.cpp
+++ b/src/lib/tls/tls_client.cpp
@@ -718,7 +718,7 @@ void Client::process_handshake_msg(const Handshake_State* active_state,
const bool should_save = save_session(session_info);
- if(session_id.size() > 0 && state.is_a_resumption() == false)
+ if(!session_id.empty() && state.is_a_resumption() == false)
{
if(should_save)
session_manager().save(session_info);
diff --git a/src/lib/tls/tls_extensions.cpp b/src/lib/tls/tls_extensions.cpp
index 792ebb5fc..d6d2bf55c 100644
--- a/src/lib/tls/tls_extensions.cpp
+++ b/src/lib/tls/tls_extensions.cpp
@@ -265,7 +265,7 @@ std::vector<uint8_t> Application_Layer_Protocol_Notification::serialize(Connecti
{
if(p.length() >= 256)
throw TLS_Exception(Alert::INTERNAL_ERROR, "ALPN name too long");
- if(p != "")
+ if(!p.empty())
append_tls_length_value(buf,
cast_char_ptr_to_uint8(p.data()),
p.size(),
@@ -557,7 +557,7 @@ std::vector<uint8_t> Supported_Versions::serialize(Connection_Side whoami) const
}
else
{
- BOTAN_ASSERT_NOMSG(m_versions.size() >= 1);
+ BOTAN_ASSERT_NOMSG(!m_versions.empty());
const uint8_t len = static_cast<uint8_t>(m_versions.size() * 2);
buf.push_back(len);
diff --git a/src/lib/tls/tls_handshake_io.cpp b/src/lib/tls/tls_handshake_io.cpp
index 04dc1fe49..b2370036d 100644
--- a/src/lib/tls/tls_handshake_io.cpp
+++ b/src/lib/tls/tls_handshake_io.cpp
@@ -106,7 +106,7 @@ Stream_Handshake_IO::format(const std::vector<uint8_t>& msg,
store_be24(&send_buf[1], buf_size);
- if (msg.size() > 0)
+ if (!msg.empty())
{
copy_mem(&send_buf[4], msg.data(), msg.size());
}
@@ -149,7 +149,7 @@ void Datagram_Handshake_IO::retransmit_flight(size_t flight_idx)
{
const std::vector<uint16_t>& flight = m_flights.at(flight_idx);
- BOTAN_ASSERT(flight.size() > 0, "Nonempty flight to retransmit");
+ BOTAN_ASSERT(!flight.empty(), "Nonempty flight to retransmit");
uint16_t epoch = m_flight_data[flight[0]].epoch;
diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp
index fbf8879a4..ffe91afe8 100644
--- a/src/lib/tls/tls_record.cpp
+++ b/src/lib/tls/tls_record.cpp
@@ -89,7 +89,7 @@ std::vector<uint8_t> Connection_Cipher_State::aead_nonce(uint64_t seq, RandomNum
{
case Nonce_Format::CBC_MODE:
{
- if(m_nonce.size())
+ if(!m_nonce.empty())
{
std::vector<uint8_t> nonce;
nonce.swap(m_nonce);
@@ -126,7 +126,7 @@ Connection_Cipher_State::aead_nonce(const uint8_t record[], size_t record_len, u
{
case Nonce_Format::CBC_MODE:
{
- if(nonce_bytes_from_record() == 0 && m_nonce.size())
+ if(nonce_bytes_from_record() == 0 && !m_nonce.empty())
{
std::vector<uint8_t> nonce;
nonce.swap(m_nonce);
diff --git a/src/lib/tls/tls_server.cpp b/src/lib/tls/tls_server.cpp
index 6dc1ba9f2..fb56126b0 100644
--- a/src/lib/tls/tls_server.cpp
+++ b/src/lib/tls/tls_server.cpp
@@ -105,7 +105,7 @@ bool check_for_resume(Session& session_info,
return false;
// client sent a different SNI hostname
- if(client_hello->sni_hostname() != "")
+ if(!client_hello->sni_hostname().empty())
{
if(client_hello->sni_hostname() != session_info.server_info().hostname())
return false;
@@ -288,7 +288,7 @@ std::vector<X509_Certificate>
Server::get_peer_cert_chain(const Handshake_State& state_base) const
{
const Server_Handshake_State& state = dynamic_cast<const Server_Handshake_State&>(state_base);
- if(state.resume_peer_certs().size() > 0)
+ if(!state.resume_peer_certs().empty())
return state.resume_peer_certs();
if(state.client_certs())
@@ -320,7 +320,7 @@ Protocol_Version select_version(const Botan::TLS::Policy& policy,
const Protocol_Version latest_supported = policy.latest_supported_version(is_datagram);
- if(supported_versions.size() > 0)
+ if(!supported_versions.empty())
{
if(is_datagram)
{
@@ -818,7 +818,7 @@ void Server::session_create(Server_Handshake_State& pending_state,
cert_chains = get_server_certs(sni_hostname, m_creds);
- if(sni_hostname != "" && cert_chains.empty())
+ if(!sni_hostname.empty() && cert_chains.empty())
{
cert_chains = get_server_certs("", m_creds);
@@ -878,7 +878,7 @@ void Server::session_create(Server_Handshake_State& pending_state,
// csr is non-null if client_hello()->supports_cert_status_message()
BOTAN_ASSERT_NOMSG(csr != nullptr);
const auto resp_bytes = callbacks().tls_provide_cert_status(cert_chains[algo_used], *csr);
- if(resp_bytes.size() > 0)
+ if(!resp_bytes.empty())
{
pending_state.server_cert_status(new Certificate_Status(
pending_state.handshake_io(),