aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffi/ffi_kdf.cpp2
-rw-r--r--src/lib/hash/par_hash/par_hash.cpp2
-rw-r--r--src/lib/misc/rfc3394/rfc3394.cpp4
-rw-r--r--src/lib/modes/aead/ccm/ccm.cpp5
-rw-r--r--src/lib/passhash/bcrypt/bcrypt.cpp2
-rw-r--r--src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp4
-rw-r--r--src/lib/pubkey/mce/mce_workfactor.cpp2
-rw-r--r--src/lib/pubkey/pbes2/pbes2.cpp4
-rw-r--r--src/lib/pubkey/xmss/xmss_verification_operation.cpp2
-rw-r--r--src/lib/tls/tls_cbc/tls_cbc.cpp10
-rw-r--r--src/lib/tls/tls_seq_numbers.h2
11 files changed, 20 insertions, 19 deletions
diff --git a/src/lib/ffi/ffi_kdf.cpp b/src/lib/ffi/ffi_kdf.cpp
index 4eca31773..1a4c40893 100644
--- a/src/lib/ffi/ffi_kdf.cpp
+++ b/src/lib/ffi/ffi_kdf.cpp
@@ -72,7 +72,7 @@ int botan_bcrypt_generate(uint8_t* out, size_t* out_len,
if(flags != 0)
return BOTAN_FFI_ERROR_BAD_FLAG;
- if(wf < 2 || wf > 30)
+ if(wf < 4 || wf > 18)
throw FFI_Error("Bad bcrypt work factor " + std::to_string(wf));
Botan::RandomNumberGenerator& rng = safe_get(rng_obj);
diff --git a/src/lib/hash/par_hash/par_hash.cpp b/src/lib/hash/par_hash/par_hash.cpp
index af43d6d97..a0297dfe8 100644
--- a/src/lib/hash/par_hash/par_hash.cpp
+++ b/src/lib/hash/par_hash/par_hash.cpp
@@ -18,7 +18,7 @@ void Parallel::add_data(const uint8_t input[], size_t length)
void Parallel::final_result(uint8_t out[])
{
- uint32_t offset = 0;
+ size_t offset = 0;
for(auto&& hash : m_hashes)
{
diff --git a/src/lib/misc/rfc3394/rfc3394.cpp b/src/lib/misc/rfc3394/rfc3394.cpp
index 2ec49ac65..3bb792723 100644
--- a/src/lib/misc/rfc3394/rfc3394.cpp
+++ b/src/lib/misc/rfc3394/rfc3394.cpp
@@ -39,7 +39,7 @@ secure_vector<uint8_t> rfc3394_keywrap(const secure_vector<uint8_t>& key,
{
for(size_t i = 1; i <= n; ++i)
{
- const uint32_t t = (n * j) + i;
+ const uint32_t t = static_cast<uint32_t>((n * j) + i);
copy_mem(&A[8], &R[8*i], 8);
@@ -84,7 +84,7 @@ secure_vector<uint8_t> rfc3394_keyunwrap(const secure_vector<uint8_t>& key,
{
for(size_t i = n; i != 0; --i)
{
- const uint32_t t = (5 - j) * n + i;
+ const uint32_t t = static_cast<uint32_t>((5 - j) * n + i);
uint8_t t_buf[4] = { 0 };
store_be(t, t_buf);
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp
index db0d2d58b..b7f81e5ab 100644
--- a/src/lib/modes/aead/ccm/ccm.cpp
+++ b/src/lib/modes/aead/ccm/ccm.cpp
@@ -136,7 +136,8 @@ secure_vector<uint8_t> CCM_Mode::format_b0(size_t sz)
{
secure_vector<uint8_t> B0(CCM_BS);
- const uint8_t b_flags = (m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1);
+ const uint8_t b_flags =
+ static_cast<uint8_t>((m_ad_buf.size() ? 64 : 0) + (((tag_size()/2)-1) << 3) + (L()-1));
B0[0] = b_flags;
copy_mem(&B0[1], m_nonce.data(), m_nonce.size());
@@ -149,7 +150,7 @@ secure_vector<uint8_t> CCM_Mode::format_c0()
{
secure_vector<uint8_t> C(CCM_BS);
- const uint8_t a_flags = L()-1;
+ const uint8_t a_flags = static_cast<uint8_t>(L() - 1);
C[0] = a_flags;
copy_mem(&C[1], m_nonce.data(), m_nonce.size());
diff --git a/src/lib/passhash/bcrypt/bcrypt.cpp b/src/lib/passhash/bcrypt/bcrypt.cpp
index 8cea34a97..4f3cda2ae 100644
--- a/src/lib/passhash/bcrypt/bcrypt.cpp
+++ b/src/lib/passhash/bcrypt/bcrypt.cpp
@@ -138,7 +138,7 @@ bool check_bcrypt(const std::string& pass, const std::string& hash)
return false;
}
- const uint16_t workfactor = to_u32bit(hash.substr(4, 2));
+ const uint16_t workfactor = to_uint16(hash.substr(4, 2));
const std::vector<uint8_t> salt = bcrypt_base64_decode(hash.substr(7, 22));
if(salt.size() != 16)
diff --git a/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp b/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
index 21edb6afc..f298bb3e4 100644
--- a/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
+++ b/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
@@ -57,9 +57,9 @@ uint8_t OpenPGP_S2K::encode_count(size_t desired_iterations)
*/
for(size_t c = 0; c < 256; ++c)
{
- size_t decoded_iter = OPENPGP_S2K_ITERS[c];
+ const uint32_t decoded_iter = OPENPGP_S2K_ITERS[c];
if(decoded_iter >= desired_iterations)
- return c;
+ return static_cast<uint8_t>(c);
}
return 255;
diff --git a/src/lib/pubkey/mce/mce_workfactor.cpp b/src/lib/pubkey/mce/mce_workfactor.cpp
index 51cfcc269..f1dddeee9 100644
--- a/src/lib/pubkey/mce/mce_workfactor.cpp
+++ b/src/lib/pubkey/mce/mce_workfactor.cpp
@@ -106,7 +106,7 @@ size_t mceliece_work_factor(size_t n, size_t t)
min = std::min(min, lwf);
}
- return min;
+ return static_cast<size_t>(min);
}
}
diff --git a/src/lib/pubkey/pbes2/pbes2.cpp b/src/lib/pubkey/pbes2/pbes2.cpp
index b0a7f336d..6bc7a23c3 100644
--- a/src/lib/pubkey/pbes2/pbes2.cpp
+++ b/src/lib/pubkey/pbes2/pbes2.cpp
@@ -125,7 +125,7 @@ pbes2_encrypt(const secure_vector<uint8_t>& key_bits,
const std::string& digest,
RandomNumberGenerator& rng)
{
- size_t msec_in_iterations_out = msec.count();
+ size_t msec_in_iterations_out = static_cast<size_t>(msec.count());
return pbes2_encrypt_shared(key_bits, passphrase, &msec_in_iterations_out, 0, cipher, digest, rng);
// return value msec_in_iterations_out discarded
}
@@ -139,7 +139,7 @@ pbes2_encrypt_msec(const secure_vector<uint8_t>& key_bits,
const std::string& digest,
RandomNumberGenerator& rng)
{
- size_t msec_in_iterations_out = msec.count();
+ size_t msec_in_iterations_out = static_cast<size_t>(msec.count());
auto ret = pbes2_encrypt_shared(key_bits, passphrase, &msec_in_iterations_out, 0, cipher, digest, rng);
diff --git a/src/lib/pubkey/xmss/xmss_verification_operation.cpp b/src/lib/pubkey/xmss/xmss_verification_operation.cpp
index fe712d4c8..5f8c3a721 100644
--- a/src/lib/pubkey/xmss/xmss_verification_operation.cpp
+++ b/src/lib/pubkey/xmss/xmss_verification_operation.cpp
@@ -117,7 +117,7 @@ bool XMSS_Verification_Operation::is_valid_signature(const uint8_t sig[],
m_msg_buf.clear();
return result;
}
- catch(Integrity_Failure& e)
+ catch(Integrity_Failure&)
{
m_msg_buf.clear();
return false;
diff --git a/src/lib/tls/tls_cbc/tls_cbc.cpp b/src/lib/tls/tls_cbc/tls_cbc.cpp
index 9e178a457..e63893d75 100644
--- a/src/lib/tls/tls_cbc/tls_cbc.cpp
+++ b/src/lib/tls/tls_cbc/tls_cbc.cpp
@@ -134,8 +134,8 @@ void TLS_CBC_HMAC_AEAD_Encryption::set_associated_data(const uint8_t ad[], size_
if(use_encrypt_then_mac())
{
// AAD hack for EtM
- size_t pt_size = make_uint16(assoc_data()[11], assoc_data()[12]);
- size_t enc_size = round_up(iv_size() + pt_size + 1, block_size());
+ const uint16_t pt_size = make_uint16(assoc_data()[11], assoc_data()[12]);
+ const uint16_t enc_size = round_up(iv_size() + pt_size + 1, block_size());
assoc_data()[11] = get_byte<uint16_t>(0, enc_size);
assoc_data()[12] = get_byte<uint16_t>(1, enc_size);
}
@@ -344,11 +344,11 @@ void TLS_CBC_HMAC_AEAD_Decryption::perform_additional_compressions(size_t plen,
max_bytes_in_first_block = 55;
}
// number of maximum MACed bytes
- const uint16_t L1 = 13 + plen - tag_size();
+ const uint16_t L1 = static_cast<uint16_t>(13 + plen - tag_size());
// number of current MACed bytes (L1 - padlen)
// Here the Lucky 13 paper is different because the padlen length in the paper
// does not count the last message byte.
- const uint16_t L2 = 13 + plen - padlen - tag_size();
+ const uint16_t L2 = static_cast<uint16_t>(13 + plen - padlen - tag_size());
// From the paper, for SHA-256/SHA-1 compute: ceil((L1-55)/64) and ceil((L2-55)/64)
// ceil((L1-55)/64) = floor((L1+64-1-55)/64)
// Here we compute number of compressions for SHA-* in general
@@ -416,7 +416,7 @@ void TLS_CBC_HMAC_AEAD_Decryption::finish(secure_vector<uint8_t>& buffer, size_t
}
const uint8_t* plaintext_block = &record_contents[0];
- const uint16_t plaintext_length = enc_size - pad_size;
+ const size_t plaintext_length = enc_size - pad_size;
buffer.insert(buffer.end(), plaintext_block, plaintext_block + plaintext_length);
}
diff --git a/src/lib/tls/tls_seq_numbers.h b/src/lib/tls/tls_seq_numbers.h
index ece329494..c5741b998 100644
--- a/src/lib/tls/tls_seq_numbers.h
+++ b/src/lib/tls/tls_seq_numbers.h
@@ -102,7 +102,7 @@ class Datagram_Sequence_Numbers final : public Connection_Sequence_Numbers
if(sequence > m_window_highest)
{
- const size_t offset = sequence - m_window_highest;
+ const uint64_t offset = sequence - m_window_highest;
m_window_highest += offset;
if(offset >= window_size)