Documentation ¶
Index ¶
- Constants
- Variables
- func ChannelHash(channelName string, channelKey []byte) (uint32, error)
- func CreateNonce(packetId uint32, fromNode uint32) ([]byte, error)
- func GenerateByteSlices() [][]byte
- func ParseKey(key string) ([]byte, error)
- func TryDecode(packet *generated.MeshPacket, key []byte) (*generated.Data, error)
- func XOR(text []byte, key []byte, packetID, fromNode uint32) ([]byte, error)
- type Something
- type Transport
Constants ¶
const ( ComModeProtobuf comMode = iota + 1 ComModeSerialDebug )
Variables ¶
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==
var ErrDecrypt = errors.New("unable to decrypt payload")
Functions ¶
func ChannelHash ¶
GenerateHash returns the hash for a given channel by XORing the channel name and PSK.
func CreateNonce ¶
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 ¶
ParseKey converts the most common representation of a channel encryption key (URL encoded base64) to a byte slice
Types ¶
type Something ¶
type Something struct {
// contains filtered or unexported fields
}
Something is something created to track keys for packet decrypting
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