| 1183 | } |
| 1184 | |
| 1185 | bool V2Transport::ProcessReceivedGarbageBytes() noexcept |
| 1186 | { |
| 1187 | AssertLockHeld(m_recv_mutex); |
| 1188 | Assume(m_recv_state == RecvState::GARB_GARBTERM); |
| 1189 | Assume(m_recv_buffer.size() <= MAX_GARBAGE_LEN + BIP324Cipher::GARBAGE_TERMINATOR_LEN); |
| 1190 | if (m_recv_buffer.size() >= BIP324Cipher::GARBAGE_TERMINATOR_LEN) { |
| 1191 | if (std::ranges::equal(MakeByteSpan(m_recv_buffer).last(BIP324Cipher::GARBAGE_TERMINATOR_LEN), m_cipher.GetReceiveGarbageTerminator())) { |
| 1192 | // Garbage terminator received. Store garbage to authenticate it as AAD later. |
| 1193 | m_recv_aad = std::move(m_recv_buffer); |
| 1194 | m_recv_aad.resize(m_recv_aad.size() - BIP324Cipher::GARBAGE_TERMINATOR_LEN); |
| 1195 | m_recv_buffer.clear(); |
| 1196 | SetReceiveState(RecvState::VERSION); |
| 1197 | } else if (m_recv_buffer.size() == MAX_GARBAGE_LEN + BIP324Cipher::GARBAGE_TERMINATOR_LEN) { |
| 1198 | // We've reached the maximum length for garbage + garbage terminator, and the |
| 1199 | // terminator still does not match. Abort. |
| 1200 | LogDebug(BCLog::NET, "V2 transport error: missing garbage terminator, peer=%d\n", m_nodeid); |
| 1201 | return false; |
| 1202 | } else { |
| 1203 | // We still need to receive more garbage and/or garbage terminator bytes. |
| 1204 | } |
| 1205 | } else { |
| 1206 | // We have less than GARBAGE_TERMINATOR_LEN (16) bytes, so we certainly need to receive |
| 1207 | // more first. |
| 1208 | } |
| 1209 | return true; |
| 1210 | } |
| 1211 | |
| 1212 | bool V2Transport::ProcessReceivedPacketBytes() noexcept |
| 1213 | { |
nothing calls this directly
no test coverage detected