seed2sdp

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 21 Imported by: 3

README

seed2sdp

Golang Test Build


Generate full-length SDP offers/answers from a shared-secret seed with minimal signalling process.

Introduction

WebRTC and presumably many other amazing p2p communication implementations relies on SDP(Session Description Protocol). A traditional SDP weighs over 200 bytes and sometimes could be as long as 500 bytes while most of these data are for only integrity and confidentiality purposes and are unnecessary.

seed2sdp(this project) eliminates the random info in SDP by replacing the uncontrollable randomness with deterministic "randomness" based on HKDF readers and excluding all derivable information from the deflated SDP.

Credits

Pion

Documentation

Index

Constants

View Source
const (
	MINSECRETLEN     int = 8
	MINSALTLEN       int = 8
	MININFOPREFIXLEN int = 8
)
View Source
const (
	SDPOffer     uint8  = 1
	SDPAnswer    uint8  = 2
	SDPOfferStr  string = "offer"
	SDPAnswerStr string = "answer"
)

Variables

View Source
var (
	ErrBadSDPDeflated         = errors.New("seed2sdp: bad sdpDeflated input")
	ErrMalformedICEParameters = errors.New("seed2sdp: malformed iceParameters")
	ErrInvalidIP              = errors.New("seed2sdp: invalid IP address")
	ErrInvalidSDPType         = errors.New("seed2sdp: invalid SDP type")
)

Functions

func FromJSON added in v0.3.0

func FromJSON(in string, obj interface{})

func GetCertificate

func GetCertificate(hkdfParams *HKDFParams) (webrtc.Certificate, error)

GetCertificate() generates DTLS Certificate used for webrtc.

func GetPwd added in v0.2.0

func GetPwd(hkdfParams *HKDFParams) (string, error)

func GetUfrag added in v0.2.0

func GetUfrag(hkdfParams *HKDFParams) (string, error)

func NewCertificate added in v0.2.0

func NewCertificate(hkdfParams *HKDFParams) (webrtc.Certificate, error)

NewCertificate() might be ambiguous: we have notices 2 possible version of Certificates. Use GetCertificate() instead.

func PredictDTLSFingerprint

func PredictDTLSFingerprint(hkdfParams *HKDFParams) (webrtc.DTLSFingerprint, error)

func ToJSON added in v0.3.0

func ToJSON(obj interface{}) string

Types

type DeflatedICECandidate added in v0.4.0

type DeflatedICECandidate struct {
	IPUpper64  uint64
	IPLower64  uint64
	Composed32 uint32 // [16..31]: ICECandidate.port * (1<<16), [4..5]: ICECandidate.tcpType * (1<<4), [2..3]: ICECandidate.candidateType * (1<<2), [1]: ICECandidate.protocol * (1<<1), [0]: ICECandidate.ICEComponent-1
}

func (*DeflatedICECandidate) IPAddr added in v0.4.0

func (c *DeflatedICECandidate) IPAddr() (net.IP, error)

func (*DeflatedICECandidate) Inflate added in v0.4.0

func (c *DeflatedICECandidate) Inflate() ICECandidate

type HKDFParams added in v0.2.0

type HKDFParams struct {
	// contains filtered or unexported fields
}

func NewHKDFParams added in v0.2.0

func NewHKDFParams() *HKDFParams

func (*HKDFParams) IsValid added in v0.3.0

func (p *HKDFParams) IsValid() bool

A valid HKDFParams has all 3 []byte with proper length.

func (*HKDFParams) SetInfoPrefix added in v0.3.0

func (p *HKDFParams) SetInfoPrefix(infoPrefix string) *HKDFParams

func (*HKDFParams) SetSalt added in v0.3.0

func (p *HKDFParams) SetSalt(salt string) *HKDFParams

func (*HKDFParams) SetSecret added in v0.3.0

func (p *HKDFParams) SetSecret(secret string) *HKDFParams

type ICECandidate

type ICECandidate struct {
	// contains filtered or unexported fields
}

func (*ICECandidate) Deflate added in v0.4.0

func (c *ICECandidate) Deflate() DeflatedICECandidate

func (*ICECandidate) Foundation

func (c *ICECandidate) Foundation() uint32

func (*ICECandidate) LocalPreference

func (c *ICECandidate) LocalPreference() uint16

func (*ICECandidate) NetworkType

func (c *ICECandidate) NetworkType() ICENetworkType

func (*ICECandidate) OffsetComponentPreference

func (c *ICECandidate) OffsetComponentPreference() uint32

func (*ICECandidate) Preference

func (c *ICECandidate) Preference() uint32

func (*ICECandidate) Priority

func (c *ICECandidate) Priority() uint32

func (*ICECandidate) SetCandidateType

func (c *ICECandidate) SetCandidateType(candidateType ICECandidateType) *ICECandidate

func (*ICECandidate) SetComponent

func (c *ICECandidate) SetComponent(component ICEComponent) *ICECandidate

Necessary

func (*ICECandidate) SetFoundation

func (c *ICECandidate) SetFoundation(foundation uint32) *ICECandidate

func (*ICECandidate) SetIpAddr

func (c *ICECandidate) SetIpAddr(ipAddr net.IP) *ICECandidate

func (*ICECandidate) SetPort

func (c *ICECandidate) SetPort(port uint16) *ICECandidate

func (*ICECandidate) SetPriority

func (c *ICECandidate) SetPriority(priority uint32) *ICECandidate

func (*ICECandidate) SetProtocol

func (c *ICECandidate) SetProtocol(protocol ICENetworkProtocol) *ICECandidate

func (*ICECandidate) SetTcpType

func (c *ICECandidate) SetTcpType(tcpType ice.TCPType)

type ICECandidateType

type ICECandidateType uint8
const (
	Host  ICECandidateType = iota // 0
	Srflx                         // 1
	Prflx                         // 2
	Relay                         // 3 // 2-bits
	Unknown
)

3-bits to exchange

func (ICECandidateType) String

func (ic ICECandidateType) String() string

type ICEComponent

type ICEComponent uint8
const (
	ICEComponentUnknown ICEComponent = iota // 0
	ICEComponentRTP                         // 1
	ICEComponentRTCP                        // 2
)

1-bit to exchange

type ICENetworkProtocol

type ICENetworkProtocol uint8
const (
	UDP ICENetworkProtocol = iota // 0
	TCP                           // 1 // 1-bit
	BADNETWORKPROTOCOL
)

1-bits to exchange

func (ICENetworkProtocol) String

func (inp ICENetworkProtocol) String() string

type ICENetworkType

type ICENetworkType uint8
const (
	UDP4 ICENetworkType = iota
	UDP6
	TCP4
	TCP6
	BADNETWORKTYPE
)

Derived locally

func (ICENetworkType) String

func (intype ICENetworkType) String() string

type ICEParameters

type ICEParameters struct {
	UsernameFragment string // 16-char
	Password         string // 32-char
	ICELite          bool   // Always false for now
}

func PredictIceParameters

func PredictIceParameters(hkdfParams *HKDFParams) (ICEParameters, error)

func (ICEParameters) Equal added in v0.2.0

func (i ICEParameters) Equal(d ICEParameters) bool

func (*ICEParameters) InjectSettingEngine added in v0.3.7

func (i *ICEParameters) InjectSettingEngine(se *webrtc.SettingEngine) error

InjectSettingEngine() would inject the pseudorandom ice-ufrag and ice-pwd into se *SettingEngine

type SDP added in v0.3.0

type SDP struct {
	SDPType       string                 // value of "type" key
	Malleables    SDPMalleables          // v, o, s, t, c lines in "sdp" key's value
	Medias        []SDPMedia             // m lines in "sdp" key's value
	Attributes    []SDPAttribute         // a lines in "sdp" key's value
	Fingerprint   webrtc.DTLSFingerprint // Also an attribute, but calculated
	IceParams     ICEParameters          // Also 2 attribute, but calculated
	IceCandidates []ICECandidate         // Also attributes, but calculated
}

func ParseSDP

func ParseSDP(sdpText string) SDP

func (*SDP) AddAttrs added in v0.3.1

func (s *SDP) AddAttrs(newval SDPAttribute)

func (*SDP) AddIceCandidates added in v0.3.1

func (s *SDP) AddIceCandidates(newval ICECandidate)

func (*SDP) AddMedia added in v0.3.1

func (s *SDP) AddMedia(newval SDPMedia)

func (*SDP) Deflate added in v0.3.0

func (S *SDP) Deflate(candidateIP []net.IP) *SDPDeflated

func (*SDP) SetFingerprint added in v0.3.1

func (s *SDP) SetFingerprint(newval webrtc.DTLSFingerprint)

func (*SDP) SetIceParams added in v0.3.1

func (s *SDP) SetIceParams(newval ICEParameters)

func (*SDP) SetMalleables added in v0.3.1

func (s *SDP) SetMalleables(newval SDPMalleables)

func (*SDP) String added in v0.3.0

func (s *SDP) String() string

type SDPAttribute added in v0.3.1

type SDPAttribute struct {
	Key   string
	Value string
}

The lines that does not impact

func (*SDPAttribute) String added in v0.3.1

func (sa *SDPAttribute) String() string

type SDPConnectionData added in v0.3.1

type SDPConnectionData struct {
	Direction string
	IPType    string
	Hostname  string
}

The lines that does not impact

func NewSDPConnectionData added in v0.3.1

func NewSDPConnectionData() SDPConnectionData

func (*SDPConnectionData) String added in v0.3.1

func (cp *SDPConnectionData) String() string

type SDPDeflated added in v0.3.1

type SDPDeflated struct {
	SDPType    uint8
	Candidates []DeflatedICECandidate
}

SDPDeflated represents the minimal info need to be exchanged for SDP

func SDPDeflatedFromString added in v0.3.2

func SDPDeflatedFromString(SDS string) (SDPDeflated, error)

func (SDPDeflated) Inflate added in v0.3.1

func (sd SDPDeflated) Inflate() (*SDP, error)

func (*SDPDeflated) String added in v0.3.2

func (SD *SDPDeflated) String() string

String() return SDPDeflated in string format (old version compatibility)

type SDPMalleables added in v0.3.1

type SDPMalleables struct {
	Version        uint32            // v=0
	Origin         SDPOrigin         // o=- 0 0 IN IP4 0.0.0.0
	SessionName    string            // s=-
	ConnectionData SDPConnectionData // c=IN IP4 0.0.0.0
	Timing         SDPTiming         // t=0 0
}

SDPMalleable includes v, o, s, c, t which "do not affect the WebRTC session". (WebRTC For The Curious, page 13)

func NewSDPMalleables added in v0.3.1

func NewSDPMalleables() SDPMalleables

func PredictSDPMalleables added in v0.3.7

func PredictSDPMalleables(_ *HKDFParams) SDPMalleables

Reserved

func (*SDPMalleables) String added in v0.3.1

func (sm *SDPMalleables) String() string

v=0 o=- 0 0 IN IP4 0.0.0.0 s=- c=IN IP4 0.0.0.0 t=0 0

type SDPMedia added in v0.3.1

type SDPMedia struct {
	MediaType   string
	Description string
}

The lines that does not impact

func (*SDPMedia) String added in v0.3.1

func (sm *SDPMedia) String() string

type SDPOrigin added in v0.3.1

type SDPOrigin struct {
	SessionId      uint64
	SessionVer     uint32
	ConnectionData SDPConnectionData
}

The lines that does not impact

func NewSDPOrigin added in v0.3.1

func NewSDPOrigin() SDPOrigin

func (*SDPOrigin) String added in v0.3.1

func (so *SDPOrigin) String() string

type SDPTiming added in v0.3.1

type SDPTiming struct {
	Start uint32
	End   uint32
}

The lines that does not impact

func NewSDPTiming added in v0.3.1

func NewSDPTiming() SDPTiming

func (*SDPTiming) String added in v0.3.1

func (st *SDPTiming) String() string

Directories

Path Synopsis
examples
datachannel Module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL