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

Method processOutgoingPacket

src/jlsrtp.cpp:2055–2156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2053}
2054
2055int JLSRTP::processOutgoingPacket(unsigned short SEQ_s,
2056 std::vector<unsigned char> &rtp_header,
2057 std::vector<unsigned char> &rtp_payload,
2058 std::vector<unsigned char> &srtp_packet)
2059{
2060 int rc = 0;
2061 bool check = false;
2062 unsigned long v_s = 0;
2063 unsigned long long i_s = 0LL; /* TEST PACKET INDEX */
2064 std::vector<unsigned char> srtp_payload; /* ENCRYPTED PAYLOAD */
2065 std::vector<unsigned char> auth_tag;
2066 std::vector<unsigned char> auth_portion;
2067 int retVal = -1;
2068
2069 // 1. Determine crypto context to use
2070 // NO-OP (IMPLICIT)
2071
2072 // 2. Determine packet index (i) using RoC + _s_l + SEQ (section 3.3.1)
2073 //std::cout << "[processOutgoingPacket] SEQ_s: " << SEQ_s << " current ROC_s: " << _ROC << " current s_l_s: " << _s_l << " ";
2074 v_s = determineV(SEQ_s);
2075 //std::cout << "v_s: " << v_s << " ";
2076 i_s = determinePacketIndex(v_s, SEQ_s);
2077 //std::cout << "i_s: " << i_s << std::endl;
2078
2079 // 3. Determine master key / master salt using packet index (i) OR MKI (section 8.1)
2080 // NO-OP -- MASTER KEY / MASTER SALT ASSUMED TO BE UNIQUE WITHIN CONTEXT
2081
2082 // 4. Determine session key / session salt (section 4.3) using master key + master salt + key_derivation_rate + session key-lengths + packet index (i)
2083 // NO-OP -- SESSION KEY / SESSION SALT ALREADY DETERMINED AT THIS POINT
2084
2085 // 5. Encrypt PAYLOAD to produce encrypted portion (section 4.1) using encryption algorithm + session encryption key + session salting key + packet index (i)
2086 rc = computePacketIV(i_s);
2087 if (rc == 0)
2088 {
2089 rc = setPacketIV();
2090 if (rc == 0)
2091 {
2092 rc = encryptVector(rtp_payload, srtp_payload);
2093 if (rc == 0)
2094 {
2095 //printf("[processOutgoingPacket] CIPHERTEXT: [");
2096 //for (unsigned int i = 0; i < srtp_payload.size(); i++) {
2097 // printf("%02x", srtp_payload[i]);
2098 //}
2099 //printf("]\n");
2100
2101 auth_portion.insert(auth_portion.end(), rtp_header.begin(), rtp_header.end());
2102 auth_portion.insert(auth_portion.end(), srtp_payload.begin(), srtp_payload.end());
2103
2104 // 6. If MKI is 1 then append MKI to packet
2105 // NO-OP -- MKI NOT USED
2106
2107 // 7A. Compute authentication tag from authenticated portion of the packet (section 4.2) using RoC + authentication algorithm + session authentication key
2108 rc = issueAuthenticationTag(auth_portion, auth_tag);
2109 if (rc == 0)
2110 {
2111 // 7B. Append authentication tag to the packet to produce encrypted+authenticated portion
2112 srtp_packet.clear();

Callers 3

rtpstream_playrtptaskFunction · 0.80

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected