MCPcopy Create free account
hub / github.com/SIPp/sipp / processIncomingPacket

Method processIncomingPacket

src/jlsrtp.cpp:2158–2296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2156}
2157
2158int JLSRTP::processIncomingPacket(unsigned short SEQ_r,
2159 std::vector<unsigned char> &srtp_packet,
2160 std::vector<unsigned char> &rtp_header,
2161 std::vector<unsigned char> &rtp_payload)
2162{
2163 int rc = 0;
2164 bool check = false;
2165 unsigned long v_r = 0;
2166 unsigned long long i_r = 0LL; /* TEST PACKET INDEX */
2167 std::vector<unsigned char> auth_tag_generated;
2168 std::vector<unsigned char> auth_portion;
2169 std::vector<unsigned char> auth_tag_received;
2170 std::vector<unsigned char> srtp_payload; /* ENCRYPTED PAYLOAD */
2171 int retVal = -1;
2172
2173 rtp_header.clear();
2174 rtp_payload.clear();
2175
2176 // 1. Determine crypto context to use
2177 // NO-OP (IMPLICIT)
2178
2179 // 2. Determine packet index (i) using RoC + _s_l (section 3.3.1)
2180 //std::cout << "[processIncomingPacket] SEQ_r: " << SEQ_r << " current ROC_r: " << _ROC << " current s_l_r: " << _s_l << " ";
2181 v_r = determineV(SEQ_r);
2182 //std::cout << "v_r: " << v_r << " ";
2183 i_r = determinePacketIndex(v_r, SEQ_r);
2184 //std::cout << "i_r: " << i_r << " " << std::endl;
2185
2186 // 3. Determine master key / master salt -- if MKI is 1 then use MKI in packet otherwise use packet index (i) (section 8.1)
2187 // NO-OP -- MASTER KEY / MASTER SALT ASSUMED TO BE UNIQUE WITHIN CONTEXT
2188
2189 // 4. Determine session key / session salt (section 4.3) using master key + master salt + key_derivation_rate + session key-lengths + packet index (i)
2190 // NO-OP -- SESSION KEY / SESSION SALT ALREADY DETERMINED AT THIS POINT
2191
2192 // 5A. Check if packet has been replayed (section 3.3.2) using replay list + packet index (i) -- discard packet if replayed
2193 // NO-OP -- REPLAY LIST NOT USED
2194
2195 // 5B. Verify authentication tag using RoC + authentication algorithm + session authentication key -- if authentication failure (section 4.2) discard packet
2196
2197 rc = extractAuthenticationTag(srtp_packet, auth_tag_received);
2198 if (rc == 0)
2199 {
2200 rc = extractSRTPHeader(srtp_packet, rtp_header);
2201 if (rc == 0)
2202 {
2203 rc = extractSRTPPayload(srtp_packet, srtp_payload);
2204 if (rc == 0)
2205 {
2206 auth_portion.insert(auth_portion.end(), rtp_header.begin(), rtp_header.end());
2207 auth_portion.insert(auth_portion.end(), srtp_payload.begin(), srtp_payload.end());
2208
2209 rc = issueAuthenticationTag(auth_portion, auth_tag_generated);
2210 if (rc == 0)
2211 {
2212 if (auth_tag_received == auth_tag_generated)
2213 {
2214 // 6. Decrypt PAYLOAD (section 4.1) using decryption algorithm + session encryption key + session salting key
2215 //printf("[processIncomingPacket] CIPHERTEXT: [");

Callers 3

rtpstream_playrtptaskFunction · 0.80

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected