radio

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ComModeProtobuf comMode = iota + 1
	ComModeSerialDebug
)

Variables

View Source
var DefaultKey = []byte{0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01}

default encryption key, commonly referenced as AQ== as base64: 1PG7OiApB1nwvP+rz05pAQ==

View Source
var ErrDecrypt = errors.New("unable to decrypt payload")

Functions

func ChannelHash

func ChannelHash(channelName string, channelKey []byte) (uint32, error)

GenerateHash returns the hash for a given channel by XORing the channel name and PSK.

func CreateNonce

func CreateNonce(packetId uint32, fromNode uint32) ([]byte, error)

CreateNonce creates a 128-bit nonce. It takes a uint32 packetId, converts it to a uint64, and a uint32 fromNode. The nonce is concatenated as [64-bit packetId][32-bit fromNode][32-bit block counter].

func GenerateByteSlices

func GenerateByteSlices() [][]byte

GenerateByteSlices creates a bunch of weak keys for use when interfacing on MQTT. This creates 128, 192, and 256 bit AES keys with only a single byte specified

func ParseKey

func ParseKey(key string) ([]byte, error)

ParseKey converts the most common representation of a channel encryption key (URL encoded base64) to a byte slice

func TryDecode

func TryDecode(packet *generated.MeshPacket, key []byte) (*generated.Data, error)

Attempts to decrypt a packet with the specified key, or return the already decrypted data if present.

func XOR

func XOR(text []byte, key []byte, packetID, fromNode uint32) ([]byte, error)

XOR encrypts or decrypts text with the specified key. It requires the packetID and sending node ID for the AES IV

Types

type Something

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

Something is something created to track keys for packet decrypting

func NewThing

func NewThing() *Something

func (*Something) TryDecode

func (s *Something) TryDecode(packet *generated.MeshPacket, key []byte) (*generated.Data, error)

decode a payload to a Data protobuf

type Transport

type Transport interface {
	Connect() error
	SendPacket(data []byte) error
	RequestConfig() error

	//	Listen(ch chan)
	Close() error
}

Transport defines methods required for communicating with a radio via serial, ble, or tcp Probably need to reevaluate this to just use the ToRadio and FromRadio protobufs

Jump to

Keyboard shortcuts

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