rtc

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FRAG_SIZE = 16 * 1024
	MAX_FRAGS = 4096
)

Variables

This section is empty.

Functions

func BuildHandshake

func BuildHandshake(selfPriv *ec.PrivateKey, peerPub *ec.PublicKey) ([]byte, []byte, []byte, error)

BuildHandshake creates and signs a handshake payload.

func VerifyHandshake

func VerifyHandshake(raw, sig []byte, selfPriv *ec.PrivateKey) (*ec.PublicKey, []byte, error)

VerifyHandshake verifies peer handshake and returns peer pubkey & salt.

Types

type Fragmenter

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

func NewFragmenter

func NewFragmenter(sess *Session) *Fragmenter

func (*Fragmenter) Encode

func (f *Fragmenter) Encode(plaintext []byte) ([][]byte, error)

Encode splits plaintext into fragments, returns list of BST2 frames ready to send.

type HandshakeMsg

type HandshakeMsg struct {
	Proto string `json:"proto"`
	PK    string `json:"pk"`   // compressed hex
	Salt  string `json:"salt"` // 4 bytes hex
	Ts    int64  `json:"ts"`
}

type Reassembler

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

func NewReassembler

func NewReassembler(sess *Session) *Reassembler

func (*Reassembler) Push

func (r *Reassembler) Push(frame []byte) ([]byte, bool, error)

type Session

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

Session represents an established BST2 session.

func NewSession

func NewSession(selfPriv *ec.PrivateKey, peerPub *ec.PublicKey, selfSalt, peerSalt []byte, logger *zap.Logger) (*Session, error)

NewSession creates session after both handshakes exchanged. If logger is nil, the function stays silent.

func (*Session) DecodeRecord

func (s *Session) DecodeRecord(frame []byte) ([]byte, error)

DecodeRecord decrypts frame and returns plaintext.

func (*Session) EncodeRecord

func (s *Session) EncodeRecord(plaintext []byte, flags byte) ([]byte, error)

EncodeRecord encrypts plaintext into a BST2 frame.

func (*Session) PeerPub added in v0.2.2

func (s *Session) PeerPub() *ec.PublicKey

PeerPub returns peer's public key.

Jump to

Keyboard shortcuts

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