diff options
-rw-r--r-- | src/lib/block/camellia/camellia.cpp | 16 | ||||
-rw-r--r-- | src/lib/pubkey/pkcs8.cpp | 2 | ||||
-rw-r--r-- | src/lib/tls/tls_seq_numbers.h | 8 | ||||
-rw-r--r-- | src/lib/tls/tls_version.h | 2 | ||||
-rw-r--r-- | src/lib/utils/ct_utils.h | 12 | ||||
-rw-r--r-- | src/lib/utils/http_util/socket.h | 2 | ||||
-rw-r--r-- | src/lib/utils/loadstor.h | 4 | ||||
-rw-r--r-- | src/lib/x509/x509path.cpp | 4 |
8 files changed, 26 insertions, 24 deletions
diff --git a/src/lib/block/camellia/camellia.cpp b/src/lib/block/camellia/camellia.cpp index c737a0928..ea84fa313 100644 --- a/src/lib/block/camellia/camellia.cpp +++ b/src/lib/block/camellia/camellia.cpp @@ -613,11 +613,11 @@ inline uint64_t F(uint64_t v, uint64_t K) inline uint64_t FL(uint64_t v, uint64_t K) { - uint32_t x1 = (v >> 32); - uint32_t x2 = (v & 0xFFFFFFFF); + uint32_t x1 = static_cast<uint32_t>(v >> 32); + uint32_t x2 = static_cast<uint32_t>(v & 0xFFFFFFFF); - const uint32_t k1 = (K >> 32); - const uint32_t k2 = (K & 0xFFFFFFFF); + const uint32_t k1 = static_cast<uint32_t>(K >> 32); + const uint32_t k2 = static_cast<uint32_t>(K & 0xFFFFFFFF); x2 ^= rotate_left(x1 & k1, 1); x1 ^= (x2 | k2); @@ -627,11 +627,11 @@ inline uint64_t FL(uint64_t v, uint64_t K) inline uint64_t FLINV(uint64_t v, uint64_t K) { - uint32_t x1 = (v >> 32); - uint32_t x2 = (v & 0xFFFFFFFF); + uint32_t x1 = static_cast<uint32_t>(v >> 32); + uint32_t x2 = static_cast<uint32_t>(v & 0xFFFFFFFF); - const uint32_t k1 = (K >> 32); - const uint32_t k2 = (K & 0xFFFFFFFF); + const uint32_t k1 = static_cast<uint32_t>(K >> 32); + const uint32_t k2 = static_cast<uint32_t>(K & 0xFFFFFFFF); x1 ^= (x2 | k2); x2 ^= rotate_left(x1 & k1, 1); diff --git a/src/lib/pubkey/pkcs8.cpp b/src/lib/pubkey/pkcs8.cpp index 59f0c9fa9..fe2470275 100644 --- a/src/lib/pubkey/pkcs8.cpp +++ b/src/lib/pubkey/pkcs8.cpp @@ -303,7 +303,7 @@ load_key(DataSource& source, throw PKCS8_Exception("Unknown algorithm OID: " + alg_id.oid.as_string()); - return std::unique_ptr<Private_Key>(load_private_key(alg_id, pkcs8_key)); + return load_private_key(alg_id, pkcs8_key); } } diff --git a/src/lib/tls/tls_seq_numbers.h b/src/lib/tls/tls_seq_numbers.h index 817b5b6ed..1be280453 100644 --- a/src/lib/tls/tls_seq_numbers.h +++ b/src/lib/tls/tls_seq_numbers.h @@ -36,8 +36,8 @@ class Connection_Sequence_Numbers class Stream_Sequence_Numbers final : public Connection_Sequence_Numbers { public: - void new_read_cipher_state() override { m_read_seq_no = 0; m_read_epoch += 1; } - void new_write_cipher_state() override { m_write_seq_no = 0; m_write_epoch += 1; } + void new_read_cipher_state() override { m_read_seq_no = 0; m_read_epoch++; } + void new_write_cipher_state() override { m_write_seq_no = 0; m_write_epoch++; } uint16_t current_read_epoch() const override { return m_read_epoch; } uint16_t current_write_epoch() const override { return m_write_epoch; } @@ -59,11 +59,11 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers public: Datagram_Sequence_Numbers() { m_write_seqs[0] = 0; } - void new_read_cipher_state() override { m_read_epoch += 1; } + void new_read_cipher_state() override { m_read_epoch++; } void new_write_cipher_state() override { - m_write_epoch += 1; + m_write_epoch++; m_write_seqs[m_write_epoch] = 0; } diff --git a/src/lib/tls/tls_version.h b/src/lib/tls/tls_version.h index dd1d09530..569030085 100644 --- a/src/lib/tls/tls_version.h +++ b/src/lib/tls/tls_version.h @@ -59,7 +59,7 @@ class BOTAN_PUBLIC_API(2,0) Protocol_Version final * @param minor the minor version */ Protocol_Version(uint8_t major, uint8_t minor) : - m_version((static_cast<uint16_t>(major) << 8) | minor) {} + m_version(static_cast<uint16_t>((static_cast<uint16_t>(major) << 8) | minor)) {} /** * @return true if this is a valid protocol version diff --git a/src/lib/utils/ct_utils.h b/src/lib/utils/ct_utils.h index 5d97cb869..0356f9b39 100644 --- a/src/lib/utils/ct_utils.h +++ b/src/lib/utils/ct_utils.h @@ -88,9 +88,11 @@ inline T expand_mask(T x) T r = x; // First fold r down to a single bit for(size_t i = 1; i != sizeof(T)*8; i *= 2) - r |= r >> i; + { + r = r | static_cast<T>(r >> i); + } r &= 1; - r = ~(r - 1); + r = static_cast<T>(~(r - 1)); return r; } @@ -103,7 +105,7 @@ inline T expand_top_bit(T a) template<typename T> inline T select(T mask, T from0, T from1) { - return (from0 & mask) | (from1 & ~mask); + return static_cast<T>((from0 & mask) | (from1 & ~mask)); } template<typename PredT, typename ValT> @@ -115,7 +117,7 @@ inline ValT val_or_zero(PredT pred_val, ValT val) template<typename T> inline T is_zero(T x) { - return ~expand_mask(x); + return static_cast<T>(~expand_mask(x)); } template<typename T> @@ -173,7 +175,7 @@ inline secure_vector<uint8_t> strip_leading_zeros(const uint8_t in[], size_t len for(size_t i = 0; i != length; ++i) { - only_zeros &= CT::is_zero(in[i]); + only_zeros = only_zeros & CT::is_zero<uint8_t>(in[i]); leading_zeros += CT::select<uint8_t>(only_zeros, 1, 0); } diff --git a/src/lib/utils/http_util/socket.h b/src/lib/utils/http_util/socket.h index 78c29f147..4961738ae 100644 --- a/src/lib/utils/http_util/socket.h +++ b/src/lib/utils/http_util/socket.h @@ -33,7 +33,7 @@ class BOTAN_TEST_API Socket /** * The socket will be closed upon destruction */ - virtual ~Socket() {}; + virtual ~Socket() = default; /** * Write to the socket. Blocks until all bytes sent. diff --git a/src/lib/utils/loadstor.h b/src/lib/utils/loadstor.h index affbb9ab6..ca75969fa 100644 --- a/src/lib/utils/loadstor.h +++ b/src/lib/utils/loadstor.h @@ -59,7 +59,7 @@ template<typename T> inline uint8_t get_byte(size_t byte_num, T input) */ inline uint16_t make_uint16(uint8_t i0, uint8_t i1) { - return ((static_cast<uint16_t>(i0) << 8) | i1); + return static_cast<uint16_t>((static_cast<uint16_t>(i0) << 8) | i1); } /** @@ -115,7 +115,7 @@ inline T load_be(const uint8_t in[], size_t off) in += off * sizeof(T); T out = 0; for(size_t i = 0; i != sizeof(T); ++i) - out = (out << 8) | in[i]; + out = static_cast<T>((out << 8) | in[i]); return out; } diff --git a/src/lib/x509/x509path.cpp b/src/lib/x509/x509path.cpp index f34fc0a11..fcc5bf0ba 100644 --- a/src/lib/x509/x509path.cpp +++ b/src/lib/x509/x509path.cpp @@ -217,10 +217,10 @@ PKIX::check_crl(const std::vector<std::shared_ptr<const X509_Certificate>>& cert if(!ca->allowed_usage(CRL_SIGN)) status.insert(Certificate_Status_Code::CA_CERT_NOT_FOR_CRL_ISSUER); - if(validation_time < X509_Time(crls[i]->this_update())) + if(validation_time < crls[i]->this_update()) status.insert(Certificate_Status_Code::CRL_NOT_YET_VALID); - if(validation_time > X509_Time(crls[i]->next_update())) + if(validation_time > crls[i]->next_update()) status.insert(Certificate_Status_Code::CRL_HAS_EXPIRED); if(crls[i]->check_signature(ca->subject_public_key()) == false) |