Skip to content
Snippets Groups Projects
Unverified Commit a2207056 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

tlssession: Rx buffer should not use the MTU as the max size

The MTU is not symetric, so the other device can send messages
larger than the local MTU (or don't use any MTU). The Rx buffer
should use the maximum size of a UDP packet (64k) instead the MTU.

Change-Id: I1ef6f17b041b25dc6a364c237527efe84927e6db
Gitlab: #14
parent ca174511
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ static constexpr const char* DTLS_CERT_PRIORITY_STRING {"SECURE192:-VERS-TLS-ALL
static constexpr const char* DTLS_FULL_PRIORITY_STRING {"SECURE192:-KX-ALL:+ANON-ECDH:+ANON-DH:+SECURE192:-VERS-TLS-ALL:+VERS-DTLS-ALL:-RSA:%SERVER_PRECEDENCE:%SAFE_RENEGOTIATION"};
static constexpr const char* TLS_CERT_PRIORITY_STRING {"SECURE192:-RSA:%SERVER_PRECEDENCE:%SAFE_RENEGOTIATION"};
static constexpr const char* TLS_FULL_PRIORITY_STRING {"SECURE192:-KX-ALL:+ANON-ECDH:+ANON-DH:+SECURE192:-RSA:%SERVER_PRECEDENCE:%SAFE_RENEGOTIATION"};
static constexpr uint16_t INPUT_BUFFER_SIZE {16*1024}; // to be coherent with the maximum size advised in path mtu discovery
static constexpr uint32_t RX_MAX_SIZE {64*1024}; // 64k = max size of a UDP packet
static constexpr std::size_t INPUT_MAX_SIZE {1000}; // Maximum number of packets to store before dropping (pkt size = DTLS_MTU)
static constexpr ssize_t FLOOD_THRESHOLD {4*1024};
static constexpr auto FLOOD_PAUSE = std::chrono::milliseconds(100); // Time to wait after an invalid cookie packet (anti flood attack)
......@@ -1118,7 +1118,7 @@ TlsSession::TlsSessionImpl::handleStateEstablished(TlsSessionState state)
}
std::array<uint8_t, 8> seq;
rawPktBuf_.resize(maxPayload_);
rawPktBuf_.resize(RX_MAX_SIZE);
auto ret = gnutls_record_recv_seq(session_, rawPktBuf_.data(), rawPktBuf_.size(), &seq[0]);
if (ret > 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment