aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp4
-rw-r--r--src/lib/prov/pkcs11/p11.h47
-rw-r--r--src/lib/prov/pkcs11/p11_mechanism.h4
-rw-r--r--src/lib/prov/pkcs11/p11_randomgenerator.cpp4
-rw-r--r--src/lib/rng/system_rng/system_rng.cpp2
-rw-r--r--src/lib/tls/tls_cbc/tls_cbc.cpp4
-rw-r--r--src/lib/utils/mem_pool/mem_pool.cpp2
-rw-r--r--src/lib/utils/os_utils.cpp9
-rw-r--r--src/lib/x509/x509_ext.cpp2
-rw-r--r--src/lib/x509/x509path.cpp4
10 files changed, 53 insertions, 29 deletions
diff --git a/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp b/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
index 3f2c564c8..1cd07c490 100644
--- a/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
+++ b/src/lib/pbkdf/pgp_s2k/pgp_s2k.cpp
@@ -20,7 +20,7 @@ uint8_t RFC4880_encode_count(size_t desired_iterations)
for(size_t c = 0; c < 256; ++c)
{
// TODO could binary search
- const uint32_t decoded_iter = RFC4880_decode_count(c);
+ const size_t decoded_iter = RFC4880_decode_count(static_cast<uint8_t>(c));
if(decoded_iter >= desired_iterations)
return static_cast<uint8_t>(c);
}
@@ -178,7 +178,7 @@ std::unique_ptr<PasswordHash> RFC4880_S2K_Family::tune(size_t output_len, std::c
const size_t blocks_required = (output_len <= hash_size ? 1 : (output_len + hash_size - 1) / hash_size);
const double bytes_to_be_hashed = (hash_bytes_per_second * (desired_nsec / 1000000000.0)) / blocks_required;
- const size_t iterations = RFC4880_round_iterations(bytes_to_be_hashed);
+ const size_t iterations = RFC4880_round_iterations(static_cast<size_t>(bytes_to_be_hashed));
return std::unique_ptr<PasswordHash>(new RFC4880_S2K(m_hash->clone(), iterations));
}
diff --git a/src/lib/prov/pkcs11/p11.h b/src/lib/prov/pkcs11/p11.h
index a1f85af45..dfd89bb0f 100644
--- a/src/lib/prov/pkcs11/p11.h
+++ b/src/lib/prov/pkcs11/p11.h
@@ -1156,8 +1156,11 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
padded_label.insert(padded_label.end(), 32 - label.size(), ' ');
}
- return C_InitToken(slot_id, reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(so_pin.data())),
- so_pin.size(), reinterpret_cast< Utf8Char* >(const_cast< char* >(padded_label.c_str())), return_value);
+ return C_InitToken(slot_id,
+ reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(so_pin.data())),
+ static_cast<Ulong>(so_pin.size()),
+ reinterpret_cast< Utf8Char* >(const_cast< char* >(padded_label.c_str())),
+ return_value);
}
/**
@@ -1252,8 +1255,10 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
ReturnValue* return_value = ThrowException) const
{
return C_SetPIN(session,
- reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(old_pin.data())), old_pin.size(),
- reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(new_pin.data())), new_pin.size(),
+ reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(old_pin.data())),
+ static_cast<Ulong>(old_pin.size()),
+ reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(new_pin.data())),
+ static_cast<Ulong>(new_pin.size()),
return_value);
}
@@ -1423,7 +1428,9 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
const std::vector<uint8_t, TAlloc>& pin,
ReturnValue* return_value = ThrowException) const
{
- return C_Login(session, user_type, reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(pin.data())), pin.size(),
+ return C_Login(session, user_type,
+ reinterpret_cast< Utf8Char* >(const_cast< uint8_t* >(pin.data())),
+ static_cast<Ulong>(pin.size()),
return_value);
}
@@ -1583,8 +1590,11 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
getter_template.emplace_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(entry.first), nullptr, 0 });
}
- bool success = C_GetAttributeValue(session, object, const_cast< Attribute* >(getter_template.data()),
- getter_template.size(), return_value);
+ bool success = C_GetAttributeValue(session,
+ object,
+ const_cast< Attribute* >(getter_template.data()),
+ static_cast<Ulong>(getter_template.size()),
+ return_value);
if(!success)
{
@@ -1600,7 +1610,9 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
i++;
}
- return C_GetAttributeValue(session, object, const_cast< Attribute* >(getter_template.data()), getter_template.size(),
+ return C_GetAttributeValue(session, object,
+ const_cast< Attribute* >(getter_template.data()),
+ static_cast<Ulong>(getter_template.size()),
return_value);
}
@@ -1658,7 +1670,9 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
setter_template.emplace_back(Attribute{ static_cast< CK_ATTRIBUTE_TYPE >(entry.first), entry.second.data(), static_cast<CK_ULONG>(entry.second.size()) });
}
- return C_SetAttributeValue(session, object, const_cast< Attribute* >(setter_template.data()), setter_template.size(),
+ return C_SetAttributeValue(session, object,
+ const_cast< Attribute* >(setter_template.data()),
+ static_cast<Ulong>(setter_template.size()),
return_value);
}
@@ -1790,7 +1804,10 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
ReturnValue* return_value = ThrowException) const
{
Ulong encrypted_size = 0;
- if(!C_Encrypt(session, const_cast<Byte*>((plaintext_data.data())), plaintext_data.size(), nullptr, &encrypted_size,
+ if(!C_Encrypt(session,
+ const_cast<Byte*>((plaintext_data.data())),
+ static_cast<Ulong>(plaintext_data.size()),
+ nullptr, &encrypted_size,
return_value))
{
return false;
@@ -1917,7 +1934,10 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
ReturnValue* return_value = ThrowException) const
{
Ulong decrypted_size = 0;
- if(!C_Decrypt(session, const_cast<Byte*>((encrypted_data.data())), encrypted_data.size(), nullptr, &decrypted_size,
+ if(!C_Decrypt(session,
+ const_cast<Byte*>((encrypted_data.data())),
+ static_cast<Ulong>(encrypted_data.size()),
+ nullptr, &decrypted_size,
return_value))
{
return false;
@@ -2197,7 +2217,10 @@ class BOTAN_PUBLIC_API(2,0) LowLevel
const std::vector<uint8_t, TAlloc>& part,
ReturnValue* return_value = ThrowException) const
{
- return C_SignUpdate(session, const_cast<Byte*>(part.data()), part.size(), return_value);
+ return C_SignUpdate(session,
+ const_cast<Byte*>(part.data()),
+ static_cast<Ulong>(part.size()),
+ return_value);
}
/**
diff --git a/src/lib/prov/pkcs11/p11_mechanism.h b/src/lib/prov/pkcs11/p11_mechanism.h
index 80f2f8ec9..035d1e69a 100644
--- a/src/lib/prov/pkcs11/p11_mechanism.h
+++ b/src/lib/prov/pkcs11/p11_mechanism.h
@@ -66,7 +66,7 @@ class MechanismWrapper final
inline void set_ecdh_salt(const uint8_t salt[], size_t salt_len)
{
m_parameters->ecdh_params.pSharedData = const_cast<uint8_t*>(salt);
- m_parameters->ecdh_params.ulSharedDataLen = salt_len;
+ m_parameters->ecdh_params.ulSharedDataLen = static_cast<Ulong>(salt_len);
}
/**
@@ -77,7 +77,7 @@ class MechanismWrapper final
inline void set_ecdh_other_key(const uint8_t other_key[], size_t other_key_len)
{
m_parameters->ecdh_params.pPublicData = const_cast<uint8_t*>(other_key);
- m_parameters->ecdh_params.ulPublicDataLen = other_key_len;
+ m_parameters->ecdh_params.ulPublicDataLen = static_cast<Ulong>(other_key_len);
}
/// @return a pointer to the CK_MECHANISM struct that can be passed to the cryptoki functions
diff --git a/src/lib/prov/pkcs11/p11_randomgenerator.cpp b/src/lib/prov/pkcs11/p11_randomgenerator.cpp
index 957a33cae..2f4e4c2ec 100644
--- a/src/lib/prov/pkcs11/p11_randomgenerator.cpp
+++ b/src/lib/prov/pkcs11/p11_randomgenerator.cpp
@@ -18,12 +18,12 @@ PKCS11_RNG::PKCS11_RNG(Session& session)
void PKCS11_RNG::randomize(uint8_t output[], std::size_t length)
{
- module()->C_GenerateRandom(m_session.get().handle(), output, length);
+ module()->C_GenerateRandom(m_session.get().handle(), output, Ulong(length));
}
void PKCS11_RNG::add_entropy(const uint8_t in[], std::size_t length)
{
- module()->C_SeedRandom(m_session.get().handle(), const_cast<uint8_t*>(in), length);
+ module()->C_SeedRandom(m_session.get().handle(), const_cast<uint8_t*>(in), Ulong(length));
}
}
diff --git a/src/lib/rng/system_rng/system_rng.cpp b/src/lib/rng/system_rng/system_rng.cpp
index aa7858d4a..ae027d021 100644
--- a/src/lib/rng/system_rng/system_rng.cpp
+++ b/src/lib/rng/system_rng/system_rng.cpp
@@ -48,7 +48,7 @@ class System_RNG_Impl final : public RandomNumberGenerator
void randomize(uint8_t buf[], size_t len) override
{
- bool success = m_rtlgenrandom(buf, len) == TRUE;
+ bool success = m_rtlgenrandom(buf, ULONG(len)) == TRUE;
if(!success)
throw Exception("RtlGenRandom failed");
}
diff --git a/src/lib/tls/tls_cbc/tls_cbc.cpp b/src/lib/tls/tls_cbc/tls_cbc.cpp
index a745a548b..23127642d 100644
--- a/src/lib/tls/tls_cbc/tls_cbc.cpp
+++ b/src/lib/tls/tls_cbc/tls_cbc.cpp
@@ -141,7 +141,7 @@ void TLS_CBC_HMAC_AEAD_Encryption::set_associated_data(const uint8_t ad[], size_
{
// AAD hack for EtM
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());
+ const uint16_t enc_size = static_cast<uint16_t>(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);
}
@@ -231,7 +231,7 @@ uint16_t check_tls_cbc_padding(const uint8_t record[], size_t record_len)
* and allows up to 255 bytes.
*/
- const uint16_t to_check = std::min<uint16_t>(256, record_len);
+ const uint16_t to_check = std::min<uint16_t>(256, static_cast<uint16_t>(record_len));
const uint8_t pad_byte = record[record_len-1];
const uint16_t pad_bytes = 1 + pad_byte;
diff --git a/src/lib/utils/mem_pool/mem_pool.cpp b/src/lib/utils/mem_pool/mem_pool.cpp
index d25343383..e052c10e7 100644
--- a/src/lib/utils/mem_pool/mem_pool.cpp
+++ b/src/lib/utils/mem_pool/mem_pool.cpp
@@ -63,7 +63,7 @@ Memory_Pool::Memory_Pool(uint8_t* pool,
void* Memory_Pool::allocate(size_t req)
{
- const size_t alignment = (1 << m_align_bit);
+ const size_t alignment = (static_cast<size_t>(1) << m_align_bit);
if(req > m_pool_size)
return nullptr;
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index 7d50dac77..86e5443c3 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -216,20 +216,21 @@ uint64_t OS::get_system_timestamp_ns()
size_t OS::system_page_size()
{
+ const size_t default_page_size = 4096;
+
#if defined(BOTAN_TARGET_OS_HAS_POSIX1)
long p = ::sysconf(_SC_PAGESIZE);
if(p > 1)
return static_cast<size_t>(p);
else
- return 4096;
+ return default_page_size;
#elif defined(BOTAN_TARGET_OS_HAS_VIRTUAL_LOCK)
SYSTEM_INFO sys_info;
::GetSystemInfo(&sys_info);
return sys_info.dwPageSize;
+#else
+ return default_page_size;
#endif
-
- // default value
- return 4096;
}
size_t OS::get_memory_locking_limit()
diff --git a/src/lib/x509/x509_ext.cpp b/src/lib/x509/x509_ext.cpp
index 841adac57..97c291f6e 100644
--- a/src/lib/x509/x509_ext.cpp
+++ b/src/lib/x509/x509_ext.cpp
@@ -99,7 +99,7 @@ Extensions::create_extn_obj(const OID& oid,
{
extn->decode_inner(body);
}
- catch(Decoding_Error& e)
+ catch(Decoding_Error&)
{
extn.reset(new Cert_Extension::Unknown_Extension(oid, critical));
extn->decode_inner(body);
diff --git a/src/lib/x509/x509path.cpp b/src/lib/x509/x509path.cpp
index e73fe12b6..8e459e9d2 100644
--- a/src/lib/x509/x509path.cpp
+++ b/src/lib/x509/x509path.cpp
@@ -389,7 +389,7 @@ PKIX::check_ocsp_online(const std::vector<std::shared_ptr<const X509_Certificate
/*redirects*/1,
timeout);
}
- catch(std::exception& e)
+ catch(std::exception&)
{
// log e.what() ?
}
@@ -476,7 +476,7 @@ PKIX::check_crl_online(const std::vector<std::shared_ptr<const X509_Certificate>
{
crls[i] = future_crls[i].get();
}
- catch(std::exception& e)
+ catch(std::exception&)
{
// crls[i] left null
// todo: log exception e.what() ?