Improved AES GCM encryption, changed IV length to 12 bytes. #2962
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
TODO
AES-CTR Initialisation Vector (IV)
The Initialisation Vector (IV) for the AES-CTR encryption mode is derived by exclusive ORing the first 112 bits of the Salt provided in the Keying Material with the packet sequence number (PktSeqNo) in the SRT header, and left-shifting the resulting value by 16 bits:
Thus the counter (keystream) used by the AES engine is the 128-bit value obtained by concatenating the IV with the block counter ("ctr"):
To avoid using the same keystream twice the payload size MUST be less than 2^16 blocks of 128 bits.
AES-GCM Initialisation Vector (IV)
Starting from v1.5.4.
The Initialisation Vector (IV) for the AES-GCM encryption mode is derived by exclusive ORing the first 96 bits of the Salt provided in the Keying Material with the packet sequence number (PktSeqNo) in the SRT header:
Each outbound packet uses a 12-octet IV and an encryption key to form two outputs (RFC-7714):
With an IV taking 96 bits, there are always
128-96=32
bits for the block counter until it wraps around.