As implied by the use of the word "double" above, this transform applies AES-GCM to the SRTP packet twice. This allows media distributors to be able to modify some header fields while allowing endpoints to verify the end-to-end integrity of a packet.
The first, "inner" application of AES-GCM encrypts the SRTP payload and protects the integrity of a version of the SRTP header with extensions truncated. Omitting extensions from the inner integrity check means that they can be modified by an MD holding only the outer key.
The second, "outer" application of AES-GCM encrypts the ciphertext produced by the inner encryption (i.e., the encrypted payload and authentication tag), plus an OHB that expresses any changes made between the inner and outer transforms.
An MD that has the outer key but not the inner key may modify the header fields that can be included in the OHB by decrypting, modifying, and re-encrypting the packet.
An endpoint encrypts a packet by using the inner (end-to-end) cryptographic key and then the outer (hop-by-hop) cryptographic key. The encryption also supports a mode for repair packets that only does the outer (hop-by-hop) encryption. The processes is as follows:
-
Form an RTP packet. If there are any header extensions, they MUST use [RFC 8285].
-
If the packet is for repair mode data, skip to step 6.
-
Form a synthetic RTP packet with the following contents:
-
Header: The RTP header of the original packet with the following modifications:
-
The X bit is set to zero.
-
The header is truncated to remove any extensions (i.e., keep only the first 12 + 4 * CSRC count (CC) bytes of the header).
-
Payload: The RTP payload of the original packet (including padding when present).
-
Apply the inner cryptographic algorithm to the synthetic RTP packet from the previous step.
-
Replace the header of the protected RTP packet with the header of the original packet (to restore any header extensions and reset the X bit), and append an empty OHB (0x00) to the encrypted payload (with the authentication tag) obtained from step 4.
-
Apply the outer cryptographic algorithm to the RTP packet. If encrypting RTP header extensions hop-by-hop, then [RFC 6904] MUST be used when encrypting the RTP packet using the outer cryptographic key.
When using Encrypted Key Transport (EKT) [
EKT-SRTP], the EKTField comes after the SRTP packet, exactly like using EKT with any other SRTP transform.
The MD has the part of the key for the outer (hop-by-hop) cryptographic algorithm, but it does not have the part of the key for the inner (end-to-end) cryptographic algorithm. The cryptographic algorithm and key used to decrypt a packet and any encrypted RTP header extensions would be the same as those used in the endpoint's outer algorithm and key.
In order to modify a packet, the MD decrypts the received packet, modifies the packet, updates the OHB with any modifications not already present in the OHB, and re-encrypts the packet using the outer (hop-by-hop) cryptographic key before transmitting using the following steps:
-
Apply the outer (hop-by-hop) cryptographic algorithm to decrypt the packet. If decrypting RTP header extensions hop-by-hop, then [RFC 6904] MUST be used. Note that the RTP payload produced by this decryption operation contains the original encrypted payload with the tag from the inner transform and the OHB appended.
-
Make any desired changes to the fields that are allowed to be changed, i.e., PT, SEQ, and M. The MD MAY also make modifications to header extensions, without the need to reflect these changes in the OHB.
-
Reflect any changes to header fields in the OHB:
-
If the MD changed a field that is not already in the OHB, then it MUST add the original value of the field to the OHB. Note that this might result in an increase in the size of the OHB.
-
If the MD took a field that had previously been modified and reset to its original value, then it SHOULD drop the corresponding information from the OHB. Note that this might result in a decrease in the size of the OHB.
-
Otherwise, the MD MUST NOT modify the OHB.
-
Apply the outer (hop-by-hop) cryptographic algorithm to the packet. If the RTP sequence number has been modified, SRTP processing happens as defined in SRTP and will end up using the new sequence number. If encrypting RTP header extensions hop-by-hop, then [RFC 6904] MUST be used.
In order to avoid nonce reuse, the cryptographic contexts used in steps [
1] and [
4]
MUST use different, independent master keys. Note that this means that the key used for decryption by the MD
MUST be different from the key used for re-encryption to the end recipient.
Note that if multiple MDs modify the same packet, then the first MD to alter a given header field is the one that adds it to the OHB. If a subsequent MD changes the value of a header field that has already been changed, then the original value will already be in the OHB, so no update to the OHB is required.
An MD that decrypts, modifies, and re-encrypts packets in this way
MUST use an independent key for each recipient, and
MUST NOT re-encrypt the packet using the sender's keys. If the MD decrypts and re-encrypts with the same key and salt, it will result in the reuse of a (key, nonce) pair, undermining the security of AES-GCM.
To decrypt a packet, the endpoint first decrypts and verifies using the outer (hop-by-hop) cryptographic key, then uses the OHB to reconstruct the original packet, which it decrypts and verifies with the inner (end-to-end) cryptographic key using the following steps:
-
Apply the outer cryptographic algorithm to the packet. If the integrity check does not pass, discard the packet. The result of this is referred to as the outer SRTP packet. If decrypting RTP header extensions hop-by-hop, then [RFC 6904] MUST be used when decrypting the RTP packet using the outer cryptographic key.
-
If the packet is for repair mode data, skip the rest of the steps. Note that the packet that results from the repair algorithm will still have encrypted data that needs to be decrypted as specified by the repair algorithm sections.
-
Remove the inner authentication tag and the OHB from the end of the payload of the outer SRTP packet.
-
Form a new synthetic SRTP packet with:
-
Header = Received header, with the following modifications:
-
Header fields replaced with values from OHB (if any).
-
The X bit is set to zero.
-
The header is truncated to remove any extensions (i.e., keep only the first 12 + 4 * CC bytes of the header).
-
Payload is the encrypted payload from the outer SRTP packet (after the inner tag and OHB have been stripped).
-
Authentication tag is the inner authentication tag from the outer SRTP packet.
-
Apply the inner cryptographic algorithm to this synthetic SRTP packet. Note if the RTP sequence number was changed by the MD, the synthetic packet has the original sequence number. If the integrity check does not pass, discard the packet.
Once the packet has been successfully decrypted, the application needs to be careful about which information it uses to get the correct behavior. The application
MUST use only the information found in the synthetic SRTP packet and
MUST NOT use the other data that was in the outer SRTP packet with the following exceptions:
-
The PT from the outer SRTP packet is used for normal matching to Session Description Protocol (SDP) and codec selection.
-
The sequence number from the outer SRTP packet is used for normal RTP ordering.
The PT and sequence number from the inner SRTP packet can be used for collection of various statistics.
If the RTP header of the outer packet contains extensions, they
MAY be used. However, because extensions are not protected end-to-end, implementations
SHOULD reject an RTP packet containing headers that would require end-to-end protection.