encoding

package
v0.0.0-...-4083cd3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxMessageSize                   = 1000
	MaxPacketSize                    = 1400
	HeaderSize                       = 6
	AESEncryptHeaderSize             = 2
	RequestConnect       MessageType = iota
	RequestDisconnect
	Message
	KeepAlive
	WhisperMessage
	ServerActiveUsers
	ErrorMessage
	SendAESKey
)

Variables

View Source
var HeaderPattern = [...]byte{0, 0, 27, 0, 5, 19, 93, 255, 255, 255}

Functions

func PrepAESForSending

func PrepAESForSending(key []byte, receiversPubKey *rsa.PublicKey, keyPair crypto.RSAKeys) ([]byte, error)

func PrepBytesForSending

func PrepBytesForSending(msg []byte, messageType MessageType, sentFrom, colour string, AESKey []byte) ([]byte, error)

func PrepHandshakeForSending

func PrepHandshakeForSending(msg []byte, sentFrom, colour string) ([]byte, error)

Types

type AESProtocol

type AESProtocol struct {
	MessageType MessageType
	MsgSize     uint16
	SigSize     uint16
	DateTime    time.Time
	Data        [crypto.EncodedKeySize]byte
	Sig         [crypto.EncodedKeySize]byte
}

func DecodeAESPacket

func DecodeAESPacket(buffer *bytes.Buffer) AESProtocol

type MessageType

type MessageType uint8

type MsgProtocol

type MsgProtocol struct {
	MessageType    MessageType
	MsgSize        uint16
	UsernameSize   uint16
	UserColourSize uint16
	Username       [32]byte
	UserColour     [32]byte
	DateTime       time.Time
	Data           [MaxMessageSize]byte
}

func DecodeMsgPacket

func DecodeMsgPacket(buffer *bytes.Buffer) MsgProtocol

Jump to

Keyboard shortcuts

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