simplify buffer handling in rc4_decrypt calls

This commit is contained in:
arvidn 2017-08-22 23:34:56 +02:00 committed by Arvid Norberg
parent 22c047f8a0
commit 1290e6f5af
1 changed files with 5 additions and 12 deletions

View File

@ -2754,10 +2754,8 @@ namespace {
if (!m_recv_buffer.packet_finished()) return;
// TODO: 3 this is weird buffer handling
span<char> const buf = m_recv_buffer.mutable_buffer();
TORRENT_ASSERT(int(buf.size()) >= m_recv_buffer.packet_size());
rc4_decrypt({buf.data(), size_t(m_recv_buffer.packet_size())});
rc4_decrypt(m_recv_buffer.mutable_buffer().first(
size_t(m_recv_buffer.packet_size())));
recv_buffer = m_recv_buffer.get();
@ -2861,10 +2859,8 @@ namespace {
int const pad_size = is_outgoing() ? m_recv_buffer.packet_size() : m_recv_buffer.packet_size() - 2;
// TODO: 3 this is weird buffer handling
span<char> const buf = m_recv_buffer.mutable_buffer();
TORRENT_ASSERT(int(buf.size()) >= m_recv_buffer.packet_size());
rc4_decrypt({buf.data(), size_t(m_recv_buffer.packet_size())});
rc4_decrypt(m_recv_buffer.mutable_buffer().first(
size_t(m_recv_buffer.packet_size())));
recv_buffer = m_recv_buffer.get();
@ -2922,10 +2918,7 @@ namespace {
if (!m_recv_buffer.packet_finished()) return;
// ia is always rc4, so decrypt it
// TODO: 3 this is weird buffer handling
span<char> const buf = m_recv_buffer.mutable_buffer();
TORRENT_ASSERT(int(buf.size()) >= m_recv_buffer.packet_size());
rc4_decrypt({buf.data(), size_t(m_recv_buffer.packet_size())});
rc4_decrypt(m_recv_buffer.mutable_buffer().first(size_t(m_recv_buffer.packet_size())));
#ifndef TORRENT_DISABLE_LOGGING
peer_log(peer_log_alert::info, "ENCRYPTION"