Skip to content

Commit

Permalink
Fixed problems with encryption decision and status report on encrypti…
Browse files Browse the repository at this point in the history
…on failure. (#318)
  • Loading branch information
ethouris authored and rndi committed Apr 4, 2018
1 parent ff98b0d commit 1a28026
Show file tree
Hide file tree
Showing 11 changed files with 465 additions and 258 deletions.
2 changes: 2 additions & 0 deletions apps/socketoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ SocketOption::Mode SrtConfigurePre(SRTSOCKET socket, string host, map<string, st

if ( options.count("passphrase") )
{
/*
// Insert default
if ( options.count("pbkeylen") == 0 )
{
options["pbkeylen"] = "16"; // m_output_direction ? "16" : "0";
}
*/
}

SocketOption::Mode mode;
Expand Down
13 changes: 11 additions & 2 deletions srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ int CSndBuffer::addBufferFromFile(fstream& ifs, int len)
return total;
}

int CSndBuffer::readData(char** data, int32_t& msgno_bitset, uint64_t& srctime, unsigned kflgs)
int CSndBuffer::readData(char** data, int32_t& msgno_bitset, uint64_t& srctime, int kflgs)
{
// No data to read
if (m_pCurrBlock == m_pLastBlock)
Expand Down Expand Up @@ -383,7 +383,16 @@ int CSndBuffer::readData(char** data, int32_t& msgno_bitset, uint64_t& srctime,
// extracting from here, but when the packet is stored into CSndBuffer. The appropriate
// flags for PH_MSGNO will be applied directly there. Then here the value for setting
// PH_MSGNO will be set as is.
m_pCurrBlock->m_iMsgNoBitset |= MSGNO_ENCKEYSPEC::wrap(kflgs);

if (kflgs == -1)
{
HLOGC(dlog.Debug, log << CONID() << " CSndBuffer: ERROR: encryption required and not possible. NOT SENDING.");
readlen = 0;
}
else
{
m_pCurrBlock->m_iMsgNoBitset |= MSGNO_ENCKEYSPEC::wrap(kflgs);
}
msgno_bitset = m_pCurrBlock->m_iMsgNoBitset;

srctime =
Expand Down
2 changes: 1 addition & 1 deletion srtcore/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CSndBuffer
/// @param [in] kflags Odd|Even crypto key flag
/// @return Actual length of data read.

int readData(char** data, int32_t& msgno, uint64_t& origintime, unsigned kflgs);
int readData(char** data, int32_t& msgno, uint64_t& origintime, int kflgs);


/// Find data position to pack a DATA packet for a retransmission.
Expand Down
312 changes: 214 additions & 98 deletions srtcore/core.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions srtcore/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ class CUDT
EConnectStatus processAsyncConnectResponse(const CPacket& pkt) ATR_NOEXCEPT;
bool processAsyncConnectRequest(EConnectStatus cst, const CPacket& response, const sockaddr* serv_addr);

void checkUpdateCryptoKeyLen(const char* loghdr, int32_t typefield);

size_t fillSrtHandshake_HSREQ(uint32_t* srtdata, size_t srtlen, int hs_version);
size_t fillSrtHandshake_HSRSP(uint32_t* srtdata, size_t srtlen, int hs_version);
Expand Down Expand Up @@ -535,6 +536,7 @@ class CUDT

// XXX Consider removing them. The m_bDataSender may stay here
// in order to maintain the HS side selection in HSv4.
// m_bTwoWayData is unused.
bool m_bDataSender;
bool m_bTwoWayData;

Expand Down
Loading

0 comments on commit 1a28026

Please sign in to comment.