crypto

package
v0.0.0-...-37f1e7d Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LEN_PREFIX        = 1
	LEN_VERSION       = 1 // Should match len(PREFIX)
	LEN_SUFFIX        = 1 // Should match len(SUFFIX)
	LEN_BODY          = 2
	LEN_LEN_IV        = 1
	LEN_IV            = 12
	LEN_TAG           = 16
	LEN_ACTUAL_HEADER = LEN_BODY + LEN_LEN_IV + LEN_IV
	LEN_HEADER        = LEN_PREFIX + LEN_VERSION + LEN_ACTUAL_HEADER + LEN_SUFFIX /* 0 suffix */
)
View Source
const (
	AES_GCM_TAG_LENGTH = 16
)

Variables

View Source
var (
	PREFIX    = []byte{0}
	VERSION_0 = byte(0)
	VERSION_1 = byte(1)
	SUFFIX    = []byte{0}
)
View Source
var (
	ErrNoData = errors.New("no data was passed")
)

Functions

func DeriveEncryptionKey

func DeriveEncryptionKey(sharedMeetingKey, secretNonce []byte, keyType AesKeyType) []byte

func RewriteAudioHack

func RewriteAudioHack(header []byte, payload []byte) []byte

Types

type AesGcmCrypto

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

func NewAesGcmCrypto

func NewAesGcmCrypto(sharedMeetingKey, secretNonce []byte, keyType AesKeyType) (*AesGcmCrypto, error)

func (*AesGcmCrypto) Decrypt

func (c *AesGcmCrypto) Decrypt(nonce, cipherText []byte) ([]byte, error)

func (*AesGcmCrypto) Encrypt

func (c *AesGcmCrypto) Encrypt(nonce, plaintext []byte) ([]byte, error)

type AesKeyType

type AesKeyType byte
const (
	KEY_TYPE_VIDEO       AesKeyType = 0x00
	KEY_TYPE_AUDIO       AesKeyType = 0x01 // TODO: assumption not tested
	KEY_TYPE_SCREENSHARE AesKeyType = 0x02
)

type RtpEncryptedPayload

type RtpEncryptedPayload struct {
	Version       uint8
	LenCiphertext uint32
	LenIV         uint8
	IV            []byte
	Ciphertext    []byte
	Tag           []byte
}

func NewRtpEncryptedPayload

func NewRtpEncryptedPayload(version uint8, IV []byte, CiphertextWithTag []byte) *RtpEncryptedPayload

func (*RtpEncryptedPayload) Marshal

func (encryptedPayload *RtpEncryptedPayload) Marshal() []byte

func (*RtpEncryptedPayload) Unmarshal

func (encryptedPayload *RtpEncryptedPayload) Unmarshal(payload []byte) error

func (*RtpEncryptedPayload) UnmarshalHeader

func (encryptedPayload *RtpEncryptedPayload) UnmarshalHeader(header []byte) error

Jump to

Keyboard shortcuts

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