Class FrameCryptor
LiveKit's end-to-end encryption of media frames, as its clients and Element Call do it: AES-GCM with a key derived by HKDF, the first bytes of each frame in the clear and authenticated, and the IV and the key's index after the frame.
Namespace: Uniform.LiveKit
Assembly: Uniform.LiveKit.dll
public sealed class FrameCryptor
Fields
|
Edit this page
View Source
Length of the IV after each frame.
Declaration
public const int IvLength = 12
Field Value
|
Edit this page
View Source
The salt of the key derivation.
Declaration
public static readonly byte[] Salt
Field Value
|
Edit this page
View Source
Length of the AES-GCM tag.
Declaration
public const int TagLength = 16
Field Value
Properties
|
Edit this page
View Source
Declaration
public byte CurrentIndex { get; }
Property Value
|
Edit this page
View Source
Frames that did not decrypt, e.g. before their key came.
Declaration
public long Failures { get; }
Property Value
|
Edit this page
View Source
The trailer of frames an SFU injects, e.g. silence while muted, which come unencrypted; empty for none.
Declaration
public byte[] ServerTrailer { get; set; }
Property Value
Methods
|
Edit this page
View Source
Return how many first bytes of frame stay in the clear.
Declaration
public static int ClearLength(ReadOnlySpan<byte> frame, FrameKind kind)
Parameters
Returns
|
Edit this page
View Source
Return frame decrypted with the key its trailer names; null when it does not decrypt, has no such key, or is a frame the SFU injected.
Declaration
public byte[]? Decrypt(ReadOnlySpan<byte> frame, FrameKind kind)
Parameters
Returns
|
Edit this page
View Source
Return the AES-128 key of a raw key, as LiveKit derives it.
Declaration
public static byte[] DeriveKey(ReadOnlySpan<byte> rawKey)
Parameters
Returns
|
Edit this page
View Source
Return frame encrypted with the current key; the IV takes the stream's ssrc, the frame's timestamp and a counter, so it never repeats.
Declaration
public byte[] Encrypt(ReadOnlySpan<byte> frame, FrameKind kind, uint ssrc, uint timestamp)
Parameters
Returns
Exceptions
|
Edit this page
View Source
Return whether a key of index is set.
Declaration
public bool HasKey(byte index)
Parameters
| Type |
Name |
Description |
| byte |
index |
|
Returns
|
Edit this page
View Source
Set the raw key of index; with current, frames are encrypted with it from now on.
Declaration
public void SetKey(byte index, ReadOnlySpan<byte> rawKey, bool current = true)
Parameters