Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug: packetfilter configuration did not include AUTH tag when AEAD is on #2880

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5649,6 +5649,14 @@ bool srt::CUDT::prepareConnectionObjects(const CHandShake &hs, HandshakeSide hsd
return true;
}

int srt::CUDT::getAuthTagSize() const
{
if (m_pCryptoControl && m_pCryptoControl->getCryptoMode() == CSrtConfig::CIPHER_MODE_AES_GCM)
return HAICRYPT_AUTHTAG_MAX;

return 0;
}

bool srt::CUDT::prepareBuffers(CUDTException* eout)
{
if (m_pSndBuffer)
Expand All @@ -5660,7 +5668,7 @@ bool srt::CUDT::prepareBuffers(CUDTException* eout)
try
{
// CryptoControl has to be initialized and in case of RESPONDER the KM REQ must be processed (interpretSrtHandshake(..)) for the crypto mode to be deduced.
const int authtag = (m_pCryptoControl && m_pCryptoControl->getCryptoMode() == CSrtConfig::CIPHER_MODE_AES_GCM) ? HAICRYPT_AUTHTAG_MAX : 0;
const int authtag = getAuthTagSize();

SRT_ASSERT(m_iMaxSRTPayloadSize != 0);

Expand Down
1 change: 1 addition & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ class CUDT
/// Allocates sender and receiver buffers and loss lists.
SRT_ATR_NODISCARD SRT_ATTR_REQUIRES(m_ConnectionLock)
bool prepareBuffers(CUDTException* eout);
int getAuthTagSize() const;

SRT_ATR_NODISCARD SRT_ATTR_REQUIRES(m_ConnectionLock)
EConnectStatus postConnect(const CPacket* response, bool rendezvous, CUDTException* eout) ATR_NOEXCEPT;
Expand Down
3 changes: 3 additions & 0 deletions srtcore/fec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ void FECFilterBuiltin::ClipData(Group& g, uint16_t length_net, uint8_t kflg,
g.flag_clip = g.flag_clip ^ kflg;
g.timestamp_clip = g.timestamp_clip ^ timestamp_hw;

HLOGC(pflog.Debug, log << "FEC CLIP: data pkt.size=" << payload_size
<< " to a clip buffer size=" << payloadSize());

// Payload goes "as is".
for (size_t i = 0; i < payload_size; ++i)
{
Expand Down
8 changes: 7 additions & 1 deletion srtcore/packetfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,15 @@ bool srt::PacketFilter::configure(CUDT* parent, CUnitQueue* uq, const std::strin
init.socket_id = parent->socketID();
init.snd_isn = parent->sndSeqNo();
init.rcv_isn = parent->rcvSeqNo();
init.payload_size = parent->OPT_PayloadSize();

// XXX This is a formula for a full "SRT payload" part that undergoes transmission,
// might be nice to have this formula as something more general.
init.payload_size = parent->OPT_PayloadSize() + parent->getAuthTagSize();
init.rcvbuf_size = parent->m_config.iRcvBufSize;

HLOGC(pflog.Debug, log << "PFILTER: @" << init.socket_id << " payload size="
<< init.payload_size << " rcvbuf size=" << init.rcvbuf_size);

// Found a filter, so call the creation function
m_filter = selector->second->Create(init, m_provided, confstr);
if (!m_filter)
Expand Down
2 changes: 1 addition & 1 deletion srtcore/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ class UniquePtr: public std::auto_ptr<T>
bool operator==(const element_type* two) const { return get() == two; }
bool operator!=(const element_type* two) const { return get() != two; }

operator bool () { return 0!= get(); }
operator bool () const { return 0!= get(); }
};

// A primitive one-argument versions of Sprint and Printable
Expand Down
Loading