Documentation
¶
Index ¶
- Constants
- Variables
- func AppendWarpMITag(authKey, packetWithoutTag []byte, roc uint32, tagLen int, ...) []byte
- func AudioPiggybackExtensionFor(packetIndex int, enabled bool, startPacket int, log ...zerolog.Logger) *uint32
- func BuildE2eRtpIV(salt []byte, ssrc uint32, roc uint32, seq uint16) [16]byte
- func BuildRtpICMNonce(ssrc uint32, packetIndex uint64) [16]byte
- func ComputeWarpMITag(authKey, packetWithoutTag []byte, roc uint32, tagLen int, ...) []byte
- func CryptPayload(keys *E2eSrtpKeys, ssrc uint32, seq uint16, roc uint32, payload []byte, ...) ([]byte, error)
- func CryptRtpPayload(session *LibsrtpSessionKeys, ssrc uint32, packetIndex uint64, payload []byte, ...) ([]byte, error)
- func DeriveE2eSframeKeyForParticipant(callKey []byte, participantID string, log ...zerolog.Logger) ([]byte, error)
- func DeriveHbhSrtpKeyDownlink(hbhKey []byte, log ...zerolog.Logger) ([]byte, error)
- func DeriveHbhSrtpKeyUplink(hbhKey []byte, log ...zerolog.Logger) ([]byte, error)
- func DeriveWarpAuthKey(callKey []byte, log ...zerolog.Logger) ([]byte, error)
- func FormatSframeParticipantID(jid string) string
- func ProtectSrtcp(keys *E2eSrtpKeys, senderSsrc, index uint32, rtcp []byte) ([]byte, error)
- func SframeInfoLabel(participantID string) string
- func UnprotectSrtcp(keys *E2eSrtpKeys, senderSsrc uint32, packet []byte) ([]byte, uint32, bool)
- func VerifyWarpMITag(authKey, packetWithoutTag []byte, roc uint32, tagLen int, receivedTag []byte, ...) bool
- type E2eSrtpKeys
- func DeriveE2eKeys(callKey []byte, participantLid string, log ...zerolog.Logger) (E2eSrtpKeys, error)
- func DeriveE2eKeysFromRaw(rawE2e []byte, participantLid string, log ...zerolog.Logger) (E2eSrtpKeys, error)
- func DeriveE2eSRTCPKeysFromRaw(rawE2E []byte, participantLID string, log ...zerolog.Logger) (E2eSrtpKeys, error)
- func DeriveE2eSrtcpKeys(callKey []byte, participantLid string, log ...zerolog.Logger) (E2eSrtpKeys, error)
- type LibsrtpSessionKeys
- type Option
- type RecvRocTracker
- type RocTracker
- type SframeSession
- type SrtpKeyingMaterial
Constants ¶
const ( SrtcpAuthTagLen = 10 SrtcpTrailerLen = 4 + SrtcpAuthTagLen )
const ( KDFLabelE2ESframe = "e2e sframe key" KDFLabelWarpAuth = "warp auth key" )
SFrame KDF labels and lengths.
const ( WarpMITagLen = 4 WarpPiggybackStartPacket = 2 )
const WarpExtProfile uint16 = 0xdebe
Variables ¶
var WarpAudioPiggybackExt = [4]byte{0x30, 0x01, 0x00, 0x00}
WarpAudioPiggybackExt is the audio piggyback extension word (big-endian bytes).
Functions ¶
func AppendWarpMITag ¶
func AppendWarpMITag(authKey, packetWithoutTag []byte, roc uint32, tagLen int, log ...zerolog.Logger) []byte
AppendWarpMITag appends the WARP MI tag to a protected packet.
func AudioPiggybackExtensionFor ¶
func AudioPiggybackExtensionFor(packetIndex int, enabled bool, startPacket int, log ...zerolog.Logger) *uint32
AudioPiggybackExtensionFor returns the audio piggyback extension word for packetIndex, or nil for the first packets / when disabled.
func BuildE2eRtpIV ¶
BuildE2eRtpIV builds the E2E RTP IV: salt right-aligned into 16 bytes, SSRC XORed at bytes 4-7, and the 48-bit packet index (ROC<<16 | seq) XORed at bytes 8-13.
func BuildRtpICMNonce ¶
BuildRtpICMNonce builds the RTP AES-ICM nonce: zero, SSRC at bytes 4-7 (BE), (packetIndex << 16) at bytes 8-15 (BE).
func ComputeWarpMITag ¶
func ComputeWarpMITag(authKey, packetWithoutTag []byte, roc uint32, tagLen int, log ...zerolog.Logger) []byte
ComputeWarpMITag is the WARP MI tag: the first tagLen bytes of HMAC-SHA1(authKey, packetWithoutTag || roc_be32).
func CryptPayload ¶
func CryptPayload(keys *E2eSrtpKeys, ssrc uint32, seq uint16, roc uint32, payload []byte, log ...zerolog.Logger) ([]byte, error)
CryptPayload AES-128-CTR encrypts/decrypts an RTP payload (the cipher is symmetric).
func CryptRtpPayload ¶
func CryptRtpPayload(session *LibsrtpSessionKeys, ssrc uint32, packetIndex uint64, payload []byte, log ...zerolog.Logger) ([]byte, error)
CryptRtpPayload encrypts/decrypts an RTP payload with the expanded session key (symmetric).
func DeriveE2eSframeKeyForParticipant ¶
func DeriveE2eSframeKeyForParticipant(callKey []byte, participantID string, log ...zerolog.Logger) ([]byte, error)
DeriveE2eSframeKeyForParticipant derives the 32-byte per-participant SFrame key from callKey (exactly 32B), salt = callKey[0:16], ikm = callKey[16:32].
func DeriveHbhSrtpKeyDownlink ¶
DeriveHbhSrtpKeyDownlink derives the 30-byte downlink HBH SRTP key from hbhKey (30B).
func DeriveHbhSrtpKeyUplink ¶
DeriveHbhSrtpKeyUplink derives the 30-byte uplink HBH SRTP key from hbhKey (30B).
func DeriveWarpAuthKey ¶
DeriveWarpAuthKey derives the 32-byte WARP auth key from callKey (32B), empty salt, label "warp auth key".
func FormatSframeParticipantID ¶
FormatSframeParticipantID formats the participant id used as the SFrame HKDF info.
func ProtectSrtcp ¶
func ProtectSrtcp(keys *E2eSrtpKeys, senderSsrc, index uint32, rtcp []byte) ([]byte, error)
ProtectSrtcp encrypts and authenticates one RTCP packet.
func SframeInfoLabel ¶
SframeInfoLabel builds the HKDF info label "e2e sframe key<participantID>".
func UnprotectSrtcp ¶
UnprotectSrtcp authenticates and decrypts one SRTCP packet.
Types ¶
type E2eSrtpKeys ¶
E2eSrtpKeys holds the per-participant session keys for the end-to-end 1:1 SRTP cipher: the AES-128 cipher key, the 14-byte master salt, and the auth key.
func DeriveE2eKeys ¶
func DeriveE2eKeys(callKey []byte, participantLid string, log ...zerolog.Logger) (E2eSrtpKeys, error)
DeriveE2eKeys derives the E2E 1:1 keys from callKey (>=32B) using participantLid as the HKDF info. It errors when callKey is shorter than 32 bytes.
func DeriveE2eKeysFromRaw ¶
func DeriveE2eKeysFromRaw(rawE2e []byte, participantLid string, log ...zerolog.Logger) (E2eSrtpKeys, error)
DeriveE2eKeysFromRaw derives the E2E 1:1 keys from a keygen-v2 <raw_e2e> blob (>=32B) in place of callKey. It errors when rawE2e is shorter than 32 bytes.
func DeriveE2eSRTCPKeysFromRaw ¶
func DeriveE2eSRTCPKeysFromRaw(rawE2E []byte, participantLID string, log ...zerolog.Logger) (E2eSrtpKeys, error)
DeriveE2eSRTCPKeysFromRaw derives per-participant SRTCP keys from a keygen-v2 raw E2E root using the RFC 3711 SRTCP labels.
func DeriveE2eSrtcpKeys ¶
func DeriveE2eSrtcpKeys(callKey []byte, participantLid string, log ...zerolog.Logger) (E2eSrtpKeys, error)
DeriveE2eSrtcpKeys derives the per-participant SRTCP keys using RFC 3711 labels.
type LibsrtpSessionKeys ¶
LibsrtpSessionKeys is the expanded per-session keying (AES_CM_128_HMAC_SHA1_80).
func ExpandLibsrtpSessionKeys ¶
func ExpandLibsrtpSessionKeys(keying *SrtpKeyingMaterial, log ...zerolog.Logger) (LibsrtpSessionKeys, error)
ExpandLibsrtpSessionKeys runs the libsrtp session-key expansion (labels 0x00 enc, 0x01 auth, 0x02 salt).
type Option ¶
type Option func(*config)
Option configures optional, non-behavioral aspects of the keying/protection types — currently the diagnostic logger. The zero configuration logs nothing.
func WithLogger ¶
WithLogger sets the zerolog logger for debug/trace diagnostics. The library never configures logging itself; without this option the types are silent at zero cost. Pass the logger from a context, e.g. WithLogger(*zerolog.Ctx(ctx)).
type RecvRocTracker ¶
type RecvRocTracker struct {
// contains filtered or unexported fields
}
RecvRocTracker is the recv-side ROC estimator (RFC 3711 guess-index): it tolerates reorder/loss by guessing each packet's ROC from the highest seq seen.
func (*RecvRocTracker) CommitRoc ¶
func (t *RecvRocTracker) CommitRoc(v uint32, seq uint16, log ...zerolog.Logger)
CommitRoc folds an authenticated packet's estimated ROC and sequence into state.
func (*RecvRocTracker) EstimateRoc ¶
func (t *RecvRocTracker) EstimateRoc(seq uint16, log ...zerolog.Logger) uint32
EstimateRoc estimates the ROC for seq without mutating receive state.
type RocTracker ¶
type RocTracker struct {
// contains filtered or unexported fields
}
RocTracker is the send-side ROC tracker for monotonic 16-bit sequence numbers.
type SframeSession ¶
type SframeSession struct {
SelfParticipantID string
PeerParticipantID string
// contains filtered or unexported fields
}
SframeSession holds the per-direction SFrame keys (encrypt for peer, decrypt for self) and the send-side counter.
func NewSframeSession ¶
func NewSframeSession(callKey []byte, selfJID, peerJID string, opts ...Option) (*SframeSession, error)
NewSframeSession builds a session from callKey and the self/peer JIDs.
func (*SframeSession) Decrypt ¶
func (s *SframeSession) Decrypt(frame []byte) ([]byte, bool)
Decrypt classifies one frame. It returns (plaintext, true) when the trailing SFrame header parses and the GCM tag authenticates; otherwise (nil, false), meaning the frame is plain Opus the caller must use verbatim.
type SrtpKeyingMaterial ¶
SrtpKeyingMaterial is the 16-byte master key + 14-byte master salt split.
func KeyingFromHbhKeyDownlink ¶
func KeyingFromHbhKeyDownlink(hbhKey []byte, log ...zerolog.Logger) (SrtpKeyingMaterial, error)
KeyingFromHbhKeyDownlink derives the downlink key and splits it into keying material.
func KeyingFromHbhKeyUplink ¶
func KeyingFromHbhKeyUplink(hbhKey []byte, log ...zerolog.Logger) (SrtpKeyingMaterial, error)
KeyingFromHbhKeyUplink derives the uplink key and splits it into keying material.