summaryrefslogtreecommitdiff
path: root/modules/mbedtls
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /modules/mbedtls
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'modules/mbedtls')
-rw-r--r--modules/mbedtls/crypto_mbedtls.cpp1
-rw-r--r--modules/mbedtls/crypto_mbedtls.h3
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.cpp2
-rw-r--r--modules/mbedtls/dtls_server_mbedtls.h1
-rw-r--r--modules/mbedtls/packet_peer_mbed_dtls.cpp15
-rw-r--r--[-rwxr-xr-x]modules/mbedtls/register_types.cpp2
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.cpp1
-rw-r--r--modules/mbedtls/ssl_context_mbedtls.h2
-rw-r--r--modules/mbedtls/stream_peer_mbedtls.cpp18
9 files changed, 0 insertions, 45 deletions
diff --git a/modules/mbedtls/crypto_mbedtls.cpp b/modules/mbedtls/crypto_mbedtls.cpp
index a47a4503a5..1f9d8c2aa3 100644
--- a/modules/mbedtls/crypto_mbedtls.cpp
+++ b/modules/mbedtls/crypto_mbedtls.cpp
@@ -155,7 +155,6 @@ Crypto *CryptoMbedTLS::create() {
}
void CryptoMbedTLS::initialize_crypto() {
-
#ifdef DEBUG_ENABLED
mbedtls_debug_set_threshold(1);
#endif
diff --git a/modules/mbedtls/crypto_mbedtls.h b/modules/mbedtls/crypto_mbedtls.h
index db3d00a5e3..48855d082a 100644
--- a/modules/mbedtls/crypto_mbedtls.h
+++ b/modules/mbedtls/crypto_mbedtls.h
@@ -41,7 +41,6 @@
class CryptoMbedTLS;
class SSLContextMbedTLS;
class CryptoKeyMbedTLS : public CryptoKey {
-
private:
mbedtls_pk_context pkey;
int locks;
@@ -70,7 +69,6 @@ public:
};
class X509CertificateMbedTLS : public X509Certificate {
-
private:
mbedtls_x509_crt cert;
int locks;
@@ -100,7 +98,6 @@ public:
};
class CryptoMbedTLS : public Crypto {
-
private:
mbedtls_entropy_context entropy;
mbedtls_ctr_drbg_context ctr_drbg;
diff --git a/modules/mbedtls/dtls_server_mbedtls.cpp b/modules/mbedtls/dtls_server_mbedtls.cpp
index f31f067f4e..d9961b026f 100644
--- a/modules/mbedtls/dtls_server_mbedtls.cpp
+++ b/modules/mbedtls/dtls_server_mbedtls.cpp
@@ -54,12 +54,10 @@ Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_
}
DTLSServer *DTLSServerMbedTLS::_create_func() {
-
return memnew(DTLSServerMbedTLS);
}
void DTLSServerMbedTLS::initialize() {
-
_create = _create_func;
available = true;
}
diff --git a/modules/mbedtls/dtls_server_mbedtls.h b/modules/mbedtls/dtls_server_mbedtls.h
index d61ab3179e..d93553bf7f 100644
--- a/modules/mbedtls/dtls_server_mbedtls.h
+++ b/modules/mbedtls/dtls_server_mbedtls.h
@@ -35,7 +35,6 @@
#include "ssl_context_mbedtls.h"
class DTLSServerMbedTLS : public DTLSServer {
-
private:
static DTLSServer *_create_func();
Ref<CryptoKey> _key;
diff --git a/modules/mbedtls/packet_peer_mbed_dtls.cpp b/modules/mbedtls/packet_peer_mbed_dtls.cpp
index 37477e1246..210c9877df 100644
--- a/modules/mbedtls/packet_peer_mbed_dtls.cpp
+++ b/modules/mbedtls/packet_peer_mbed_dtls.cpp
@@ -35,7 +35,6 @@
#include "core/os/file_access.h"
int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
-
if (buf == nullptr || len <= 0)
return 0;
@@ -53,7 +52,6 @@ int PacketPeerMbedDTLS::bio_send(void *ctx, const unsigned char *buf, size_t len
}
int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
-
if (buf == nullptr || len <= 0)
return 0;
@@ -79,7 +77,6 @@ int PacketPeerMbedDTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
}
void PacketPeerMbedDTLS::_cleanup() {
-
ssl_ctx->clear();
base = Ref<PacketPeer>();
status = STATUS_DISCONNECTED;
@@ -116,7 +113,6 @@ Error PacketPeerMbedDTLS::_do_handshake() {
}
Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_validate_certs, const String &p_for_hostname, Ref<X509Certificate> p_ca_certs) {
-
ERR_FAIL_COND_V(!p_base.is_valid() || !p_base->is_connected_to_host(), ERR_INVALID_PARAMETER);
base = p_base;
@@ -141,7 +137,6 @@ Error PacketPeerMbedDTLS::connect_to_peer(Ref<PacketPeerUDP> p_base, bool p_vali
}
Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain, Ref<CookieContextMbedTLS> p_cookies) {
-
Error err = ssl_ctx->init_server(MBEDTLS_SSL_TRANSPORT_DATAGRAM, MBEDTLS_SSL_VERIFY_NONE, p_key, p_cert, p_cookies);
ERR_FAIL_COND_V(err != OK, err);
@@ -170,7 +165,6 @@ Error PacketPeerMbedDTLS::accept_peer(Ref<PacketPeerUDP> p_base, Ref<CryptoKey>
}
Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
if (p_bytes == 0)
@@ -189,7 +183,6 @@ Error PacketPeerMbedDTLS::put_packet(const uint8_t *p_buffer, int p_bytes) {
}
Error PacketPeerMbedDTLS::get_packet(const uint8_t **r_buffer, int &r_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
r_bytes = 0;
@@ -215,7 +208,6 @@ Error PacketPeerMbedDTLS::get_packet(const uint8_t **r_buffer, int &r_bytes) {
}
void PacketPeerMbedDTLS::poll() {
-
if (status == STATUS_HANDSHAKING) {
_do_handshake();
return;
@@ -240,19 +232,16 @@ void PacketPeerMbedDTLS::poll() {
}
int PacketPeerMbedDTLS::get_available_packet_count() const {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, 0);
return mbedtls_ssl_get_bytes_avail(&(ssl_ctx->ssl)) > 0 ? 1 : 0;
}
int PacketPeerMbedDTLS::get_max_packet_size() const {
-
return 488; // 512 (UDP in Godot) - 24 (DTLS header)
}
PacketPeerMbedDTLS::PacketPeerMbedDTLS() {
-
ssl_ctx.instance();
status = STATUS_DISCONNECTED;
}
@@ -262,7 +251,6 @@ PacketPeerMbedDTLS::~PacketPeerMbedDTLS() {
}
void PacketPeerMbedDTLS::disconnect_from_peer() {
-
if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
return;
@@ -278,17 +266,14 @@ void PacketPeerMbedDTLS::disconnect_from_peer() {
}
PacketPeerMbedDTLS::Status PacketPeerMbedDTLS::get_status() const {
-
return status;
}
PacketPeerDTLS *PacketPeerMbedDTLS::_create_func() {
-
return memnew(PacketPeerMbedDTLS);
}
void PacketPeerMbedDTLS::initialize_dtls() {
-
_create = _create_func;
available = true;
}
diff --git a/modules/mbedtls/register_types.cpp b/modules/mbedtls/register_types.cpp
index d39af7fe87..84a27c29bd 100755..100644
--- a/modules/mbedtls/register_types.cpp
+++ b/modules/mbedtls/register_types.cpp
@@ -36,7 +36,6 @@
#include "stream_peer_mbedtls.h"
void register_mbedtls_types() {
-
CryptoMbedTLS::initialize_crypto();
StreamPeerMbedTLS::initialize_ssl();
PacketPeerMbedDTLS::initialize_dtls();
@@ -44,7 +43,6 @@ void register_mbedtls_types() {
}
void unregister_mbedtls_types() {
-
DTLSServerMbedTLS::finalize();
PacketPeerMbedDTLS::finalize_dtls();
StreamPeerMbedTLS::finalize_ssl();
diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp
index 1ffb9bda05..b0ca4a9e44 100644
--- a/modules/mbedtls/ssl_context_mbedtls.cpp
+++ b/modules/mbedtls/ssl_context_mbedtls.cpp
@@ -33,7 +33,6 @@
static void my_debug(void *ctx, int level,
const char *file, int line,
const char *str) {
-
printf("%s:%04d: %s", file, line, str);
fflush(stdout);
}
diff --git a/modules/mbedtls/ssl_context_mbedtls.h b/modules/mbedtls/ssl_context_mbedtls.h
index d3e1f87a8e..baaeb6eb85 100644
--- a/modules/mbedtls/ssl_context_mbedtls.h
+++ b/modules/mbedtls/ssl_context_mbedtls.h
@@ -47,7 +47,6 @@
class SSLContextMbedTLS;
class CookieContextMbedTLS : public Reference {
-
friend class SSLContextMbedTLS;
protected:
@@ -65,7 +64,6 @@ public:
};
class SSLContextMbedTLS : public Reference {
-
protected:
bool inited;
diff --git a/modules/mbedtls/stream_peer_mbedtls.cpp b/modules/mbedtls/stream_peer_mbedtls.cpp
index af36b29dac..0be473b97e 100644
--- a/modules/mbedtls/stream_peer_mbedtls.cpp
+++ b/modules/mbedtls/stream_peer_mbedtls.cpp
@@ -34,7 +34,6 @@
#include "core/os/file_access.h"
int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len) {
-
if (buf == nullptr || len <= 0)
return 0;
@@ -54,7 +53,6 @@ int StreamPeerMbedTLS::bio_send(void *ctx, const unsigned char *buf, size_t len)
}
int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
-
if (buf == nullptr || len <= 0)
return 0;
@@ -74,7 +72,6 @@ int StreamPeerMbedTLS::bio_recv(void *ctx, unsigned char *buf, size_t len) {
}
void StreamPeerMbedTLS::_cleanup() {
-
ssl_ctx->clear();
base = Ref<StreamPeer>();
status = STATUS_DISCONNECTED;
@@ -104,7 +101,6 @@ Error StreamPeerMbedTLS::_do_handshake() {
}
Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_validate_certs, const String &p_for_hostname, Ref<X509Certificate> p_ca_certs) {
-
ERR_FAIL_COND_V(p_base.is_null(), ERR_INVALID_PARAMETER);
base = p_base;
@@ -127,7 +123,6 @@ Error StreamPeerMbedTLS::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida
}
Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base, Ref<CryptoKey> p_key, Ref<X509Certificate> p_cert, Ref<X509Certificate> p_ca_chain) {
-
ERR_FAIL_COND_V(p_base.is_null(), ERR_INVALID_PARAMETER);
Error err = ssl_ctx->init_server(MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_VERIFY_NONE, p_key, p_cert);
@@ -147,7 +142,6 @@ Error StreamPeerMbedTLS::accept_stream(Ref<StreamPeer> p_base, Ref<CryptoKey> p_
return OK;
}
Error StreamPeerMbedTLS::put_data(const uint8_t *p_data, int p_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
Error err;
@@ -168,7 +162,6 @@ Error StreamPeerMbedTLS::put_data(const uint8_t *p_data, int p_bytes) {
}
Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
r_sent = 0;
@@ -195,14 +188,12 @@ Error StreamPeerMbedTLS::put_partial_data(const uint8_t *p_data, int p_bytes, in
}
Error StreamPeerMbedTLS::get_data(uint8_t *p_buffer, int p_bytes) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
Error err;
int got = 0;
while (p_bytes > 0) {
-
err = get_partial_data(p_buffer, p_bytes, got);
if (err != OK) {
@@ -217,7 +208,6 @@ Error StreamPeerMbedTLS::get_data(uint8_t *p_buffer, int p_bytes) {
}
Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_UNCONFIGURED);
r_received = 0;
@@ -240,7 +230,6 @@ Error StreamPeerMbedTLS::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r
}
void StreamPeerMbedTLS::poll() {
-
ERR_FAIL_COND(status != STATUS_CONNECTED && status != STATUS_HANDSHAKING);
ERR_FAIL_COND(!base.is_valid());
@@ -274,13 +263,11 @@ void StreamPeerMbedTLS::poll() {
}
int StreamPeerMbedTLS::get_available_bytes() const {
-
ERR_FAIL_COND_V(status != STATUS_CONNECTED, 0);
return mbedtls_ssl_get_bytes_avail(&(ssl_ctx->ssl));
}
StreamPeerMbedTLS::StreamPeerMbedTLS() {
-
ssl_ctx.instance();
status = STATUS_DISCONNECTED;
}
@@ -290,7 +277,6 @@ StreamPeerMbedTLS::~StreamPeerMbedTLS() {
}
void StreamPeerMbedTLS::disconnect_from_stream() {
-
if (status != STATUS_CONNECTED && status != STATUS_HANDSHAKING)
return;
@@ -304,23 +290,19 @@ void StreamPeerMbedTLS::disconnect_from_stream() {
}
StreamPeerMbedTLS::Status StreamPeerMbedTLS::get_status() const {
-
return status;
}
StreamPeerSSL *StreamPeerMbedTLS::_create_func() {
-
return memnew(StreamPeerMbedTLS);
}
void StreamPeerMbedTLS::initialize_ssl() {
-
_create = _create_func;
available = true;
}
void StreamPeerMbedTLS::finalize_ssl() {
-
available = false;
_create = nullptr;
}