encode

package
v0.0.0-...-84ed8a2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptAndRead

func DecryptAndRead(
	buffer *bytes.Buffer, encType openiot.EncryptionType, key []byte, msgs ...proto.Message) error

DecryptAndRead decrypts buffer using encoding from encType, then de-serializes all messages using "delimited" approach.

func DecryptAndReadCBC

func DecryptAndReadCBC(buffer *bytes.Buffer, key, iv []byte, msgs ...proto.Message) error

DecryptAndReadCBC decrypts buffer using AES-CBC with provided key and IV, then de-serializes all messages using "delimited" approach.

func DecryptAndReadECB

func DecryptAndReadECB(buffer *bytes.Buffer, key []byte, msgs ...proto.Message) error

DecryptAndReadECB decrypts buffer using AES-ECB with provided key, then de-serializes all messages using "delimited" approach.

func MakeReadyToSendDeviceMessage

func MakeReadyToSendDeviceMessage(dev *device.Device, msg proto.Message) ([]byte, error)

MakeReadyToSendDeviceMessage makes ready to be send bytes using device's settings and proto message It does: - Serializes protobuf message - Calculates CRC - Makes MessageInfo header - Encrypts all (if enabled on device) - Makes Header - Writes all messages into buffer and returns bytes

func MakeReadyToSendMessage

func MakeReadyToSendMessage(
	hdr *openiot.Header, enc openiot.EncryptionType, key []byte, msgs ...proto.Message) ([]byte, error)

MakeReadyToSendMessage makes message ready to be send, it does: - Serialize all msgs - Calculate CRC - Optionally encrypt messages - Write all messages into buffer

func ReadPlain

func ReadPlain(buffer *bytes.Buffer, msgs ...proto.Message) error

ReadPlain de-serializes all messages using "delimited" approach. It does not perform any decryption

func ReadSingleMessage

func ReadSingleMessage(buffer *bytes.Buffer, msg proto.Message) error

ReadSingleMessage reads and de-serializes protobuf from buffer previously encoded using "delimited" approach, i.e. message length followed by message payload

func WriteAndEncrypt

func WriteAndEncrypt(
	buffer *bytes.Buffer, encType openiot.EncryptionType, key []byte, msgs ...proto.Message) error

WriteAndEncrypt serializes all messages using "delimited" approach, then encodes result with encoding from encType.

func WriteAndEncryptCBC

func WriteAndEncryptCBC(buffer *bytes.Buffer, key, iv []byte, msgs ...proto.Message) error

WriteAndEncryptCBC serializes all messages using "delimited" approach, then encodes result with AES-CBC using provided key and iv.

func WriteAndEncryptECB

func WriteAndEncryptECB(buffer *bytes.Buffer, key []byte, msgs ...proto.Message) error

WriteAndEncryptECB serializes all messages using "delimited" approach, then encodes result with AES ECB using provided key.

func WritePlain

func WritePlain(buffer *bytes.Buffer, msgs ...proto.Message) error

WritePlain serializes all messages using "delimited" it does not performs any type of encryption, just writes messages into buffer

func WriteSingleMessage

func WriteSingleMessage(buffer *bytes.Buffer, msg proto.Message) error

WriteSingleMessage serializes single protobuf using "delimited" approach into buffer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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