summaryrefslogtreecommitdiffstats
path: root/src/PolarSSL++
diff options
context:
space:
mode:
authortycho <work.tycho@gmail.com>2015-05-24 13:56:56 +0200
committertycho <work.tycho@gmail.com>2015-05-24 13:56:56 +0200
commitdae9e5792a4f030ae9e748548a16a89790fbd311 (patch)
tree2142b8c4deb9f2c7ad096b8b0ec93fefccd8d8f1 /src/PolarSSL++
parentMerge branch 'master' into PreventNewWarnings (diff)
downloadcuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.gz
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.bz2
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.lz
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.xz
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.tar.zst
cuberite-dae9e5792a4f030ae9e748548a16a89790fbd311.zip
Diffstat (limited to '')
-rw-r--r--src/PolarSSL++/BufferedSslContext.cpp6
-rw-r--r--src/PolarSSL++/CMakeLists.txt4
-rw-r--r--src/PolarSSL++/CryptoKey.cpp12
-rw-r--r--src/PolarSSL++/CtrDrbgContext.cpp2
-rw-r--r--src/PolarSSL++/SslContext.cpp4
-rw-r--r--src/PolarSSL++/SslContext.h4
-rw-r--r--src/PolarSSL++/X509Cert.cpp2
7 files changed, 19 insertions, 15 deletions
diff --git a/src/PolarSSL++/BufferedSslContext.cpp b/src/PolarSSL++/BufferedSslContext.cpp
index 9f7caeb8a..c8d4736f7 100644
--- a/src/PolarSSL++/BufferedSslContext.cpp
+++ b/src/PolarSSL++/BufferedSslContext.cpp
@@ -66,7 +66,7 @@ int cBufferedSslContext::ReceiveEncrypted(unsigned char * a_Buffer, size_t a_Num
return POLARSSL_ERR_NET_RECV_FAILED;
}
m_IncomingData.CommitRead();
- return (int)NumBytes;
+ return static_cast<int>(NumBytes);
}
@@ -81,11 +81,11 @@ int cBufferedSslContext::SendEncrypted(const unsigned char * a_Buffer, size_t a_
{
return POLARSSL_ERR_NET_WANT_WRITE;
}
- if (!m_OutgoingData.Write((const char *)a_Buffer, a_NumBytes))
+ if (!m_OutgoingData.Write(reinterpret_cast<const char *>(a_Buffer), a_NumBytes))
{
return POLARSSL_ERR_NET_SEND_FAILED;
}
- return (int)a_NumBytes;
+ return static_cast<int>(a_NumBytes);
}
diff --git a/src/PolarSSL++/CMakeLists.txt b/src/PolarSSL++/CMakeLists.txt
index b11d16e33..fddb37501 100644
--- a/src/PolarSSL++/CMakeLists.txt
+++ b/src/PolarSSL++/CMakeLists.txt
@@ -33,6 +33,10 @@ set(HDRS
X509Cert.h
)
+if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ set_source_files_properties(RsaPrivateKey.cpp PROPERTIES COMPILE_FLAGS "-Wno-error=old-style-cast")
+endif()
+
if(NOT MSVC)
add_library(PolarSSL++ ${SRCS} ${HDRS})
diff --git a/src/PolarSSL++/CryptoKey.cpp b/src/PolarSSL++/CryptoKey.cpp
index 9354ddf50..cc4eefdfe 100644
--- a/src/PolarSSL++/CryptoKey.cpp
+++ b/src/PolarSSL++/CryptoKey.cpp
@@ -77,7 +77,7 @@ int cCryptoKey::Decrypt(const Byte * a_EncryptedData, size_t a_EncryptedLength,
{
return res;
}
- return (int)DecryptedLen;
+ return static_cast<int>(DecryptedLen);
}
@@ -97,7 +97,7 @@ int cCryptoKey::Encrypt(const Byte * a_PlainData, size_t a_PlainLength, Byte * a
{
return res;
}
- return (int)EncryptedLength;
+ return static_cast<int>(EncryptedLength);
}
@@ -109,7 +109,7 @@ int cCryptoKey::ParsePublic(const void * a_Data, size_t a_NumBytes)
{
ASSERT(!IsValid()); // Cannot parse a second key
- return pk_parse_public_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes);
+ return pk_parse_public_key(&m_Pk, reinterpret_cast<const unsigned char *>(a_Data), a_NumBytes);
}
@@ -123,14 +123,14 @@ int cCryptoKey::ParsePrivate(const void * a_Data, size_t a_NumBytes, const AStri
if (a_Password.empty())
{
- return pk_parse_key(&m_Pk, (const unsigned char *)a_Data, a_NumBytes, nullptr, 0);
+ return pk_parse_key(&m_Pk, reinterpret_cast<const unsigned char *>(a_Data), a_NumBytes, nullptr, 0);
}
else
{
return pk_parse_key(
&m_Pk,
- (const unsigned char *)a_Data, a_NumBytes,
- (const unsigned char *)a_Password.c_str(), a_Password.size()
+ reinterpret_cast<const unsigned char *>(a_Data), a_NumBytes,
+ reinterpret_cast<const unsigned char *>(a_Password.c_str()), a_Password.size()
);
}
}
diff --git a/src/PolarSSL++/CtrDrbgContext.cpp b/src/PolarSSL++/CtrDrbgContext.cpp
index 86e6d1ca5..25c2987b1 100644
--- a/src/PolarSSL++/CtrDrbgContext.cpp
+++ b/src/PolarSSL++/CtrDrbgContext.cpp
@@ -39,7 +39,7 @@ int cCtrDrbgContext::Initialize(const void * a_Custom, size_t a_CustomSize)
return 0;
}
- int res = ctr_drbg_init(&m_CtrDrbg, entropy_func, &(m_EntropyContext->m_Entropy), (const unsigned char *)a_Custom, a_CustomSize);
+ int res = ctr_drbg_init(&m_CtrDrbg, entropy_func, &(m_EntropyContext->m_Entropy), reinterpret_cast<const unsigned char *>(a_Custom), a_CustomSize);
m_IsValid = (res == 0);
return res;
}
diff --git a/src/PolarSSL++/SslContext.cpp b/src/PolarSSL++/SslContext.cpp
index 5ac4bc227..1409405bc 100644
--- a/src/PolarSSL++/SslContext.cpp
+++ b/src/PolarSSL++/SslContext.cpp
@@ -172,7 +172,7 @@ int cSslContext::WritePlain(const void * a_Data, size_t a_NumBytes)
}
}
- return ssl_write(&m_Ssl, (const unsigned char *)a_Data, a_NumBytes);
+ return ssl_write(&m_Ssl, reinterpret_cast<const unsigned char *>(a_Data), a_NumBytes);
}
@@ -191,7 +191,7 @@ int cSslContext::ReadPlain(void * a_Data, size_t a_MaxBytes)
}
}
- return ssl_read(&m_Ssl, (unsigned char *)a_Data, a_MaxBytes);
+ return ssl_read(&m_Ssl, reinterpret_cast<unsigned char *>(a_Data), a_MaxBytes);
}
diff --git a/src/PolarSSL++/SslContext.h b/src/PolarSSL++/SslContext.h
index 6b4f2c1e7..ce6a2e398 100644
--- a/src/PolarSSL++/SslContext.h
+++ b/src/PolarSSL++/SslContext.h
@@ -127,13 +127,13 @@ protected:
/** The callback used by PolarSSL when it wants to read encrypted data. */
static int ReceiveEncrypted(void * a_This, unsigned char * a_Buffer, size_t a_NumBytes)
{
- return ((cSslContext *)a_This)->ReceiveEncrypted(a_Buffer, a_NumBytes);
+ return (static_cast<cSslContext *>(a_This))->ReceiveEncrypted(a_Buffer, a_NumBytes);
}
/** The callback used by PolarSSL when it wants to write encrypted data. */
static int SendEncrypted(void * a_This, const unsigned char * a_Buffer, size_t a_NumBytes)
{
- return ((cSslContext *)a_This)->SendEncrypted(a_Buffer, a_NumBytes);
+ return (static_cast<cSslContext *>(a_This))->SendEncrypted(a_Buffer, a_NumBytes);
}
#ifdef _DEBUG
diff --git a/src/PolarSSL++/X509Cert.cpp b/src/PolarSSL++/X509Cert.cpp
index ecf664855..ed65639a5 100644
--- a/src/PolarSSL++/X509Cert.cpp
+++ b/src/PolarSSL++/X509Cert.cpp
@@ -30,7 +30,7 @@ cX509Cert::~cX509Cert()
int cX509Cert::Parse(const void * a_CertContents, size_t a_Size)
{
- return x509_crt_parse(&m_Cert, (const unsigned char *)a_CertContents, a_Size);
+ return x509_crt_parse(&m_Cert, reinterpret_cast<const unsigned char *>(a_CertContents), a_Size);
}